-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
setupsystem.sh
executable file
·162 lines (150 loc) · 5.45 KB
/
setupsystem.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
echo "STATUS- creating /var/tmp/configs directory"
if [ ! -d "/var/tmp/configs" ]; then
sudo mkdir /var/tmp/configs
else
echo "STATUS- /var/tmp/configs already exists"
fi
echo "STATUS- creating /var/tmp/status directory"
if [ ! -d "/var/tmp/status" ]; then
sudo mkdir /var/tmp/status
else
echo "STATUS- /var/tmp/status already exists"
fi
echo "STATUS- creating /var/tmp/scan directory"
if [ ! -d "/var/tmp/scan" ]; then
sudo mkdir /var/tmp/scan
else
echo "STATUS- /var/tmp/scan already exists"
fi
echo "STATUS- creating /var/app directory"
if [ ! -d "/var/app" ]; then
sudo mkdir /var/app
else
echo "STATUS- /var/app already exists"
fi
echo "STATUS- creating /var/app/public directory"
if [ ! -d "/var/app/public" ]; then
sudo mkdir /var/app/public
else
echo "STATUS- /var/app/public already exists"
fi
#echo "STATUS- checking for ./webapp/server.js"
#if [ -f "./webapp/server.js" ]; then
# echo "STATUS- found server.js- installing"
# sudo cp ./webapp/server.js /var/app
#else
# echo "STATUS- unable to find server.js - aborting!!!"
# echo "STATUS- please make sure you are running this script from the cloned project directory"
# exit
#fi
#
#echo "STATUS-checking for ./webapp/public/client.js"
#if [ -f "./webapp/public/client.js" ]; then
# echo "STATUS- found client.js- installing"
# sudo cp ./webapp/public/client.js /var/app/public
#else
# echo "STATUS- unable to find client.js - aborting!!!"
# echo "STATUS- please make sure you are running this script from the cloned project directory"
# exit
#fi
#
#echo "STATUS-checking for ./webapp/public/index.html"
#if [ -f "./webapp/public/index.html" ]; then
# echo "STATUS- found index.html- installing"
# sudo cp ./webapp/public/index.html /var/app/public
#else
# echo "STATUS- unable to find index.html - aborting!!!"
# echo "STATUS- please make sure you are running this script from the cloned project directory"
# exit
#fi
#
#echo "STATUS-checking for ./webapp/package.json"
#if [ -f "./webapp/package.json" ]; then
# echo "STATUS- found package.json- installing"
# sudo cp ./webapp/package.json /var/app
#else
# echo "STATUS- unable to find package.json - aborting!!!"
# echo "STATUS- please make sure you are running this script from the cloned project directory"
# exit
#fi
echo "STATUS-performing global Ubuntu update"
sudo apt-get update -y
echo "STATUS-performing global Ubuntu ugrade of packages"
sudo apt-get upgrade -y
echo "STATUS-installing build-essential packages"
sudo apt-get install build-essential -y
echo "STATUS-intallling libssl-dev packages"
sudo apt-get install libssl-dev -y
echo "STATUS-installing curl packages"
sudo apt-get install curl -y
echo "STATUS-installing ca-certificates"
sudo apt-get install -y ca-certificates
echo "STATUS-installing gnupg"
sudo apt-get install -y gnupg
echo "STATUS-making keyrings directory /etc/apt/keyrings for Nodesource GPG key"
sudo mkdir -p /etc/apt/keyrings
echo "STATUS-importing Nodesource GPG key"
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=18
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get update
sudo apt-get install -y nodejs
echo "STATUS- check to see if cleanup.sh installed in crontab"
CRON_TAB_DUMP=`crontab -l > checkcrontab.txt`
CLEANUP_ACTIVE=`grep -r 'cleanup.sh' checkcrontab.txt`
if [ -n "$CLEANUP_ACTIVE" ]; then
echo "cleanup.sh already in crontab"
else
echo "including cleanup.sh in crontab"
ADD_CLEANUP_TO_CRON=`(crontab -l 2>/dev/null; echo "0 * * * * /usr/bin/cleanup.sh") | crontab -`
fi
echo "STATUS- copying cleanup.sh to /usr/bin"
sudo cp cleanup.sh /usr/bin
sudo chmod +x /usr/bin/cleanup.sh
#sudo chmod +x nodesource_setup.sh
#echo "STATUS- running nodesource_setup.sh"
#sudo ./nodesource_setup.sh
#echo "STATUS- installing nodejs- full package from local repository"
#sudo apt-get install -y nodejs
echo "STATUS- installing pm2"
sudo npm install -g pm2
pushd /var/app
echo "STATUS- installing express (global)"
sudo npm install -g express
echo "STATUS- installing body-parser (global)"
sudo npm install -g body-parser
echo "STATUS- installing fs (global)"
sudo npm install -g fs
echo "STATUS- install archiver (global)"
sudo npm install -g archiver
echo "STATUS- install winston logger (global)"
sudo npm install -g winston
echo "STATUS- install read-last-lines file reader (global)"
sudo npm install -g read-last-lines
echo "STATUS- install npm-nvidia-smi (global)"
sudo npm install -g node-nvidia-smi
echo "STATUS- creating node_modules symbolic link to current directory"
sudo ln -s /usr/lib/node_modules ./node_modules
popd
echo "STATUS- installing Docker"
sudo apt-get install docker.io -y
echo "STATUS- installing tcpdump"
sudo apt-get install tcpdump -y
echo "STATUS- installing ifstat"
sudo apt-get install ifstat -y
echo "STATUS- installing zip"
sudo apt-get install zip -y
echo "STATUS- installing unzip"
sudo apt-get install unzip -y
echo "STATUS- installing apache"
sudo apt-get install apache2 -y
echo "STATUS- installing docker-buildx"
sudo apt-get install docker-buildx -y
#https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#installing-on-ubuntu-and-debian
echo "STATUS- updating pm2 (if needed)"
sudo npm install pm2@latest -g
sudo pm2 update
echo ""
echo "Please make sure you also run setuptranscode.sh!!"
echo ""