forked from acasadoalonso/SWiface
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·280 lines (280 loc) · 9.43 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#!/bin/bash
echo #
echo " " #
echo " " #
echo "========================================================" #
echo "Installing the Silent Wings Studio interface ...." #
echo "========================================================" #
echo " " #
echo " " #
echo #
if [ $# -eq 0 ]; then #
sql='NO' #
else #
sql=$1 #
fi #
if [ $sql = 'MySQL' ]; then #
server=localhost #
elif [ $sql = 'Mariadb' ]; then #
server=localhost #
elif [ $sql = 'VM' ]; then #
server=172.17.0.2 #
elif [ $sql = 'docker' ]; then #
server=MARIADB #
else #
server=localhost #
fi #
echo "SQL option: "$sql" Server: "$server #
ping -c 5 $server #
ping -c 5 172.17.0.2 #
sleep 5 #
if [ ! -f /tmp/commoninstall.sh ] #
then #
echo "Installing the common software" #
echo "==============================" #
bash commoninstall.sh $sql #
echo "==============================" #
fi #
echo "========================================================" #
echo "Installing the specific parts of SWS interface ...." #
echo "========================================================" #
cd /var/www/html/main #
echo " -------------------- APACHE restarting ---------------" #
sudo cat /etc/apache2/apache2.conf html.dir >>temp.conf #
sudo echo "ServerName SWserver " >>temp.conf #
sudo mv temp.conf /etc/apache2/apache2.conf #
sudo service apache2 restart #
echo " -------------------- APACHE restarted ---------------" #
cd /var/www/html/main #
echo #
echo " " #
echo "========================================================" #
echo " " #
echo #
if [ ! -f .DBpasswd ] #
then #
cp /tmp/.DBpasswd . #
fi #
if [ ! -f .DBpasswd ] #
then #
echo "Type DB password ..." #
read DBpasswd #
echo $DBpasswd > .DBpasswd #
fi #
echo "DB passwd:"$(cat .DBpasswd) #
if [ $sql = 'MySQL' ] #
then #
echo "Type ROOT old password: " #
echo " " #
echo "========================================================" #
echo "ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'ognognogn';" | sudo mysql -u root -p #
echo "Type ROOT new password: " #
echo " " #
echo "========================================================" #
echo "SELECT user,authentication_string,plugin,host FROM mysql.user; " | sudo mysql -u root -p #
echo #
echo " " #
mysql_config_editor print --all #
fi #
if [ ! -d /etc/local ] #
then #
sudo mkdir /etc/local #
fi #
cd /var/www/html/main #
if [ ! -d ~/src ] #
then #
mkdir ~/src #
if [ ! -d ~/src/SWSsrc ] #
then #
ln -s $(pwd) ~/src/SWSsrc #
fi #
fi #
echo " " #
echo " DIR: /src ..." #
echo "================================================" #
ls -la ~/src #
echo " DIR: /src/SWSsrc ..." #
echo "================================================" #
ls -la ~/src/SWSsrc #
echo " DIR: /src/SWSsrc/sh ..." #
echo "================================================" #
ls -la ~/src/SWSsrc/sh #
echo "================================================" #
echo " " #
echo "Installing the templates needed ...." #
echo "========================================================" #
echo " " #
echo #
cd /var/www/html/main #
sudo cp config.template /etc/local/SWSconfig.ini #
cd /var/www/html/ #
cp configtail.template configtail.txt #
python3 genconfig.py #
ls -la #
echo #
echo " " #
echo "Setting the data bases ...." #
echo "========================================================" #
echo " " #
echo #
if [ ! -f /tmp/GLIDERS.sql ] #
then #
cd /tmp #
wget acasado.es:60080/files/GLIDERS.sql 2>/dev/null #
fi #
cd /var/www/html/ #
if [ -f SWiface.db ] #
then #
rm SWiface.db #
fi #
if [ ! -d cuc ] #
then #
mkdir cuc #
chmod 777 cuc #
mkdir cuc/TSKF #
chmod 777 cuc/TSKF #
fi #
cd /var/www/html/ #
sqlite3 SWiface.db < main/DBschema.sqlite3 #
if [ -d /nfs/OGN/SWdata ] #
then #
mv SWiface.db /nfs/OGN/SWdata #
fi #
echo " " #
echo "========================================================" #
echo "Create the MySQL database SWIFACE " #
echo "========================================================" #
if [ $sql = 'MySQL' ] #
then #
echo "Create the APRSogn login-path: Type assigned password" #
mysql_config_editor set --login-path=APRSogn --user=ogn --password
fi #
cd /var/www/html/main #
cp doc/.my.cnf ~/ #
echo "Create DB user ogn ...DB:"$sql #
echo "========================================================" #
if [ $sql = 'MySQL' ] #
then #
sudo mysql --login-path=APRSogn <doc/adduser.sql #
echo "CREATE DATABASE if not exists SWIFACE" | mysql --login-path=APRSogn #
mysql --login-path=APRSogn --database SWIFACE <DBschema.sql #
mysql -u ogn -p$(cat .DBpasswd) SWIFACE </tmp/GLIDERS.sql #
else #
if [ $sql = 'mariadb' ] #
then #
echo "Installing MariaDB" #
sudo apt-get install -y mariadb-server mariadb-client #
docker stop mariadb #
sudo service mariadb start #
fi #
if [ $sql = 'VM' ] #
then #
echo "Installing MariaDB on a VM" #
sudo apt-get install -y mariadb-client #
fi #
if [ ! $sql = 'NO' ] #
then #
echo "Add user ogn ... with password: "$(cat .DBpasswd) #
sudo mysql -u root -p$(cat .DBpasswd) -h $server <doc/adduser.sql #
echo "CREATE DATABASE if not exists SWIFACE" | mysql -h $server -u ogn -p$(cat .DBpasswd)
mysql -u ogn -p$(cat .DBpasswd) -h $server SWIFACE <SWIFACE.sql #
if [ -f /tmp/GLIDERS.sql ] #
then #
mysql -u ogn -p$(cat .DBpasswd) -h $server SWIFACE </tmp/GLIDERS.sql #
fi #
fi #
fi #
cd /var/www/html/main #
if [ $sql = 'docker' ] #
then #
echo "Create DB in docker ogn ..." #
echo "========================================================" #
echo "CREATE DATABASE if not exists SWIFACE" | sudo mysql -u ogn -p$(cat .DBpasswd) -h MARIADB
echo "SET GLOBAL log_bin_trust_function_creators = 1; " | sudo mysql -u ogn -p$(cat .DBpasswd) -h MARIADB
sudo mysql -u ogn -p$(cat .DBpasswd) -h MARIADB --database SWIFACE <SWIFACE.sql
sudo mysql -u ogn -p$(cat .DBpasswd) -h MARIADB --database SWIFACE </tmp/GLIDERS.sql
fi #
sudo rm /tmp/GLIDERS.sql* #
echo " " #
echo "Optional steps ... " #
echo "========================================================" #
echo " " #
echo #
cd /var/www/html/main #
if [ ! -f ~/.bash_aliases ] #
then #
cp aliases ~/.bash_aliases #
fi #
cd sh #
if [ -f crontab.data ] #
then #
crontab <crontab.data #
crontab -l #
fi #
if [ ! -d ~/src ] #
then #
mkdir ~/src #
fi #
if [ ! -d ~/src/SWSsrc ] #
then #
mkdir ~/src/SWSsrc #
ln -s /var/www/html/main ~/src/SWSsrc #
fi #
ls -la ~/src #
if [ ! -d /nfs/OGN/SWdata ] #
then #
echo #
echo "Adding user ogn ... " #
echo "=============== ... " #
sudo adduser ogn #
sudo mkdir /nfs #
sudo mkdir /nfs/OGN #
sudo mkdir /nfs/OGN/SWdata #
sudo chown ogn:ogn /nfs/OGN/SWdata #
sudo chmod 777 /nfs/OGN/SWdata #
cd /var/www/html/ #
mv SWiface.db /nfs/OGN/SWdata #
sudo chown ogn:ogn * #
sudo chmod 777 * #
sudo chown ogn:ogn */* #
sudo chmod 777 */* #
ls -la #
fi #
echo " " #
echo "========================================================" #
echo " " #
cd /var/www/html #
if [ ! -f /usr/local/bin/calcelestial ] #
then #
cd main/sh #
sh calcelestial.sh #
calcelestial -h #
fi #
cd #
sudo chmod 755 /var/log/syslog #
tail /var/log/syslog #
touch SWSinstallation.done #
echo " " #
sudo apt-get -y dist-upgrade #
sudo apt-get -y autoremove #
echo #
echo "========================================================================================================" #
echo "Installation done ..." #
echo "Review the configuration file on /etc/local and the config tail file configtail.txt ..." #
echo "Review the configuration of the crontab and the shell scripts on ~/src " #
echo "In order to execute the Silent Wings data crawler execute: bash ~/src/SWlive.sh " #
echo "Check the placement of the RootDocument on APACHE2 ... needs to be /var/www/html" #
echo "If running in Windows under Virtual Box, run dos2unix on /var/www/html & ./main & ~/src" #
echo "Run the utilities soa2sws.py and/or sgp2sws.py in order to extract the data from SoaringSpot.com or SGP" #
echo "========================================================================================================" #
echo #
echo " " #
echo " " #
echo " " #
echo " " #
echo " " #
echo " " #
echo " " #
echo " " #
echo " " #
echo " ======================= END ===========================" #