-
Notifications
You must be signed in to change notification settings - Fork 0
/
inst_deb12_n.sh
1024 lines (775 loc) · 26 KB
/
inst_deb12_n.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
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
##################################################
# Var / Const Definition #
##################################################
okinput=true
NC=$(echo -en '\001\033[0m\002')
RED=$(echo -en '\001\033[00;31m\002')
GREEN=$(echo -en '\001\033[00;32m\002')
YELLOW=$(echo -en '\001\033[00;33m\002')
BLUE=$(echo -en '\001\033[00;34m\002')
MAGENTA=$(echo -en '\001\033[00;35m\002')
PURPLE=$(echo -en '\001\033[00;35m\002')
CYAN=$(echo -en '\001\033[00;36m\002')
WHITE=$(echo -en '\001\033[01;37m\002')
LIGHTGRAY=$(echo -en '\001\033[00;37m\002')
LRED=$(echo -en '\001\033[01;31m\002')
LGREEN=$(echo -en '\001\033[01;32m\002')
LYELLOW=$(echo -en '\001\033[01;33m\002')
LBLUE=$(echo -en '\001\033[01;34m\002')
LMAGENTA=$(echo -en '\001\033[01;35m\002')
LPURPLE=$(echo -en '\001\033[01;35m\002')
LCYAN=$(echo -en '\001\033[01;36m\002')
##################################################
# Functions #
##################################################
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 ""
}
function pre_inst_ssh () {
cd /root
wget https://raw.githubusercontent.com/fdmgit/install-debian-12/main/bashrc.ini
cp bashrc.ini /root/.bashrc
cp bashrc.ini /etc/skel/.bashrc
rm /root/bashrc.ini
echo "deb http://deb.debian.org/debian/ bookworm-backports main" | tee -a /etc/apt/sources.list
###################################
#### enable mouse support form nano
###################################
sed -i "s|# set mouse|set mouse|g" /etc/nanorc
###################################
#### change file limit for root
###################################
sed -i "s|# End of file||g" /etc/security/limits.conf
echo "root soft nofile 131072" >> /etc/security/limits.conf
echo " " >> /etc/security/limits.conf
echo "# End of file" >> /etc/security/limits.conf
###################################
#### Setup root key file
###################################
if [ -d /root/.ssh ]; then
echo ".ssh exists"
else
mkdir /root/.ssh
fi
if [ -f /root/.ssh/authorized_keys ]; then
echo "file authorized_keys exists"
else
cd /root/.ssh
wget https://raw.githubusercontent.com/fdmgit/virtualmin/main/authorized_keys
fi
###################################
#### SSH Hardening
#### https://sshaudit.com
###################################
#### Re-generate the RSA and ED25519 keys
rm /etc/ssh/ssh_host_*
ssh-keygen -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -N ""
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ""
#### Remove small Diffie-Hellman moduli
awk '$5 >= 3071' /etc/ssh/moduli > /etc/ssh/moduli.safe
mv /etc/ssh/moduli.safe /etc/ssh/moduli
#### Restrict supported key exchange, cipher, and MAC algorithms
echo -e "# Restrict key exchange, cipher, and MAC algorithms, as per sshaudit.com\n# hardening guide.\n\nKexAlgorithms [email protected],curve25519-sha256,[email protected],gss-curve25519-sha256-,diffie-hellman-group16-sha512,gss-group16-sha512-,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha256\n\nCiphers [email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr\n\nMACs [email protected],[email protected],[email protected]\n\nHostKeyAlgorithms [email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,rsa-sha2-512,rsa-sha2-256\n\nRequiredRSASize 3072\n\nCASignatureAlgorithms [email protected],ssh-ed25519,rsa-sha2-512,rsa-sha2-256\n\nGSSAPIKexAlgorithms gss-curve25519-sha256-,gss-group16-sha512-\n\nHostbasedAcceptedAlgorithms [email protected],[email protected],[email protected],ssh-ed25519,[email protected],rsa-sha2-512,[email protected],rsa-sha2-256\n\nPubkeyAcceptedAlgorithms [email protected],[email protected],[email protected],ssh-ed25519,[email protected],rsa-sha2-512,[email protected],rsa-sha2-256\n\n" > /etc/ssh/sshd_config.d/ssh-audit_hardening.conf
sed -i "s|\#Port 22|Port 49153|g" /etc/ssh/sshd_config
sed -i "s|\#LoginGraceTime 2m|LoginGraceTime 1m|g" /etc/ssh/sshd_config
sed -i "s|PermitRootLogin without-password|PermitRootLogin prohibit-password|g" /etc/ssh/sshd_config
sed -i "s|\#MaxAuthTries 6|MaxAuthTries 4|g" /etc/ssh/sshd_config
sed -i "s|X11Forwarding yes|X11Forwarding no|g" /etc/ssh/sshd_config
sed -i "s|session required pam_env.so user_readenv=1 envfile=/etc/default/locale|session required pam_env.so envfile=/etc/default/locale|g" /etc/pam.d/sshd
systemctl restart sshd
sleep 5
}
function closing_msg () {
# Closing message
host_name=$(hostname | awk '{print $1}')
echo ""
echo -e "${YELLOW}ATTENTION\\n"
echo -e "${GREEN}The port for SSH has changed. To login use the following comand:\\n"
echo -e "${CYAN} ssh root@${host_name} -p 49153${NC}\\n"
echo ""
echo -e "${GREEN} Webmin page is reachable by entering:\\n"
echo -e "${CYAN} https://${host_name}:10000"
echo -e "${NC}\\n"
echo -e "End Time:" `date +"%d.%m.%Y %T"`
echo ""
echo ""
}
function inst_logo_styles () {
###################################
#### add logo and styles
###################################
cd /root
cat >> /root/inst_logo_styles.sh <<'EOF'
wget https://raw.githubusercontent.com/fdmgit/install-debian-12/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_styles.sh
EOF
chmod +x /root/inst_logo_styles.sh
}
function inst_virtualmin_config () {
###################################
#### 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
}
function inst_redis () {
##############################
#### 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
}
function inst_add_python () {
######################################
#### install additional Python modules
######################################
apt install python3-full -y
apt install python3-venv -y
apt install python3-pip -y
apt install virtualenv -y
}
function inst_f2b () {
###################################
#### 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
git clone https://github.com/fail2ban/fail2ban.git
cd fail2ban
python3 setup.py install
cd /root
rm -r /root/fail2ban
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
cp -av /usr/local/bin/fail2ban-* /usr/bin/
rm /usr/local/bin/fail2ban-*
}
function inst_pwgen () {
###################################
#### install password generator
###################################
apt install pwgen -y
}
function inst_mc () {
#################################
#### 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
}
function inst_smart_nvme () {
######################################
#### 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
}
function inst_mariadb () {
##################################
#### 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
cd /etc/mysql/mariadb.conf.d
apt update
echo "N" | apt upgrade -y
ls provider*.cnf | xargs -I{} mv {} {}.orig
apt autoremove -y
}
function inst_kernel () {
##############################
#### Install new Linux Kernel
##############################
apt install linux-image-6.11.5+bpo-amd64 -y
apt install linux-headers-6.11.5+bpo-amd64 -y
}
function inst_sury_repo () {
##############################
#### 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
}
function inst_php74 () {
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
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
}
function inst_php80 () {
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
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
}
function inst_php81 () {
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
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
}
function inst_php82 () {
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
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
}
function inst_php83 () {
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
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
}
function enable_apache_mod () {
#####################################
#### Enable additional Apache modules
#####################################
a2enmod http2
a2enmod headers
a2enmod expires
a2enmod include
a2enmod proxy_http2
}
function dis_services () {
##############################
#### 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
}
function post_inst () {
##############################
#### Update locate DB
##############################
cd /root
touch .bash_aliases
echo "alias jos='joshuto'" >> .bash_aliases
echo "alias gc='gat'" >> .bash_aliases
cp .bash_aliases /etc/skel/.bash_aliases
rm -R .spamassassin
rm inst_deb12_n.sh
apt update
apt upgrade -y
updatedb
}
function inst_virtualmin () {
##############################
#### Install Virtualmin
##############################
apt install gpg-agent -y
cd /root
#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
}
function inst_gat () {
###################################
#### Add gat (replacement for cat)
###################################
cd /usr/local/bin
wget https://github.com/koki-develop/gat/releases/download/v0.19.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
}
function inst_jos () {
###################################
#### Add joshuto (cli filemanager)
###################################
cd /usr/local/bin
wget https://github.com/kamiyaa/joshuto/releases/download/v0.9.8/joshuto-v0.9.8-x86_64-unknown-linux-musl.tar.gz
tar -vxzf joshuto-v0.9.8-x86_64-unknown-linux-musl.tar.gz -C /usr/local/bin --strip-components=1
chown root:root joshuto
rm joshuto-v0.9.8-x86_64-unknown-linux-musl.tar.gz
}
function inst_base () {
###################################
#### Install Debian 12 Base
###################################
apt update
apt upgrade -y
apt install plocate sntp ntpdate software-properties-common curl -y
timedatectl set-timezone Europe/Zurich
hostnamectl set-hostname $fqdn # set hostname
echo "root:${rpasswd}" | chpasswd # set root password -
}
function enh_nft () {
###################################
#### add some NFT tools
###################################
apt install netfilter-persistent -y
mkdir /etc/nftables
cat >> /etc/nftables/customnft.nft <<'EOF'
table inet blockedip {
chain input {
type filter hook ingress device "eth_device" priority filter; policy accept;
}
}
table inet allowedip {
chain input {
type filter hook ingress device "eth_device" priority filter; policy accept;
}
}
table ip rejectip {
chain input {
type filter hook input priority filter; policy accept;
# INSERT BELOW
}
}
EOF
eth_device='device "'$(ip -o -4 route show to default | awk '{print $5}')'"'
sed -i "s|device \"eth_device\"|$eth_device|g" /etc/nftables/customnft.nft
cat >> /etc/systemd/system/customnft.service <<'EOF'
[Unit]
Description=Custom NFTABLES Service
After=network.target firewalld.service nftables.service fail2ban.service
[Service]
Type=simple
ExecStart=/usr/sbin/nft -f /etc/nftables/customnft.nft
[Install]
WantedBy=multi-user.target
EOF
systemctl enable customnft.service
}
inst_bip () {
###################################
#### add some BIP tool
###################################
cat >> /usr/local/bin/bip <<'EOF'
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'
if [ -z "$1" ]
then
echo -e ""
echo -e "${RED} Missing input. Enter IP Addr || Subnet !${NC}"
echo -e "${RED} Usage: bip <ipaddr || ip subnet>${NC}"
echo -e ""
exit
else
BANIPADDR=$1
fi
IPDETECT=0
if [[ "$BANIPADDR" =~ ^([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ ]]; then
IPDETECT=1
fi
if [[ "$BANIPADDR" =~ ^([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])/([1-9]|[12][0-9]|3[0-2])$ ]]; then
IPDETECT=1
fi
if [ $IPDETECT -eq 0 ] ; then
clear
echo ""
echo ""
echo -e "${RED} The IP Address or Subnet ${YELLOW}${BANIPADDR}${RED} is wrong. Enter IP address / subnet again${NC}"
echo ""
echo ""
exit
fi
sed -i "/^# INSERT BELOW/a \ \t\tip saddr $BANIPADDR counter packets 0 bytes 0 reject" /etc/nftables/customnft.nft
nft insert rule ip rejectip input ip saddr $BANIPADDR counter packets 0 bytes 0 reject
echo -e ""
echo -e "${GREEN} IP Addr || subnet blocked permanently${NC}"
echo -e ""
EOF
chmod +x /usr/local/bin/bip
}
function inst_motd () {
cd /root
echo "" > /etc/motd
apt install figlet -y
apt install boxes -y
apt install lolcat -y
cp /usr/games/lolcat /usr/local/bin/
cat >> /etc/update-motd.d/10-header <<'EOF'
#!/bin/bash
hname=$(hostname | awk '{print $1}')
hname=$(echo $hname | cut -d"." -f 1)
echo -e " "
echo -e " "
figlet -ck $hname | lolcat -f | boxes -d boy
echo ""
EOF
chmod +x /etc/update-motd.d/10-header
}
##################################################
# Start Installation #
##################################################
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
###########################################################################
###########################################################################
pre_inst_ssh # function
inst_base # function
inst_smart_nvme # function
inst_gat # function
inst_jos # function
inst_virtualmin # function
inst_add_python # function
dis_services # function