-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-u12.sh
453 lines (430 loc) · 16.7 KB
/
install-u12.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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
#!/bin/bash
##
RootCheck()
{
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
}
Welcome()
{
echo "*************************************************************************";
echo "EkoView Netbook Setup for Ubuntu 12.04 LTS";
echo "Welcome $CurrentUser"
echo "*************************************************************************";
}
Requirement()
{
echo "*** This setup written for machines with the following specifications ***"
echo " OS : Ubuntu 12.04 LTS (Precise Pangolin) only"
echo " CPU : Intel Atom 1.6 GHz and above"
echo " RAM : 512 MB and above"
echo " HDD : 3.5 GB (Minimum)"
echo " >5.0 GB (Recommended)"
echo "FAILING to comply to above specification may cause certain component "
echo "MALFUNCTIONS !!!"
echo "*** This script will install required components and dependencies to"
echo " run XServe and EkoView on Linux OS Ubuntu 12.04 LTS (Precise Pangolin) ***"
echo "*** Recommended to run this script for initial setup on fresh OS ***"
echo ""
}
SourceList()
{
echo "Updating source list...";
apt-get update
echo "Updated successfully !";
echo "";
}
ServerComponent()
{
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' apache2|grep "install ok installed")
echo "Checking for apache2: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No apache2. Setting up apache2..."
sudo apt-get -fyV install apache2
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' apache2-doc|grep "install ok installed")
echo "Checking for apache2-doc: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No apache2-doc. Setting up apache2-doc..."
sudo apt-get -fyV install apache2-doc
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' apache2-utils|grep "install ok installed")
echo "Checking for apache2-utils: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No apache2-utils. Setting up apache2-utils..."
sudo apt-get -fyV install apache2-utils
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' php5|grep "install ok installed")
echo "Checking for php5: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No php5. Setting up php5..."
sudo apt-get -fyV install php5
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' php-pear|grep "install ok installed")
echo "Checking for php-pear: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No php-pear. Setting up php-pear..."
sudo apt-get -fyV install php-pear
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' php5-xcache|grep "install ok installed")
echo "Checking for php5-xcache: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No php5-xcache. Setting up php5-xcache..."
sudo apt-get -fyV install php5-xcache
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' php5-suhosin|grep "install ok installed")
echo "Checking for php5-suhosin: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No php5-suhosin. Setting up php5-suhosin..."
sudo apt-get -fyV install php5-suhosin
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' php5-mysql|grep "install ok installed")
echo "Checking for php5-mysql: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No php5-mysql. Setting up php5-mysql..."
sudo apt-get -fyV install php5-mysql
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libapache2-mod-ruby|grep "install ok installed")
echo "Checking for libapache2-mod-ruby: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No libapache2-mod-ruby. Setting up libapache2-mod-ruby..."
sudo apt-get -fyV install libapache2-mod-ruby
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libapache2-mod-perl2|grep "install ok installed")
echo "Checking for libapache2-mod-perl2: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No libapache2-mod-perl2. Setting up libapache2-mod-perl2..."
sudo apt-get -fyV install libapache2-mod-perl2
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libapache2-mod-python|grep "install ok installed")
echo "Checking for libapache2-mod-python: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No libapache2-mod-python. Setting up libapache2-mod-python..."
sudo apt-get -fyV install libapache2-mod-python
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' python-mysqldb|grep "install ok installed")
echo "Checking for python-mysqldb: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No python-mysqldb. Setting up python-mysqldb..."
sudo apt-get -fyV install python-mysqldb
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libapache2-mod-php5|grep "install ok installed")
echo "Checking for libapache2-mod-php5: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No libapache2-mod-php5. Setting up libapache2-mod-php5..."
sudo apt-get -fyV install libapache2-mod-php5
fi
echo "Installation complete !";
echo "";
}
DownloadEkoView()
{
echo "Backing up database..";
mv -v /usr/xbow/www/sys/xserve_sqlite.db "/home/$CurrentUser/Desktop/xserve_sqlite_$(date '+%Y%m%d%H%M').db"
rm -rf /usr/xbow
mkdir /usr/xbow
mkdir /usr/xbow/tmp
if [ -f "EkoView-2.4.32.tar.gz" ]; then
echo "Installer available !";
cp EkoView-2.4.32.tar.gz /usr/xbow/tmp
else
wget https://unisense.ceastech.com/download/EkoView-2.4.32.tar.gz -P /usr/xbow/tmp
echo "EkoView download successful !";
fi
echo "";
}
InstallEkoView()
{
echo "Extracting files...";
tar zxf /usr/xbow/tmp/EkoView-2.4.32.tar.gz -C /usr/xbow
echo "Linking files...";
ln -sv /usr/xbow/xserve-2.4.32 /usr/xbow/xserve
ln -sv /usr/xbow/xserve/logs /usr/xbow/www/logs
ln -sv /usr/xbow/xserve/web /usr/xbow/www/web
ln -sv /usr/xbow/www/sys /usr/xbow/xserve-2.4.32/sys
ln -sv /usr/xbow/cgi-bin /usr/xbow/xserve-2.4.32/web/cgi-bin
ln -sv /usr/xbow/www/data /usr/xbow/xserve-2.4.32/web/data
ln -sv /usr/xbow/www/images /usr/xbow/xserve-2.4.32/web/images
echo "Removing temp...";
rm -rf /usr/xbow/tmp
echo "EkoView Installed !";
echo "";
}
ConfigureApache()
{
service apache2 stop
echo "Apache service stopped gracefully !";
echo "";
echo "Configuring server...";
cp -v /usr/xbow/xserve-2.4.32/apache2/apache2.conf /etc/apache2
echo "Configuring ports...";
cp -v /usr/xbow/xserve-2.4.32/apache2/ports.conf /etc/apache2
echo "Configuring mods...";
cp -v /usr/xbow/xserve-2.4.32/apache2/deflate.conf /etc/apache2/mods-available
echo "Configuring sites...";
cp -v /usr/xbow/xserve-2.4.32/apache2/default /etc/apache2/sites-available
echo "Configuring environment...";
rm /etc/apache2/envvars
echo '# envvars - default environment variables for apache2ctl
# this wont be correct after changing uid
unset HOME
# for supporting multiple apache2 instances
if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
SUFFIX=
fi
# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=$CurrentUser
export APACHE_RUN_GROUP=$CurrentUser
export APACHE_PID_FILE=/var/run/apache2.pid
export APACHE_RUN_DIR=/var/run/apache2
export APACHE_LOCK_DIR=/var/lock/apache2
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
export APACHE_LOG_DIR=/var/log/apache2
## The locale used by some modules like mod_dav
export LANG=C
## Uncomment the following line to use the system default locale instead:
## /etc/default/locale
export LANG
## The command to get the status for "apache2ctl status".
## Some packages providing "www-browser" need "--dump" instead of "-dump".
#export APACHE_LYNX="www-browser -dump"
## If you need a higher file descriptor limit, uncomment and adjust the
## following line (default is 8192):
#APACHE_ULIMIT_MAX_FILES="ulimit -n 65536"' > /etc/apache2/envvars
chown -R $CurrentUser:$CurrentUser /var/lock/apache2
service apache2 start
echo "Apache server configuration done !";
echo "";
}
Permission()
{
echo "Changing permissions...";
chown -R $CurrentUser:$CurrentUser /usr/xbow
chmod -R 755 /usr/xbow
chmod 555 /usr/xbow/ChangeLog.txt
chmod 444 /usr/xbow/GatewayName.txt
chmod 644 /usr/xbow/apache/htpasswd
chmod 644 /usr/xbow/www/DisableGatewayBackup.txt
chmod 644 /usr/xbow/www/DisableGatewayDiagnostics.txt
chmod 700 /usr/xbow/www/sys
chmod 664 /usr/xbow/www/sys/basejoinmap.xtbl
chmod 664 /usr/xbow/www/sys/joinmap.xtbl
chmod 644 /usr/xbow/www/sys/xserve_sqlite.db
chmod 644 /usr/xbow/xserve-2.4.32/ChangeLog.txt
chmod 644 /usr/xbow/xserve-2.4.32/mathopd.properties
chmod 644 /usr/xbow/xserve-2.4.32/Version.txt
chmod 644 /usr/xbow/xserve-2.4.32/xparams.args
chmod 644 /usr/xbow/xserve-2.4.32/xparams.properties
chmod 644 /usr/xbow/xserve-2.4.32/apache2/*
chmod 711 /usr/xbow/xserve-2.4.32/bin/*
chmod 755 /usr/xbow/xserve-2.4.32/bin/sqlite3
chmod 700 /usr/xbow/xserve-2.4.32/configxml/eko
chmod 700 /usr/xbow/xserve-2.4.32/configxml/kits
chmod 700 /usr/xbow/xserve-2.4.32/configxml/sys
chmod 700 /usr/xbow/xserve-2.4.32/configxml/test
chmod 711 /usr/xbow/xserve-2.4.32/lib/commands/*
chmod 711 /usr/xbow/xserve-2.4.32/lib/datasinks/*
chmod 711 /usr/xbow/xserve-2.4.32/lib/parsers/*
chmod 664 /usr/xbow/xserve-2.4.32/logs/*
chmod -R 700 /usr/xbow/xserve-2.4.32/scripts/*
chmod 755 /usr/xbow/xserve-2.4.32/scripts/alert_sendmail.py
chmod 755 /usr/xbow/xserve-2.4.32/scripts/log2sim.pl
chmod 755 /usr/xbow/xserve-2.4.32/scripts/database/checkdb.pl
chmod 755 /usr/xbow/xserve-2.4.32/scripts/database/initdb.pl
chmod -R 755 /usr/xbow/xserve-2.4.32/scripts/netbook/auto
chmod -R 755 /usr/xbow/xserve-2.4.32/scripts/netbook/perl
chmod 644 /usr/xbow/xserve-2.4.32/scripts/netbook/gatewayBackup.pl
chmod 644 /usr/xbow/xserve-2.4.32/scripts/netbook/gatewayDiagnosticUpdate.py
chmod 644 /usr/xbow/xserve-2.4.32/scripts/netbook/gatewayUpdate.py
chmod 644 /usr/xbow/xserve-2.4.32/scripts/netbook/managedb
chmod 644 /usr/xbow/xserve-2.4.32/scripts/netbook/manageusr
chmod 644 /usr/xbow/xserve-2.4.32/scripts/netbook/serverwatch
chmod 755 /usr/xbow/xserve-2.4.32/scripts/netbook/xserve
chmod 700 /usr/xbow/xserve-2.4.32/scripts/netbook/xservewatch
chmod 755 /usr/xbow/xserve-2.4.32/scripts/nslu2/gatewayBackup.pl
chmod 755 /usr/xbow/xserve-2.4.32/scripts/nslu2/gatewayDiagnosticUpdate.py
chmod 755 /usr/xbow/xserve-2.4.32/scripts/nslu2/gatewayUpdate.py
chmod 755 /usr/xbow/xserve-2.4.32/scripts/nslu2/managedb
chmod 755 /usr/xbow/xserve-2.4.32/scripts/nslu2/manageusr
chmod 755 /usr/xbow/xserve-2.4.32/scripts/nslu2/serverwatch
chmod 755 /usr/xbow/xserve-2.4.32/scripts/nslu2/xserve
chmod 755 /usr/xbow/xserve-2.4.32/scripts/nslu2/xservewatch
chmod 755 /usr/xbow/xserve-2.4.32/scripts/upgrade/upgrade.pl
chmod 755 /usr/xbow/xserve-2.4.32/scripts/upgrade/*/*
chmod 755 /usr/xbow/xserve-2.4.32/scripts/vmware/*
echo "Permissions Granted !";
echo "";
}
CronTab()
{
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' gnome-schedule|grep "install ok installed")
echo "Checking for gnome-schedule: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No gnome-schedule. Setting up gnome-schedule..."
sudo apt-get -fyV install gnome-schedule
fi
echo "30 * * * * /usr/xbow/xserve/scripts/netbook/serverwatch
@reboot /usr/xbow/xserve/scripts/netbook/serverwatch
* * * * * /usr/xbow/xserve/scripts/netbook/xservewatch
*/30 * * * * /usr/xbow/xserve/scripts/netbook/xservewatchhour
*/5 * * * * php5 -f /usr/xbow/www/web/sync/Sync.php" > mycron
crontab mycron
rm mycron
echo "Cron job list...";
crontab -l
echo "XServe scheduling done !";
echo "";
}
AdditionalPackages()
{
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' sqlite|grep "install ok installed")
echo "Checking for sqlite: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No sqlite. Setting up sqlite..."
sudo apt-get -fyV install sqlite
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' php5-sqlite|grep "install ok installed")
echo "Checking for php5-sqlite: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No php5-sqlite. Setting up php5-sqlite..."
sudo apt-get -fyV install php5-sqlite
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' sqlitebrowser|grep "install ok installed")
echo "Checking for sqlitebrowser: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No sqlitebrowser. Setting up sqlitebrowser..."
sudo apt-get -fyV install sqlitebrowser
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' curl|grep "install ok installed")
echo "Checking for curl: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No curl. Setting up curl..."
sudo apt-get -fyV install curl
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libcurl3|grep "install ok installed")
echo "Checking for libcurl3: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No libcurl3. Setting up libcurl3..."
sudo apt-get -fyV install libcurl3
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libcurl4-openssl-dev|grep "install ok installed")
echo "Checking for libcurl4-openssl-dev: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No libcurl4-openssl-dev. Setting up libcurl4-openssl-dev..."
sudo apt-get -fyV install libcurl4-openssl-dev
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' php5-curl|grep "install ok installed")
echo "Checking for php5-curl: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No php5-curl. Setting up php5-curl..."
sudo apt-get -fyV install php5-curl
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' htop|grep "install ok installed")
echo "Checking for htop: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No htop. Setting up htop..."
sudo apt-get -fyV install htop
fi
}
Footer()
{
echo ""; echo "";
echo "*********************************************************************";
echo "+++ Hope you like this EkoView installer ****************************";
echo "+++ Contact Ericson (Developer) if found bugs in this application ***";
echo "+++ Center of Excellence for Advaned Sensor Technology (CEASTech) ***";
echo "+++ Universiti Malaysia Perlis (UniMAP) *****************************";
echo "*********************************************************************";
}
#######################
### Start Installer ###
#######################
RootCheck
CurrentUser=$(who am i | awk '{print $1}')
Welcome
Requirement
echo " This installer will remove previous database, files & folders !!!";
read -p " Do you want to continue ?" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "";
echo "*************************************************************************";
echo "";
echo "......................................";
echo "...Updating Ubuntu 12.04 LTS (Precise Pangolin)...";
echo "......................................";
SourceList
echo "......................................";
echo "...Installing server and components...";
echo "......................................";
ServerComponent
echo "...................................";
echo "...Downloading EkoView installer...";
echo "...................................";
DownloadEkoView
echo "........................";
echo "...Installing EkoView...";
echo "........................";
InstallEkoView
echo "........................";
echo "...Configuring Apache...";
echo "........................";
ConfigureApache
echo ".................................";
echo "...Setting EkoView permissions...";
echo ".................................";
Permission
echo "..........................";
echo "...Setting up scheduler...";
echo "..........................";
CronTab
echo "......................................................";
echo "...Setting up FireFox web browser and flash support...";
echo "......................................................";
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' adobe-flashplugin|grep "install ok installed")
echo "Checking for adobe-flashplugin: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No adobe-flashplugin. Setting up adobe-flashplugin..."
apturl apt:adobe-flashplugin?channel=$distropartner
fi
#echo 'user_pref("browser.search.defaulturl", "http://localhost/web/index.html");' >> ~/.mozilla/firefox/*.default/prefs.js;
echo "Firefox web browser setup done !";
echo "";
echo "...........................";
echo "...Installing TeamViewer...";
echo "...........................";
echo "Getting TeamViewer ready for remote access..."
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' teamviewer|grep "install ok installed")
echo "Checking for teamviewer: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No teamviewer. Setting up teamviewer..."
if [ -f teamviewer_i386.deb ]; then
echo "TeamViewer available !"
echo "Proceed to install Teamviever..."
dpkg -i teamviewer_i386.deb
else
echo "Downloading TeamViewer..."
wget http://download.teamviewer.com/download/teamviewer_i386.deb teamviewer_i386.deb
echo "Proceed to install Teamviever..."
dpkg -i teamviewer_i386.deb
fi
fi
echo "";
echo "....................................";
echo "...Installing additional packages...";
echo "....................................";
AdditionalPackages
else [[ ! $REPLY =~ ^[Yy]$ ]]
echo "";
echo "Installation was cancelled by user !";
fi
Footer
#######################
### End Installer ###
#######################