forked from ubports/ubports-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-dev.sh
executable file
·71 lines (64 loc) · 1.72 KB
/
setup-dev.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
distro=$(lsb_release -si)
version=$(lsb_release -sr)
isNodeInstalled=false
isNpmInstalled=false
echo "The script will try to install nodejs and npm on the machine."
if command -v node &> /dev/null
then
echo "nodejs is already installed."
isNodeInstalled=true
fi
if command -v npm &> /dev/null
then
isNpmInstalled=true
echo "npm is already installed."
fi
if [ "$isNodeInstalled" = true ] && [ "$isNpmInstalled" = true ]
then
echo "Both node and npm are already installed. Nothing more to install."
exit
fi
packageCommand="apt install"
case "${distro}" in
"Arch")
packageCommand="pacman -S"
packages="npm nodejs"
;;
"openSUSE")
packages="npm nodejs"
;;
"Ubuntu")
if [[ ${version:0:2} -gt 19 ]]; then
packages="npm nodejs libgconf-2-4"
elif [[ ${version:0:2} -ge 18 ]]; then
packages="npm nodejs libgconf2-4"
fi
;;
"Fedora")
if [[ ${version} -ge 18 ]]; then
packageCommand="dnf install"
else
packageCommand="yum install"
fi
packages="npm nodejs"
;;
"VoidLinux")
packageCommand="xbps-install"
packages="nodejs"
;;
"*")
packages="npm nodejs-legacy"
echo "Distro could not be identified. Please add yours to the script."
echo " Falling back to attempt default packages using apt"
;;
esac
echo "Installing nodejs..."
sudo ${packageCommand} ${packages}
if [[ ${?} -ne 0 ]]; then
echo "Failed to install packages. Please troubleshoot and try again"
exit 1
fi
echo "Setting up node modules..."
npm install
echo "Dev setup complete. Thank you for hacking on the UBports Installer!"