-
Notifications
You must be signed in to change notification settings - Fork 0
/
inst_deb12.sh
718 lines (557 loc) · 17.6 KB
/
inst_deb12.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
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
#!/bin/bash
RED='\033[0;31m'
LRED='\033[0;91m'
YELLOW='\033[0;33m'
GREEN='\033[0;32m'
NC='\033[0m'
function print_header () {
clear
echo ""
echo -e "${YELLOW} Welcome to the Debian 12 System installer!${NC}"
echo -e "${GREEN}"
echo " I need to ask you a few questions before starting the setup."
echo ""
}
function print_conf () {
clear
echo ""
echo -e "${YELLOW} Debian 12 System installer${NC}"
echo -e "${GREEN}"
echo " Your input is:"
echo ""
}
rpasswd=""
fqdn=""
print_header
until [ ${#rpasswd} -gt 11 ]; do
echo -en "${GREEN} Enter new root password [min. length is 12 char]: ${YELLOW} "
read -e -i "${rpasswd}" rpasswd
if [ ${#rpasswd} -lt 12 ]; then
print_header
echo -e "${LRED} Password has too few characters"
fi
done
print_header
echo -e "${GREEN} Enter new root password [min. length is 12 char]: ${YELLOW}${rpasswd}"
until [[ "$fqdn" =~ ^.*\..*\..*$ ]]; do
# print_header
# echo -e "${GREEN} Enter new root password [min. length is 12 char]: ${YELLOW}${rpasswd}"
echo -en "${GREEN} Enter a full qualified domain name: ${YELLOW} "
read -e -i "${fqdn}" fqdn
if [[ "$fqdn" =~ ^.*\..*\..*$ ]]; then
print_conf
echo -e "${GREEN} New root password: ${YELLOW}${rpasswd}"
echo -e "${GREEN} Full qualified domain name: ${YELLOW}${fqdn}"
else
print_header
echo -e "${GREEN} Enter new root password [min. length is 12 char]: ${YELLOW}${rpasswd}"
echo ""
echo -e "${LRED} The FQDN is not correct"
fi
done
echo -e "${NC}"
read -r -p " Ready to start installation [Y/n] ? " start_inst
if [[ "$start_inst" = "" ]]; then
start_inst="Y"
fi
if [[ "$start_inst" != [yY] ]]; then
clear
exit
fi
apt update
###################################
#### Install Debian 12
###################################
apt upgrade -y
apt install plocate sntp ntpdate software-properties-common curl nvme-cli smartmontools -y
timedatectl set-timezone Europe/Zurich
hostnamectl set-hostname $fqdn # set hostname
apt update
echo "root:${rpasswd}" | chpasswd # set root password -
###################################
#### Add gat (replacement for cat)
###################################
cd /usr/local/bin
wget https://github.com/koki-develop/gat/releases/download/v0.16.0/gat_Linux_x86_64.tar.gz
tar -xvzf gat_Linux_x86_64.tar.gz
chown root:root gat
chmod +x gat
rm gat_Linux_x86_64.tar.gz
rm LICENSE
rm README.md
###################################
#### Add joshuto (cli filemanager)
###################################
cd /usr/local/bin
wget https://github.com/kamiyaa/joshuto/releases/download/v0.9.6/joshuto-v0.9.6-x86_64-unknown-linux-gnu.tar.gz
tar -xvzf joshuto-v0.9.6-x86_64-unknown-linux-gnu.tar.gz
tar -vxzf joshuto-v0.9.6-x86_64-unknown-linux-gnu.tar.gz -C /usr/local/bin --strip-components=1
chown root:root joshuto
chmod +x joshuto
rm joshuto-v0.9.6-x86_64-unknown-linux-gnu.tar.gz
rm -R joshuto-v0.9.6-x86_64-unknown-linux-gnu
###################################
#### Build aliases file
###################################
cd /root
touch .bash_aliases
echo "alias jos='joshuto'" >> .bash_aliases
echo "alias gc='gat'" >> .bash_aliases
##############################
#### Install Virtualmin
##############################
apt install gpg-agent -y
#wget -O virtualmin-install.sh https://raw.githubusercontent.com/virtualmin/virtualmin-install/master/virtualmin-install.sh
wget -O virtualmin-install.sh https://software.virtualmin.com/gpl/scripts/virtualmin-install.sh
sh virtualmin-install.sh -y
rm virtualmin-install.sh
###########################################################################
###########################################################################
##############################
#### Disable Services ####
##############################
systemctl disable named
systemctl disable usermin
systemctl disable dovecot
systemctl disable proftpd
systemctl disable clamav-freshclam
systemctl disable clamav-daemon
systemctl disable postgrey
systemctl disable postfix
##############################
#### install new PHP versions
##############################
apt -y install lsb-release apt-transport-https ca-certificates
echo | curl -sSL https://packages.sury.org/apache2/README.txt | sudo bash -xe
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
apt update
apt upgrade -y
systemctl restart apache2
apt update
apt upgrade -y
apt install php7.4-bcmath php7.4-bz2 php7.4-cgi php7.4-curl php7.4-dba -y
apt install php7.4-gd php7.4-gmp php7.4-imap php7.4-fpm php7.4-json php7.4-xml php7.4-common -y
apt install php7.4-intl php7.4-ldap php7.4-mbstring php7.4-mysql php7.4-odbc php7.4-pspell -y
apt install php7.4-soap php7.4-sqlite3 php7.4-tidy php7.4-xmlrpc php7.4-xsl php7.4-zip php7.4-imagick php7.4-redis -y
apt install php8.0-bcmath php8.0-bz2 php8.0-cgi php8.0-curl php8.0-dba php8.0-fpm php8.0-gd -y
apt install php8.0-gmp php8.0-igbinary php8.0-imagick php8.0-imap php8.0-intl php8.0-ldap php8.0-mbstring -y
apt install php8.0-mysql php8.0-odbc php8.0-opcache php8.0-pspell php8.0-readline -y
apt install php8.0-redis php8.0-soap php8.0-sqlite3 php8.0-tidy php8.0-xml php8.0-xmlrpc php8.0-xsl php8.0-zip -y
apt install php8.1-bcmath php8.1-bz2 php8.1-cgi php8.1-curl php8.1-dba php8.1-fpm -y
apt install php8.1-gd php8.1-gmp php8.1-igbinary php8.1-imagick php8.1-imap php8.1-intl php8.1-ldap php8.1-mbstring -y
apt install php8.1-mysql php8.1-odbc php8.1-opcache php8.1-pspell php8.1-readline -y
apt install php8.1-redis php8.1-soap php8.1-sqlite3 php8.1-tidy php8.1-xml php8.1-xmlrpc php8.1-xsl php8.1-zip -y
apt install php8.2-bcmath php8.2-bz2 php8.2-cgi php8.2-curl php8.2-dba php8.2-fpm -y
apt install php8.2-gd php8.2-gmp php8.2-igbinary php8.2-imagick php8.2-imap php8.2-intl php8.2-ldap php8.2-mbstring -y
apt install php8.2-mysql php8.2-odbc php8.2-opcache php8.2-pspell php8.2-readline -y
apt install php8.2-redis php8.2-soap php8.2-sqlite3 php8.2-tidy php8.2-xml php8.2-xmlrpc php8.2-xsl php8.2-zip -y
apt install php8.3-bcmath php8.3-bz2 php8.3-cgi php8.3-curl php8.3-dba php8.3-fpm -y
apt install php8.3-gd php8.3-gmp php8.3-igbinary php8.3-imagick php8.3-imap php8.3-intl php8.3-ldap php8.3-mbstring -y
apt install php8.3-mysql php8.3-odbc php8.3-opcache php8.3-pspell php8.3-readline -y
apt install php8.3-redis php8.3-soap php8.3-sqlite3 php8.3-tidy php8.3-xml php8.3-xmlrpc php8.3-xsl php8.3-zip -y
##############################
#### Change php.ini parameters
##############################
cat >> /etc/php/7.4/fpm/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
EOF
cat >> /etc/php/7.4/cgi/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
EOF
cat >> /etc/php/7.4/cli/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
EOF
cat >> /etc/php/8.0/fpm/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
EOF
cat >> /etc/php/8.0/cgi/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
EOF
cat >> /etc/php/8.0/cli/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
EOF
cat >> /etc/php/8.1/fpm/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
EOF
cat >> /etc/php/8.1/cgi/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
EOF
cat >> /etc/php/8.1/cli/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
EOF
cat >> /etc/php/8.2/fpm/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
EOF
cat >> /etc/php/8.2/cgi/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
EOF
cat >> /etc/php/8.2/cli/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
EOF
cat >> /etc/php/8.3/cgi/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
EOF
cat >> /etc/php/8.3/cli/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
EOF
cat >> /etc/php/8.3/fpm/php.ini <<'EOF'
[PHP]
output_buffering = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 1024M
upload_max_filesize = 1024M
date.timezone = Europe/Zurich
max_input_vars = 10000
[Session]
session.gc_maxlifetime = 3600
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
EOF
#####################################
#### Enable additional Apache modules
#####################################
a2enmod http2
a2enmod headers
a2enmod expires
a2enmod include
a2enmod proxy_http2
##############################
#### Restart Apache / PHP-FPM
##############################
systemctl restart apache2
systemctl restart php7.4-fpm.service
systemctl restart php8.0-fpm.service
systemctl restart php8.1-fpm.service
systemctl restart php8.2-fpm.service
systemctl restart php8.3-fpm.service
######################################
#### install additional Python modules
######################################
apt install python3-venv -y
apt install python3-pip -y
apt install virtualenv -y
cd /root
##############################
#### Install Redis Server
##############################
apt update
apt install redis -y
#systemctl enable --now redis-server
#systemctl restart redis-server
cat >> /etc/sysctl.conf <<'EOF'
vm.overcommit_memory = 1
EOF
###################################
#### add config files to Virtualmin
###################################
cd /etc/webmin/virtual-server/plans
wget https://raw.githubusercontent.com/fdmgit/virtualmin/main/160880314564582
cd /etc/webmin/virtual-server/templates
wget https://raw.githubusercontent.com/fdmgit/virtualmin/main/server-level.tar.gz
tar -xvzf server-level.tar.gz
rm server-level.tar.gz
cd /root
###################################
#### add logo and styles
###################################
cat >> /root/inst_logo.sh <<'EOF'
wget https://raw.githubusercontent.com/fdmgit/virtualmin/main/logostyle.zip
unzip logostyle.zip
cp logo.png /etc/webmin/authentic-theme/
cp logo_welcome.png /etc/webmin/authentic-theme/
cp styles.css /etc/webmin/authentic-theme/
rm logo.png
rm logo_welcome.png
rm styles.css
rm logostyle.zip
rm inst_logo.sh
EOF
chmod +x inst_logo.sh
cd /root
: <<'END'
wget https://raw.githubusercontent.com/fdmgit/virtualmin/main/settings.js
wget https://raw.githubusercontent.com/fdmgit/virtualmin/main/settings-root.js
cp settings.js /etc/webmin/authentic-theme/
cp settings-root.js /etc/webmin/authentic-theme/
###################################
#### left menu html
###################################
all_ip_addresses="$(hostname -I)";
ip_address_array=($all_ip_addresses);
local_host="$(hostname -s)";
local_host=${local_host^^};
leftmenu_user_html="<br /><kb><b><span style='font-size:20px;color:gold;'>""$local_host""</span></b></kb><br /><kb><span style='font-size:16px;color:gold;'>IP4: ""${ip_address_array[0]}""</span></kb><br /><kb><span style='font-size:16px;color:gold;'>IP6: ""${ip_address_array[1]}""</span></kb>";
leftmenu_user_html="settings_leftmenu_user_html='""$leftmenu_user_html""';";
sed -i "s|settings_leftmenu_user_html='';|$leftmenu_user_html|g" /etc/webmin/authentic-theme/settings.js
sed -i "s|settings_leftmenu_user_html='';|$leftmenu_user_html|g" /etc/webmin/authentic-theme/settings-root.js
cd /root
END
###################################
#### new fail2ban and jail
###################################
cd /root
wget -O fail2ban_newest.deb https://github.com/fail2ban/fail2ban/releases/download/1.1.0/fail2ban_1.1.0-1.upstream1_all.deb
dpkg -i --force-confnew fail2ban_newest.deb
rm fail2ban_newest.deb
wget https://raw.githubusercontent.com/fdmgit/install-debian-12/main/jail-deb12.local
cd /etc/fail2ban
mv jail.local jail.local.orig
#cp /root/jail-deb12.local jail.local
rm /root/jail-deb12.local
touch /var/log/auth.log
cd /root
###################################
#### install password generator
###################################
apt install pwgen -y
#################################
#### Install Midnight Commander
#################################
cd /usr/share/keyrings
wget https://raw.githubusercontent.com/fdmgit/install-debian-12/main/tataranovich-keyring.gpg
echo "# Repository for Midnight Commander" > /etc/apt/sources.list.d/mc.list
echo "deb [signed-by=/usr/share/keyrings/tataranovich-keyring.gpg] http://www.tataranovich.com/debian bookworm main" >> /etc/apt/sources.list.d/mc.list
apt update
apt install mc -y
##############################
#### Update programs
##############################
apt update
apt upgrade -y
##############################
#### Update locate DB
##############################
updatedb
apt autoremove -y # clean installed apps
cd /root
rm instp1n.sh
rm instp2.sh
rm li_files.sh
rm -R .spamassassin
######################################
#### Install smartmontools & nvme-cli
######################################
cd /root
wget https://raw.githubusercontent.com/fdmgit/install-debian-12/main/smartmontools_7.4-2~bpo12+1_amd64.deb
dpkg -i smartmontools_7.4-2~bpo12+1_amd64.deb
rm smartmontools_7.4-2~bpo12+1_amd64.deb
apt install nvme-cli -y
######################################
#### Copy .bash_aliases to skel
######################################
cd /root
cp .bash_aliases /etc/skel/.bash_aliases
##############################
#### Install new Linux Kernel
##############################
apt install linux-image-6.6.13+bpo-amd64 -y
apt install linux-headers-6.6.13+bpo-amd64 -y
##################################
#### Install MariaDB Repository
##################################
curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'
cd /etc/apt/sources.list.d
touch mariadb.list
cat >> /etc/apt/sources.list.d/mariadb.list <<'EOF'
# deb.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# deb [signed-by=/etc/apt/keyrings/mariadb-keyring.pgp] https://deb.mariadb.org/10.11/debian bookworm main
deb [signed-by=/etc/apt/keyrings/mariadb-keyring.pgp] https://mirror.mva-n.net/mariadb/repo/10.11/debian bookworm main
# deb-src [signed-by=/etc/apt/keyrings/mariadb-keyring.pgp] https://mirror.mva-n.net/mariadb/repo/10.11/debian bookworm main
EOF
apt update
apt upgrade -y
cd /etc/mysql/mariadb.conf.d
ls provider*.cnf | xargs -I{} mv {} {}.orig
apt autoremove -y
cd /root
rm inst_deb12.sh
reboot