-
Notifications
You must be signed in to change notification settings - Fork 2
/
installer-debian.sh
816 lines (697 loc) · 26.2 KB
/
installer-debian.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
#!/bin/bash
#################################################### CONFIGURATION ###
BUILD=202112181
PASS=$(openssl rand -base64 32|sha256sum|base64|head -c 32| tr '[:upper:]' '[:lower:]')
DBPASS=$(openssl rand -base64 24|sha256sum|base64|head -c 32| tr '[:upper:]' '[:lower:]')
SERVERID=$(openssl rand -base64 12|sha256sum|base64|head -c 32| tr '[:upper:]' '[:lower:]')
REPO=ATSiCorp/LinkPanel
if [ -z "$1" ];
BRANCH=main
then
BRANCH=$1
fi
#################################################### CLI TOOLS ###
reset=$(tput sgr0)
bold=$(tput bold)
underline=$(tput smul)
black=$(tput setaf 0)
white=$(tput setaf 7)
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
blue=$(tput setaf 4)
purple=$(tput setaf 5)
bgblack=$(tput setab 0)
bgwhite=$(tput setab 7)
bgred=$(tput setab 1)
bggreen=$(tput setab 2)
bgyellow=$(tput setab 4)
bgblue=$(tput setab 4)
bgpurple=$(tput setab 5)
#################################################### LINKPANEL SETUP ######
# LOGO
clear
echo "${green}${bold}"
echo "=================================================================="
echo " █ █ ██████ █ █ ████ █ █████ █████ █ "
echo " █ █ █ █ █ █ █ █ ███ █ █ █ █ "
echo " █ █ █ █ ██ █ █ █ █ █ █ ███ █ "
echo " █ █ █ █ █ █ ████ ███████ █ █ █ █ "
echo " ██████ █ █ █ █ █ █ █ █ █ █ █████ █████ "
echo " Debian Version BY ATSi Corporation"
echo "=================================================================="
echo "Installation has been started... on 20 sec, Hold on!"
echo "This script automatically takes care of all the installation tasks"
echo "so sit back and get some coffee ready to relax."
echo "${reset}"
sleep 20s
# Ubuntu Operating System CHECK
clear
clear
echo "${bggreen}${black}${bold}"
echo "Operating System Compatibility Check...!"
echo "${reset}"
sleep 10s
CODENAME=lsb_release -cs
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
VERSION=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"')
if [ "$ID" = "debian" ]; then
case $VERSION in
10 | 11 | 12)
break
;;
*)
echo "${bgred}${white}${bold}"
echo "LinkPanel requires Linux Ubuntu 24.04-22.04 LTS Only"
echo "${reset}"
exit 1;
break
;;
esac
else
echo "${bgred}${white}${bold}"
echo "LinkPanel requires Linux Ubuntu 20.04-22.04 LTS Only"
echo "${reset}"
exit 1
fi
# ROOT CHECK
clear
clear
echo "${bggreen}${black}${bold}"
echo "Permission check..."
echo "${reset}"
sleep 5s
if [ "$(id -u)" = "0" ]; then
clear
else
clear
echo "${bgred}${white}${bold}"
echo "You have to run LinkPanel as root. (In VPS or Local Server use '-s')"
sleep 20s
echo "${reset}"
exit 1
fi
# BASIC SETUP
clear
clear
echo "${bggreen}${black}${bold}"
echo "OS Base setup also check Update - Upgrade - Install software for LinkPanel requirement..."
echo "${reset}"
sleep 15s
sudo echo "\$nrconf{restart} = 'a';" >> /etc/needrestart/needrestart.conf
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade
# Add Ondrej's repo source and signing key along with dependencies
sudo apt install apt-transport-https
sudo curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
sudo DEBIAN_FRONTEND=noninteractive apt-get install software-properties-common -y
sudo DEBIAN_FRONTEND=noninteractive apt-get install net-tools curl wget nano micro vim neofetch -y
sudo DEBIAN_FRONTEND=noninteractive apt-get install rpl sed zip unzip openssl expect dirmngr lsb-release -y
sudo DEBIAN_FRONTEND=noninteractive apt-get install ca-certificates dnsutils dos2unix zsh htop ffmpeg -y
sudo apt update
# GET IP
clear
clear
echo "${bggreen}${black}${bold}"
echo "Getting this machine public IP not local IP..."
echo "${reset}"
sleep 5s
IP=$(curl -s https://checkip.amazonaws.com)
echo "Your Public IP: $IP"
sleep 10s
# MOTD WELCOME MESSAGE
clear
echo "${bggreen}${black}${bold}"
echo "Motd settings..."
echo "${reset}"
sleep 10s
WELCOME=/etc/motd
sudo touch $WELCOME
sudo cat > "$WELCOME" <<EOF
█ █ ██████ █ █ ████ █ █████ █████ █
█ █ █ █ █ █ █ █ ███ █ █ █ █
█ █ █ █ ██ █ █ █ █ █ █ ███ █
█ █ █ █ █ █ ████ ███████ █ █ █ █
██████ █ █ █ █ █ █ █ █ █ █ █████ █████
=======================================================
Simple Lightweight Functional For Small Server
LinkPanel Build BY ATSi Corporation
=======================================================
EOF
sleep 15s
# SWAP
clear
echo "${bggreen}${black}${bold}"
echo "LinkPanel will set Memory SWAP to 2GB..."
sleep 5s
sudo /bin/dd if=/dev/zero of=/var/swap.LinkPanel2GB bs=2M count=2024
sudo /sbin/mkswap /var/swap.LinkPanel2GB
sudo /sbin/swapon /var/swap.LinkPanel2GB
free -h
echo "${reset}"
sleep 15s
# ALIAS
clear
echo "${bggreen}${black}${bold}"
echo "Custom CLI configuration..."
echo "${reset}"
sleep 10s
shopt -s expand_aliases
alias ll='ls -alF'
# LINKPANEL DIRS
clear
echo "${bggreen}${black}${bold}"
echo "Configure LinkPanel directories..."
echo "${reset}"
sleep 10s
sudo mkdir /etc/linkpanel/
sudo chmod o-r /etc/linkpanel
sudo mkdir /var/linkpanel/
sudo chmod o-r /var/linkpanel
# USER
clear
echo "${bggreen}${black}${bold}"
echo "Set LinkPanel root user..."
echo "${reset}"
sleep 10s
sudo pam-auth-update --package
sudo mount -o remount,rw /
sudo chmod 640 /etc/shadow
sudo useradd -m -s /bin/bash linkpanel
echo "linkpanel:$PASS"|chpasswd
sudo usermod -aG linkpanel
# NGINX
clear
echo "${bggreen}${black}${bold}"
echo "Nginx setup..."
echo "${reset}"
sleep 5s
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install nginx.core
sudo systemctl start nginx.service
sudo rpl -i -w "http {" "http { limit_req_zone \$binary_remote_addr zone=one:10m rate=1r/s; fastcgi_read_timeout 300;" /etc/nginx/nginx.conf
sudo rpl -i -w "http {" "http { limit_req_zone \$binary_remote_addr zone=one:10m rate=1r/s; fastcgi_read_timeout 300;" /etc/nginx/nginx.conf
sudo systemctl enable nginx.service
sudo systemctl status nginx.service
sleep 10s
# FIREWALL
clear
echo "${bggreen}${black}${bold}"
echo "Fail2ban Firewall setup..."
echo "${reset}"
sleep 5s
apt-get -y install fail2ban
JAIL=/etc/fail2ban/jail.local
sudo unlink JAIL
sudo touch $JAIL
sudo cat > "$JAIL" <<EOF
[DEFAULT]
bantime = 3600
banaction = iptables-multiport
[sshd]
enabled = true
logpath = /var/log/auth.log
EOF
systemctl restart fail2ban
sudo ufw --force enable
sudo ufw allow ssh
sudo ufw allow 22/tcp
sudo ufw allow 22/udp
sudo ufw allow http
sudo ufw allow https
sudo ufw allow "Nginx Full"
# PHP
clear
echo "${bggreen}${black}${bold}"
echo "PHP setup (This may take some time for install and configure)"
echo "${reset}"
sleep 15s
apt-get update
sleep 10s
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-fpm
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-common
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-curl
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-openssl
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-bcmath
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-mbstring
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-tokenizer
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-mysql
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-sqlite3
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-pgsql
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-redis
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-memcached
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-json
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-zip
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-xml
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-soap
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-gd
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-imagick
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-fileinfo
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-imap
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.4-cli
PHPINI=/etc/php/7.4/fpm/conf.d/linkpanel.ini
sudo touch $PHPINI
sudo cat > "$PHPINI" <<EOF
memory_limit = 256M
upload_max_filesize = 256M
post_max_size = 256M
max_execution_time = 1999
max_input_time = 1999
EOF
service php7.4-fpm restart
sleep 10s
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-fpm
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-common
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-curl
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-openssl
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-bcmath
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-mbstring
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-tokenizer
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-mysql
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-sqlite3
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-pgsql
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-redis
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-memcached
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-json
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-zip
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-xml
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-soap
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-gd
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-imagick
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-fileinfo
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-imap
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0-cli
PHPINI=/etc/php/8.0/fpm/conf.d/linkpanel.ini
sudo touch $PHPINI
sudo cat > "$PHPINI" <<EOF
memory_limit = 256M
upload_max_filesize = 256M
post_max_size = 256M
max_execution_time = 1999
max_input_time = 1999
EOF
service php8.0-fpm restart
sleep 10s
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-fpm
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-common
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-curl
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-openssl
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-bcmath
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-mbstring
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-tokenizer
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-mysql
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-sqlite3
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-pgsql
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-redis
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-memcached
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-json
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-zip
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-xml
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-soap
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-gd
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-imagick
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-fileinfo
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-imap
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.1-cli
PHPINI=/etc/php/8.1/fpm/conf.d/linkpanel.ini
sudo touch $PHPINI
sudo cat > "$PHPINI" <<EOF
memory_limit = 256M
upload_max_filesize = 256M
post_max_size = 256M
max_execution_time = 1999
max_input_time = 1999
EOF
service php8.1-fpm restart
sleep 10s
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-fpm
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-common
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-curl
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-openssl
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-bcmath
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-mbstring
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-tokenizer
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-mysql
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-sqlite3
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-pgsql
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-redis
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-memcached
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-json
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-zip
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-xml
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-soap
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-gd
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-imagick
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-fileinfo
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-imap
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.2-cli
PHPINI=/etc/php/8.2/fpm/conf.d/linkpanel.ini
sudo touch $PHPINI
sudo cat > "$PHPINI" <<EOF
memory_limit = 256M
upload_max_filesize = 256M
post_max_size = 256M
max_execution_time = 1999
max_input_time = 1999
EOF
sudo service php8.2-fpm restart
sleep 10s
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-fpm
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-common
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-curl
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-openssl
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-bcmath
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-mbstring
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-tokenizer
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-mysql
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-sqlite3
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-pgsql
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-redis
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-memcached
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-json
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-zip
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-xml
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-soap
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-gd
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-imagick
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-fileinfo
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-imap
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php8.3-cli
PHPINI=/etc/php/8.3/fpm/conf.d/linkpanel.ini
sudo touch $PHPINI
sudo cat > "$PHPINI" <<EOF
memory_limit = 256M
upload_max_filesize = 256M
post_max_size = 256M
max_execution_time = 1999
max_input_time = 1999
EOF
sudo service php8.3-fpm restart
sleep 10s
# PHP EXTRA
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php-dev php-pear
# PHP CLI
clear
echo "${bggreen}${black}${bold}"
echo "PHP CLI configuration..."
echo "${reset}"
sleep 10s
sudo update-alternatives --set php /usr/bin/php8.0
# COMPOSER
clear
echo "${bggreen}${black}${bold}"
echo "Composer setup..."
echo "${reset}"
sleep 10s
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --no-interaction
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer
composer config --global repo.packagist composer https://packagist.org --no-interaction
# GIT
clear
echo "${bggreen}${black}${bold}"
echo "GIT setup..."
echo "${reset}"
apt-get -y install git
sudo ssh-keygen -t rsa -C "git@github.com" -f /etc/linkpanel/github -q -P ""
sleep 5s
# SUPERVISOR
clear
echo "${bggreen}${black}${bold}"
echo "Supervisor setup..."
echo "${reset}"
sleep 10s
apt-get -y install supervisor
sudo service supervisor restart
sudo service supervisor status
sleep 5s
# DEFAULT VHOST
clear
echo "${bggreen}${black}${bold}"
echo "Default vhost..."
echo "${reset}"
sleep 10s
NGINX=/etc/nginx/sites-available/default
if test -f "$NGINX"; then
sudo unlink NGINX
fi
sudo touch $NGINX
sudo cat > "$NGINX" <<EOF
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
client_body_timeout 10s;
client_header_timeout 10s;
client_max_body_size 256M;
index index.html index.php;
charset utf-8;
server_tokens off;
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
EOF
sudo mkdir /etc/nginx/linkpanel/
sudo systemctl restart nginx.service
sudo systemctl status nginx.service
sleep 15s
# MYSQL
clear
echo "${bggreen}${black}${bold}"
echo "MySQL setup..."
echo "${reset}"
sleep 5s
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server
SECURE_MYSQL=$(expect -c "
set timeout 10
spawn mysql_secure_installation
expect \"Press y|Y for Yes, any other key for No:\"
send \"n\r\"
expect \"New password:\"
send \"$DBPASS\r\"
expect \"Re-enter new password:\"
send \"$DBPASS\r\"
expect \"Remove anonymous users? (Press y|Y for Yes, any other key for No)\"
send \"y\r\"
expect \"Disallow root login remotely? (Press y|Y for Yes, any other key for No)\"
send \"n\r\"
expect \"Remove test database and access to it? (Press y|Y for Yes, any other key for No)\"
send \"y\r\"
expect \"Reload privilege tables now? (Press y|Y for Yes, any other key for No) \"
send \"y\r\"
expect eof
")
echo "$SECURE_MYSQL"
sudo /usr/bin/mysql -u root -p$DBPASS <<EOF
use mysql;
CREATE USER 'linkpanel'@'%' IDENTIFIED WITH mysql_native_password BY '$DBPASS';
GRANT ALL PRIVILEGES ON *.* TO 'linkpanel'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EOF
# REDIS
clear
echo "${bggreen}${black}${bold}"
echo "Redis setup..."
echo "${reset}"
sleep 5s
apt install -y redis-server
sudo rpl -i -w "supervised no" "supervised systemd" /etc/redis/redis.conf
systemctl restart redis.service
sleep 15s
# LET'S ENCRYPT
clear
echo "${bggreen}${black}${bold}"
echo "Let's Encrypt setup..."
echo "${reset}"
sleep 5s
apt-get install -y certbot
apt-get install -y python3-certbot-nginx
# NODE
clear
echo "${bggreen}${black}${bold}"
echo "Node/npm setup..."
echo "${reset}"
sleep 5s
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
NODE=/etc/apt/sources.list.d/nodesource.list
sudo unlink NODE
sudo touch $NODE
sudo cat > "$NODE" <<EOF
deb https://deb.nodesource.com/node_20.x $CODENAME main
deb-src https://deb.nodesource.com/node_20.x $CODENAME main
EOF
apt-get update
apt -y install nodejs
apt -y install npm
#PANEL INSTALLATION
clear
echo "${bggreen}${black}${bold}"
echo "And now LinkPanel installation begin..."
echo "${reset}"
sleep 15s
echo "${bggreen}${black}${bold}"
echo "Create Syslink..."
sudo /usr/bin/mysql -u root -p$DBPASS <<EOF
CREATE DATABASE IF NOT EXISTS linkpanel;
EOF
sleep 10s
sudo rm -rf /var/www/html
cd /var/www && git clone https://github.com/$REPO.git html
cd /var/www/html && git pull
cd /var/www/html && git checkout $BRANCH
cd /var/www/html && git pull
cd /var/www/html && unlink .env
cd /var/www/html && cp .env.example .env
cd /var/www/html && php artisan key:generate
sudo rpl -i -w "DB_USERNAME=dbuser" "DB_USERNAME=linkpanel" /var/www/html/.env
sudo rpl -i -w "DB_PASSWORD=dbpass" "DB_PASSWORD=$DBPASS" /var/www/html/.env
sudo rpl -i -w "DB_DATABASE=dbname" "DB_DATABASE=linkpanel" /var/www/html/.env
sudo rpl -i -w "APP_URL=http://localhost" "APP_URL=http://$IP" /var/www/html/.env
sudo rpl -i -w "APP_ENV=local" "APP_ENV=production" /var/www/html/.env
sudo rpl -i -w "LINKPANELSERVERID" $SERVERID /var/www/html/database/seeders/DatabaseSeeder.php
sudo rpl -i -w "LINKPANELIP" $IP /var/www/html/database/seeders/DatabaseSeeder.php
sudo rpl -i -w "LINKPANELPASS" $PASS /var/www/html/database/seeders/DatabaseSeeder.php
sudo rpl -i -w "LINKPANELDB" $DBPASS /var/www/html/database/seeders/DatabaseSeeder.php
sudo chmod -R o+w /var/www/html/storage
sudo chmod -R 777 /var/www/html/storage
sudo chmod -R o+w /var/www/html/bootstrap/cache
sudo chmod -R 777 /var/www/html/bootstrap/cache
cd /var/www/html && composer update --no-interaction
cd /var/www/html && php artisan key:generate
cd /var/www/html && php artisan cache:clear
cd /var/www/html && php artisan storage:link
cd /var/www/html && php artisan view:cache
cd /var/www/html && php artisan linkpanel:activesetupcount
LINKPANELBULD=/var/www/html/public/build_$SERVERID.php
sudo touch $LINKPANELBULD
sudo cat > $LINKPANELBULD <<EOF
$BUILD
EOF
LINKPANELPING=/var/www/html/public/ping_$SERVERID.php
sudo touch $LINKPANELPING
sudo cat > $LINKPANELPING <<EOF
Up
EOF
PUBKEYGH=/var/www/html/public/ghkey_$SERVERID.php
sudo touch $PUBKEYGH
sudo cat > $PUBKEYGH <<EOF
<?php
echo exec("cat /etc/linkpanel/github.pub");
EOF
cd /var/www/html && php artisan migrate --seed --force
cd /var/www/html && php artisan config:cache
sudo chmod -R o+w /var/www/html/storage
sudo chmod -R 775 /var/www/html/storage
sudo chmod -R o+w /var/www/html/bootstrap/cache
sudo chmod -R 775 /var/www/html/bootstrap/cache
sudo chown -R www-data:linkpanel /var/www/html
# LAST STEPS
clear
echo "${bggreen}${black}${bold}"
echo "Last LinkPanel installation steps..."
echo "${reset}"
sleep 5s
chown www-data:linkpanel -R /var/www/html
chmod -R 750 /var/www/html
echo 'DefaultStartLimitIntervalSec=1s' >> /usr/lib/systemd/system/user@.service
echo 'DefaultStartLimitBurst=50' >> /usr/lib/systemd/system/user@.service
echo 'StartLimitBurst=0' >> /usr/lib/systemd/system/user@.service
systemctl daemon-reload
TASK=/etc/cron.d/linkpanel.crontab
touch $TASK
cat > "$TASK" <<EOF
10 4 * * 7 certbot renew --nginx --non-interactive --post-hook "systemctl restart nginx.service"
20 4 * * 7 apt-get -y update
40 4 * * 7 DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" dist-upgrade
20 5 * * 7 apt-get clean && apt-get autoclean
50 5 * * * echo 3 > /proc/sys/vm/drop_caches && swapoff -a && swapon -a
* * * * * cd /var/www/html && php artisan schedule:run >> /dev/null 2>&1
5 2 * * * cd /var/www/html/utility/linkpanel-update && sh run.sh >> /dev/null 2>&1
EOF
crontab $TASK
systemctl restart nginx.service
sudo rpl -i -w "#PasswordAuthentication" "PasswordAuthentication" /etc/ssh/sshd_config
sudo rpl -i -w "#PasswordAuthentication" "PasswordAuthentication" /etc/ssh/sshd_config
sudo rpl -i -w "PasswordAuthentication no" "PasswordAuthentication yes" /etc/ssh/sshd_config
sudo rpl -i -w "PermitRootLogin yes" "PermitRootLogin no" /etc/ssh/sshd_config
service sshd restart
TASK=/etc/supervisor/conf.d/linkpanel.conf
touch $TASK
sudo cat > "$TASK" <<EOF
[program:linkpanel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:work --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=linkpanel
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/worker.log
stopwaitsecs=3600
EOF
supervisorctl reread
supervisorctl update
supervisorctl start all
service supervisor restart
# COMPLETE
clear
echo "${bggreen}${black}${bold}"
echo "LinkPanel installation has been completed..."
echo "${reset}"
sleep 15s
HOSTNAME=hostname -f | awk '{print $1}'
# SETUP COMPLETE MESSAGE
clear
echo "${green}${bold}"
echo ""
echo "=================================================================="
echo " █ █ ██████ █ █ ████ █ █████ █████ █ "
echo " █ █ █ █ █ █ █ █ ███ █ █ █ █ "
echo " █ █ █ █ ██ █ █ █ █ █ █ ███ █ "
echo " █ █ █ █ █ █ ████ ███████ █ █ █ █ "
echo " ██████ █ █ █ █ █ █ █ █ █ █ █████ █████ "
echo " Debian Version BY ATSi Corporation"
echo "=================================================================="
echo "***********************************************************"
echo " SETUP COMPLETE YAY"
echo "***********************************************************"
echo ""
echo "============================================================"
echo " SSH root user: atsi"
echo " SSH root pass: $PASS"
echo " MySQL root user: atsi"
echo " MySQL root pass: $DBPASS"
echo "============================================================"
echo ""
echo " To manage your server visit"
echo " Your IP Address [http://$IP] OR [http://$HOSTNAME]"
echo " and click on 'dashboard' button."
echo " Default credentials are: atsilinkpanel / adminpass-1230"
echo ""
echo "***********************************************************"
echo " DO NOT LOSE AND KEEP SAFE THIS DATA"
echo "***********************************************************"