forked from SmarthomeIndia/EDOMI-LTS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
500 lines (432 loc) · 17.7 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
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
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
#!/bin/sh
# -----------------------------------------------------------------------------------------------------------------------------------------
#
#
# -----------------------------------------------------------------------------------------------------------------------------------------
#
# 1. USB-Stick mounten:
# mkdir /mnt/usb
# mount -t vfat /dev/sdb1 /mnt/usb (Devicename sdb1 ggf. anpassen)
#
# 2. Installation starten:
# /mnt/usb/edomi/install.sh
# Hinweis: u.U. ist das Script zunächst ausführbar zu machen mit: chmod 777 /mnt/usb/edomi/install.sh
#
# 3. nach Abschluss der Installation ggf. den USB-Stick auswerfen:
# umount /mnt/usb
#
# -----------------------------------------------------------------------------------------------------------------------------------------
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SERVERIP="$(hostname -I | cut -d' ' -f1)"
MAIN_PATH="/usr/local/edomi"
CENTOSVERSION=$(rpm -qa \*-release | grep -Ei "oracle|redhat|centos" | cut -d"-" -f3)
install_onCentos65 () {
echo -e "\033[32m"
echo ">>> EDOMI und Systemdienste für CentOS 6.5 installieren... (Quelle: Lokal)"
echo -e "\033[39m"
sleep 3
# -------------------------------
echo -e "\033[32m>>> Packete installieren\033[39m"
rpm -Uvh centos65/rpm/*.rpm
# -------------------------------
echo -e "\033[32m>>> SELinux deaktivieren\033[39m"
cp centos65/config/config /etc/selinux/
# -------------------------------
echo -e "\033[32m>>> Apache konfigurieren\033[39m"
cp centos65/config/welcome.conf /etc/httpd/conf.d/
cp centos65/config/httpd.conf /etc/httpd/conf/
sed -i -e "s#===INSTALL-HTTP-ROOT===#$MAIN_PATH/www#g" /etc/httpd/conf/httpd.conf
sed -i -e "s#===INSTALL-SERVERIP===#$SERVERIP#g" /etc/httpd/conf/httpd.conf
chkconfig --add httpd
chkconfig --level 235 httpd on
# -------------------------------
echo -e "\033[32m>>> PHP konfigurieren\033[39m"
cp centos65/config/php.conf /etc/httpd/conf.d/
cp centos65/config/php.ini /etc/
# -------------------------------
echo -e "\033[32m>>> mySQL konfigurieren\033[39m"
cp centos65/config/my.cnf /etc/
chkconfig --add mysqld
chkconfig --level 235 mysqld on
service mysqld start
# Passwort setzen (leer), diverses
/usr/bin/mysqladmin -u root password ""
mysql -e "DROP DATABASE test;"
mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'"
mysql -e "FLUSH PRIVILEGES;"
# Remote-Access aktivieren
mysql -e "GRANT ALL ON *.* TO mysql@'%';"
# -------------------------------
echo -e "\033[32m>>> FTP konfigurieren\033[39m"
cp centos65/config/vsftpd.conf /etc/vsftpd/
rm -f /etc/vsftpd/ftpusers
rm -f /etc/vsftpd/user_list
chkconfig --add vsftpd
chkconfig --level 235 vsftpd on
service vsftpd start
# -------------------------------
echo -e "\033[32m>>> Dienste konfigurieren\033[39m"
# NTP
chkconfig --add ntpd
chkconfig --level 235 ntpd on
# Diverses
chkconfig --level 123456 crond off
chkconfig crond --del
chkconfig --level 123456 postfix off
chkconfig postfix --del
chkconfig --level 123456 blk-availability off
chkconfig blk-availability --del
chkconfig --level 123456 lvm2-monitor off
chkconfig lvm2-monitor --del
chkconfig --level 123456 mdmonitor off
chkconfig mdmonitor --del
chkconfig --level 123456 multipathd off
chkconfig multipathd --del
chkconfig --level 123456 netconsole off
chkconfig netconsole --del
chkconfig --level 123456 rdisc off
chkconfig rdisc --del
chkconfig --level 123456 restorecond off
chkconfig restorecond --del
chkconfig --level 123456 saslauthd off
chkconfig saslauthd --del
chkconfig --level 123456 auditd off
chkconfig auditd --del
# Firewall IP4 ausschalten
service iptables save
service iptables stop
chkconfig --level 123456 iptables off
chkconfig iptables --del
# Firewall IP6 ausschalten
service ip6tables save
service ip6tables stop
chkconfig --level 123456 ip6tables off
chkconfig ip6tables --del
# System-Logging ausschalten
service rsyslog stop
chkconfig rsyslog off
chkconfig rsyslog --del
# -------------------------------
echo -e "\033[32m>>> Bootvorgang konfigurieren\033[39m"
sed -i -e '/timeout=/ s/=.*/=1/' /boot/grub/grub.conf
sed -i -e 's/quiet//g' /boot/grub/grub.conf
sed -i -e 's/rhgb//g' /boot/grub/grub.conf
# boot.log löschen
chmod 777 /var/log/boot.log
rm -f /var/log/boot.log
# -------------------------------
install_edomi
# -------------------------------
echo -e "\033[32m"
echo "Autostart konfigurieren"
echo -e "\033[39m"
echo "/bin/sh $MAIN_PATH/main/start.sh" >> /etc/rc.d/rc.local
# -------------------------------
show_splash
exit
}
install_onCentos7 () {
echo -e "\033[32m"
echo ">>> EDOMI und Systemdienste für CentOS 7 installieren... (Quelle: Lokal)"
echo -e "\033[39m"
sleep 3
# -------------------------------
echo -e "\033[32m>>> Firewall deaktivieren\033[39m"
systemctl stop firewalld
systemctl disable firewalld
# -------------------------------
echo -e "\033[32m>>> Packete installieren (Teil 1)\033[39m"
rpm -Uvh centos7x/rpm1/*.rpm
yum-config-manager --enable remi-php72
# -------------------------------
echo -e "\033[32m>>> Packete installieren (Teil 2)\033[39m"
rpm -Uvh centos7x/rpm2/*.rpm
# -------------------------------
echo -e "\033[32m>>> Dienste konfigurieren\033[39m"
systemctl enable ntpd
systemctl enable vsftpd
systemctl enable httpd
systemctl enable mariadb
systemctl disable postfix
# -------------------------------
echo -e "\033[32m>>> SELinux deaktivieren\033[39m"
sed -i -e '/SELINUX=/ s/=.*/=disabled/' /etc/selinux/config
# -------------------------------
echo -e "\033[32m>>> FTP konfigurieren\033[39m"
rm -f /etc/vsftpd/ftpusers
rm -f /etc/vsftpd/user_list
sed -i -e '/listen=/ s/=.*/=YES/' /etc/vsftpd/vsftpd.conf
sed -i -e '/listen_ipv6=/ s/=.*/=NO/' /etc/vsftpd/vsftpd.conf
sed -i -e '/userlist_enable=/ s/=.*/=NO/' /etc/vsftpd/vsftpd.conf
# -------------------------------
echo -e "\033[32m>>> Apache konfigurieren\033[39m"
sed -i -e "s/#ServerName www\.example\.com/ServerName $SERVERIP/" /etc/httpd/conf/httpd.conf
sed -i -e "s#DocumentRoot \"/var/www/html\"#DocumentRoot \"$MAIN_PATH/www\"#" /etc/httpd/conf/httpd.conf
sed -i -e "s#<Directory \"/var/www\">#<Directory \"$MAIN_PATH/www\">#" /etc/httpd/conf/httpd.conf
sed -i -e "s#<Directory \"/var/www/html\">#<Directory \"$MAIN_PATH/www\">#" /etc/httpd/conf/httpd.conf
# -------------------------------
echo -e "\033[32m>>> mySQL/MariaDB konfigurieren\033[39m"
systemctl start mariadb
/usr/bin/mysqladmin -u root password ""
mysql -e "DROP DATABASE test;"
mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'"
mysql -e "FLUSH PRIVILEGES;"
mysql -e "GRANT ALL ON *.* TO mysql@'%';"
echo "key_buffer_size=256M" > /tmp/tmp.txt
echo "sort_buffer_size=8M" >> /tmp/tmp.txt
echo "read_buffer_size=16M" >> /tmp/tmp.txt
echo "read_rnd_buffer_size=4M" >> /tmp/tmp.txt
echo "myisam_sort_buffer_size=4M" >> /tmp/tmp.txt
echo "join_buffer_size=4M" >> /tmp/tmp.txt
echo "query_cache_limit=8M" >> /tmp/tmp.txt
echo "query_cache_size=8M" >> /tmp/tmp.txt
echo "query_cache_type=1" >> /tmp/tmp.txt
echo "wait_timeout=28800" >> /tmp/tmp.txt
echo "interactive_timeout=28800" >> /tmp/tmp.txt
sed -i '/\[mysqld\]/r /tmp/tmp.txt' /etc/my.cnf
# mySQL-Symlink erstellen
echo "Alias=mysqld.service" > /tmp/tmp.txt
sed -i '/\[Install\]/r /tmp/tmp.txt' /usr/lib/systemd/system/mariadb.service
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/mysqld.service'
systemctl daemon-reload
# -------------------------------
echo -e "\033[32m>>> PHP konfigurieren\033[39m"
sed -i -e '/short_open_tag =/ s/=.*/= On/' /etc/php.ini
sed -i -e '/post_max_size =/ s/=.*/= 100M/' /etc/php.ini
sed -i -e '/upload_max_filesize =/ s/=.*/= 100M/' /etc/php.ini
sed -i -e '/max_file_uploads =/ s/=.*/= 1000/' /etc/php.ini
# -------------------------------
echo -e "\033[32m>>> Bootvorgang konfigurieren\033[39m"
sed -i -e '/GRUB_TIMEOUT=/ s/=.*/=1/' /etc/default/grub
sed -i -e 's/quiet//g' /etc/default/grub
sed -i -e 's/rhgb//g' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
# -------------------------------
install_edomi
# -------------------------------
echo -e "\033[32m>>> Autostart konfigurieren\033[39m"
echo "[Unit]" > /etc/systemd/system/edomi.service
echo "Description=EDOMI" >> /etc/systemd/system/edomi.service
echo "[email protected] [email protected] [email protected] [email protected] [email protected] [email protected]" >> /etc/systemd/system/edomi.service
echo "After=httpd.service mysqld.service network.target" >> /etc/systemd/system/edomi.service
echo "[email protected] [email protected] [email protected] [email protected] [email protected] [email protected]" >> /etc/systemd/system/edomi.service
echo "[Service]" >> /etc/systemd/system/edomi.service
echo "Type=simple" >> /etc/systemd/system/edomi.service
echo "ExecStart=/bin/sh /usr/local/edomi/main/start.sh" >> /etc/systemd/system/edomi.service
echo "TimeoutStartSec=0" >> /etc/systemd/system/edomi.service
echo "StandardInput=tty-force" >> /etc/systemd/system/edomi.service
echo "StandardOutput=inherit" >> /etc/systemd/system/edomi.service
echo "StandardError=inherit" >> /etc/systemd/system/edomi.service
echo "[Install]" >> /etc/systemd/system/edomi.service
echo "WantedBy=default.target" >> /etc/systemd/system/edomi.service
systemctl daemon-reload
systemctl enable edomi
# -------------------------------
show_splash
exit
}
install_onCentos7_download () {
echo -e "\033[32m"
echo ">>> EDOMI und Systemdienste für CentOS 7 installieren... (Quelle: Download)"
echo -e "\033[39m"
sleep 3
# -------------------------------
echo -e "\033[32m>>> Firewall deaktivieren\033[39m"
systemctl stop firewalld
systemctl disable firewalld
# -------------------------------
echo -e "\033[32m>>> Packete installieren\033[39m"
# NTP, nano und vsFTP installieren
yum -y install ntp
yum -y install nano
yum -y install vsftpd
# Apache installieren
yum -y install httpd
# mySQL/MariaDB installieren
yum -y install mariadb-server
# PHP 7.2 installieren
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils
yum-config-manager --enable remi-php72
yum -y install php
yum -y install php-mysql
yum -y install php-soap
# expect installieren
yum -y install expect
# -------------------------------
echo -e "\033[32m>>> Dienste konfigurieren\033[39m"
systemctl enable ntpd
systemctl enable vsftpd
systemctl enable httpd
systemctl enable mariadb
systemctl disable postfix
# -------------------------------
echo -e "\033[32m>>> SELinux deaktivieren\033[39m"
sed -i -e '/SELINUX=/ s/=.*/=disabled/' /etc/selinux/config
# -------------------------------
echo -e "\033[32m>>> FTP konfigurieren\033[39m"
rm -f /etc/vsftpd/ftpusers
rm -f /etc/vsftpd/user_list
sed -i -e '/listen=/ s/=.*/=YES/' /etc/vsftpd/vsftpd.conf
sed -i -e '/listen_ipv6=/ s/=.*/=NO/' /etc/vsftpd/vsftpd.conf
sed -i -e '/userlist_enable=/ s/=.*/=NO/' /etc/vsftpd/vsftpd.conf
# -------------------------------
echo -e "\033[32m>>> Apache konfigurieren\033[39m"
sed -i -e "s/#ServerName www\.example\.com/ServerName $SERVERIP/" /etc/httpd/conf/httpd.conf
sed -i -e "s#DocumentRoot \"/var/www/html\"#DocumentRoot \"$MAIN_PATH/www\"#" /etc/httpd/conf/httpd.conf
sed -i -e "s#<Directory \"/var/www\">#<Directory \"$MAIN_PATH/www\">#" /etc/httpd/conf/httpd.conf
sed -i -e "s#<Directory \"/var/www/html\">#<Directory \"$MAIN_PATH/www\">#" /etc/httpd/conf/httpd.conf
# -------------------------------
echo -e "\033[32m>>> mySQL/MariaDB konfigurieren\033[39m"
systemctl start mariadb
/usr/bin/mysqladmin -u root password ""
mysql -e "DROP DATABASE test;"
mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'"
mysql -e "FLUSH PRIVILEGES;"
mysql -e "GRANT ALL ON *.* TO mysql@'%';"
echo "key_buffer_size=256M" > /tmp/tmp.txt
echo "sort_buffer_size=8M" >> /tmp/tmp.txt
echo "read_buffer_size=16M" >> /tmp/tmp.txt
echo "read_rnd_buffer_size=4M" >> /tmp/tmp.txt
echo "myisam_sort_buffer_size=4M" >> /tmp/tmp.txt
echo "join_buffer_size=4M" >> /tmp/tmp.txt
echo "query_cache_limit=8M" >> /tmp/tmp.txt
echo "query_cache_size=8M" >> /tmp/tmp.txt
echo "query_cache_type=1" >> /tmp/tmp.txt
echo "wait_timeout=28800" >> /tmp/tmp.txt
echo "interactive_timeout=28800" >> /tmp/tmp.txt
sed -i '/\[mysqld\]/r /tmp/tmp.txt' /etc/my.cnf
# mySQL-Symlink erstellen
echo "Alias=mysqld.service" > /tmp/tmp.txt
sed -i '/\[Install\]/r /tmp/tmp.txt' /usr/lib/systemd/system/mariadb.service
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/mysqld.service'
systemctl daemon-reload
# -------------------------------
echo -e "\033[32m>>> PHP konfigurieren\033[39m"
sed -i -e '/short_open_tag =/ s/=.*/= On/' /etc/php.ini
sed -i -e '/post_max_size =/ s/=.*/= 100M/' /etc/php.ini
sed -i -e '/upload_max_filesize =/ s/=.*/= 100M/' /etc/php.ini
sed -i -e '/max_file_uploads =/ s/=.*/= 1000/' /etc/php.ini
# -------------------------------
echo -e "\033[32m>>> Bootvorgang konfigurieren\033[39m"
sed -i -e '/GRUB_TIMEOUT=/ s/=.*/=1/' /etc/default/grub
sed -i -e 's/quiet//g' /etc/default/grub
sed -i -e 's/rhgb//g' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
# -------------------------------
install_edomi
# -------------------------------
echo -e "\033[32m>>> Autostart konfigurieren\033[39m"
echo "[Unit]" > /etc/systemd/system/edomi.service
echo "Description=EDOMI" >> /etc/systemd/system/edomi.service
echo "[email protected] [email protected] [email protected] [email protected] [email protected] [email protected]" >> /etc/systemd/system/edomi.service
echo "After=httpd.service mysqld.service network.target" >> /etc/systemd/system/edomi.service
echo "[email protected] [email protected] [email protected] [email protected] [email protected] [email protected]" >> /etc/systemd/system/edomi.service
echo "[Service]" >> /etc/systemd/system/edomi.service
echo "Type=simple" >> /etc/systemd/system/edomi.service
echo "ExecStart=/bin/sh /usr/local/edomi/main/start.sh" >> /etc/systemd/system/edomi.service
echo "TimeoutStartSec=0" >> /etc/systemd/system/edomi.service
echo "StandardInput=tty-force" >> /etc/systemd/system/edomi.service
echo "StandardOutput=inherit" >> /etc/systemd/system/edomi.service
echo "StandardError=inherit" >> /etc/systemd/system/edomi.service
echo "[Install]" >> /etc/systemd/system/edomi.service
echo "WantedBy=default.target" >> /etc/systemd/system/edomi.service
systemctl daemon-reload
systemctl enable edomi
# -------------------------------
show_splash
exit
}
install_edomi () {
echo -e "\033[32m>>> EDOMI installieren\033[39m"
service mysqld stop
mkdir -p $MAIN_PATH
tar -xvf edomi.edomiinstall -C $MAIN_PATH
chmod 777 -R $MAIN_PATH
# edomi.ini anpassen
sed -i -e "s#global_serverIP.*#global_serverIP='$SERVERIP'#" $MAIN_PATH/edomi.ini
}
delete_edomi () {
echo -e "\033[32m>>> EDOMI-Installation löschen\033[39m"
service mysqld stop
rm -rf $MAIN_PATH
rm -rf /var/lib/mysql/edomi*
}
show_title () {
echo -e "\033[42m\033[30m \033[49m\033[39m"
echo -e "\033[42m\033[30m EDOMI - (c) Dr. Christian Gärtner \033[49m\033[39m"
echo -e "\033[42m\033[30m \033[49m\033[39m"
}
show_splash () {
show_title
echo -e "\033[32mDie EDOMI-Installation ist abgeschlossen.\033[39m"
echo -e "\033[32mBeim nächsten Systemstart wird EDOMI automatisch gestartet.\033[39m"
echo -e "\033[32mNeustart mit: reboot (ENTER)\033[39m"
echo ""
}
while : ; do
clear
show_title
echo ""
echo -e " IP-Adresse: \033[32m$SERVERIP\033[39m (wird zur Konfiguration verwendet)"
echo ""
echo "--------------------------------------------------------------------------------"
echo " 1 = EDOMI und Systemdienste für CentOS 6.5 installieren (Quelle: Lokal)"
echo " 2 = EDOMI und Systemdienste für CentOS 7.x installieren (Quelle: Lokal)"
echo " 3 = EDOMI und Systemdienste für CentOS 7.x installieren (Quelle: Download)"
echo ""
echo " e = nur EDOMI installieren (eine vorhandene Installation wird überschrieben!)"
echo " x = Beenden"
echo "--------------------------------------------------------------------------------"
read MENUOPTION
if [ "$MENUOPTION" == "1" ]; then
if [ "$CENTOSVERSION" == "6" ]; then
install_onCentos65
else
echo "Das installierte CentOS scheint Version $CENTOSVERSION zu sein!"
echo "Sollen dennoch die Systemdienste für CentOS 6.5 installiert werden (j/n)?"
read CONFIRM
if [ "$CONFIRM" == "j" ]; then
install_onCentos65
fi
fi
fi
if [ "$MENUOPTION" == "2" ]; then
if [ "$CENTOSVERSION" == "7" ]; then
install_onCentos7
else
echo "Das installierte CentOS scheint Version $CENTOSVERSION zu sein!"
echo "Sollen dennoch die Systemdienste für CentOS 7.x installiert werden (j/n)?"
read CONFIRM
if [ "$CONFIRM" == "j" ]; then
install_onCentos7
fi
fi
fi
if [ "$MENUOPTION" == "3" ]; then
if [ "$CENTOSVERSION" == "7" ]; then
install_onCentos7_download
else
echo "Das installierte CentOS scheint Version $CENTOSVERSION zu sein!"
echo "Sollen dennoch die Systemdienste für CentOS 7.x installiert werden (j/n)?"
read CONFIRM
if [ "$CONFIRM" == "j" ]; then
install_onCentos7_download
fi
fi
fi
if [ "$MENUOPTION" == "e" ]; then
echo -e "\033[32m"
echo ">>> nur EDOMI installieren..."
echo -e "\033[39m"
sleep 3
delete_edomi
install_edomi
show_splash
exit
fi
if [ "$MENUOPTION" == "x" ]; then
exit
fi
done