-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·102 lines (87 loc) · 2.03 KB
/
install.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
# TODO: remove comments
####################################
# Script to set up worker #
####################################
#USERNAME="origin-task-worker"
#USERNAME="fahad"
USERNAME="origin-task-dispatcher"
ROOT_UID=1000
function program_is_installed(){
local return_=1
type $1 >/dev/null 2>&1 || { local return_=0; }
echo "$return_"
}
function npm_package_is_installed(){
local return_=1
type $1 >/dev/null 2>&1 || { local return_=0; }
echo "$return_"
}
function add_new_user(){
if [ "$UID" -eq "$ROOT_UID" ]
then
echo "Must be root user to run this script"
exit 1
else
if id "$USERNAME" >/dev/null 2>&1; then
echo "User $USERNAME already exists"
exit 1
else
sudo useradd --no-user-group --gid www-data --system --create-home \
--shell /usr/sbin/nologin $USERNAME
echo "Setting up Account"
fi
fi
}
function update_upgrade(){
echo
if [ "$UID" -eq "$ROOT_UID" ]
then
echo "Must be root user to run this script"
exit 1
else
echo "Update packages and upgrade system"
apt-get update -y
fi
}
function install_curl(){
res=$(program_is_installed curl)
if [ "$res" -eq 1 ]
then
echo
echo ">>>" curl is already installed
else
echo
echo Installing curl
apt-get install curl -y
fi
}
function install_node(){
res=$(program_is_installed nodejs)
if [ "$res" -eq 1 ]
then
echo
echo ">>>" Node already installed
else
echo Installing NodeJS
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
fi
}
function install_pm2(){
res=$(npm_package_is_installed pm2)
if [ "$res" -eq 1 ]
then
echo
echo ">>>" PM2 is already installed
else
echo
echo Intalling PM2
npm i -g pm2 -y
fi
}
update_upgrade
install_curl
install_node
install_pm2
add_new_user