forked from D1E7BF44/trojan_setup_script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrojan_setup.sh
4604 lines (4229 loc) · 152 KB
/
trojan_setup.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
#!/usr/bin/env bash
# VPSTOOLBOX
# VPSToolBox is a bash script that helps you setup Trojan-gfw Nginx Hexo Netdata and other powerful applications on a Linux server really quickly.
# MIT License
#
# Copyright (c) 2019-2020 JohnRosen
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set +e
#System Requirement
if [[ $(id -u) != 0 ]]; then
echo Please run this script as root or sudoer.
exit 1
fi
if [[ $(uname -m 2> /dev/null) != x86_64 ]]; then
echo Please run this script on x86_64 machine.
exit 1
fi
#if [[ $(free -m | grep Mem | awk '{print $2}' 2> /dev/null) -le "400" ]]; then
# echo Please run this script on machine with more than 400MB free ram.
# exit 1
#fi
if [[ $(df $PWD | awk '/[0-9]%/{print $(NF-2)}' 2> /dev/null) -le "3000000" ]]; then
echo Please run this script on machine with more than 3G free disk space.
exit 1
fi
#Do not show user interface for apt
export DEBIAN_FRONTEND=noninteractive
ERROR="31m" # Error message
SUCCESS="32m" # Success message
WARNING="33m" # Warning message
INFO="36m" # Info message
LINK="92m" # Share Link Message
#Trojan Server and Client cipher
cipher_server="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"
cipher_client="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:AES128-SHA:AES256-SHA:DES-CBC3-SHA"
#Predefined install
install_bbr=1
install_nodejs=1
if [[ -d /usr/local/qcloud ]]; then
#disable tencent cloud process
rm -rf /usr/local/sa
rm -rf /usr/local/agenttools
rm -rf /usr/local/qcloud
#disable huawei cloud process
rm -rf /usr/local/telescope
fi
#Disable cloud-init
rm -rf /lib/systemd/system/cloud*
colorEcho(){
set +e
COLOR=$1
echo -e "\033[${COLOR}${@:2}\033[0m"
}
#Remove Aliyun aegis
if [[ -f /etc/init.d/aegis ]] || [[ -f /etc/systemd/system/aliyun.service ]]; then
TERM=ansi whiptail --title "malicious alicloud services deletion" --infobox "malicious alicloud services detected, uninstalling now." 7 68
colorEcho ${INFO} "Uninstall Aliyun aegis"
iptables -I INPUT -s 140.205.201.0/28 -j DROP &>/dev/null
iptables -I INPUT -s 140.205.201.16/29 -j DROP &>/dev/null
iptables -I INPUT -s 140.205.201.32/28 -j DROP &>/dev/null
iptables -I INPUT -s 140.205.225.192/29 -j DROP &>/dev/null
iptables -I INPUT -s 140.205.225.200/30 -j DROP &>/dev/null
iptables -I INPUT -s 140.205.225.184/29 -j DROP &>/dev/null
iptables -I INPUT -s 140.205.225.183/32 -j DROP &>/dev/null
iptables -I INPUT -s 140.205.225.206/32 -j DROP &>/dev/null
iptables -I INPUT -s 140.205.225.205/32 -j DROP &>/dev/null
iptables -I INPUT -s 140.205.225.195/32 -j DROP &>/dev/null
iptables -I INPUT -s 140.205.225.204/32 -j DROP &>/dev/null
systemctl stop aegis
systemctl stop CmsGoAgent.service
systemctl stop aliyun
systemctl stop cloud-config
systemctl stop cloud-final
systemctl stop cloud-init-local.service
systemctl stop cloud-init
systemctl stop ecs_mq
systemctl stop exim4
systemctl stop apparmor
systemctl stop sysstat
systemctl disable aegis
systemctl disable CmsGoAgent.service
systemctl disable aliyun
systemctl disable cloud-config
systemctl disable cloud-final
systemctl disable cloud-init-local.service
systemctl disable cloud-init
systemctl disable ecs_mq
systemctl disable exim4
systemctl disable apparmor
systemctl disable sysstat
killall -9 aegis_cli >/dev/null 2>&1
killall -9 aegis_update >/dev/null 2>&1
killall -9 aegis_cli >/dev/null 2>&1
killall -9 AliYunDun >/dev/null 2>&1
killall -9 AliHids >/dev/null 2>&1
killall -9 AliHips >/dev/null 2>&1
killall -9 AliYunDunUpdate >/dev/null 2>&1
rm -rf /etc/init.d/aegis
rm -rf /etc/systemd/system/CmsGoAgent*
rm -rf /etc/systemd/system/aliyun*
rm -rf /lib/systemd/system/cloud*
rm -rf /lib/systemd/system/ecs_mq*
rm -rf /usr/local/aegis
rm -rf /usr/local/cloudmonitor
rm -rf /usr/sbin/aliyun*
rm -rf /sbin/ecs_mq_rps_rfs
for ((var=2; var<=5; var++)) do
if [ -d "/etc/rc${var}.d/" ];then
rm -rf "/etc/rc${var}.d/S80aegis"
elif [ -d "/etc/rc.d/rc${var}.d" ];then
rm -rf "/etc/rc.d/rc${var}.d/S80aegis"
fi
done
apt-get purge sysstat exim4 chrony aliyun-assist -y
systemctl daemon-reload
echo "nameserver 1.1.1.1" > '/etc/resolv.conf'
fi
#Show simple system info
systeminfo(){
echo -e "-------------------------------System Information----------------------------"
echo -e "Hostname:\t\t"`hostname`
echo -e "uptime:\t\t\t"`uptime | awk '{print $3,$4}' | sed 's/,//'`
echo -e "Manufacturer:\t\t"`cat /sys/class/dmi/id/chassis_vendor`
echo -e "Product Name:\t\t"`cat /sys/class/dmi/id/product_name`
echo -e "Version:\t\t"`cat /sys/class/dmi/id/product_version`
echo -e "Serial Number:\t\t"`cat /sys/class/dmi/id/product_serial`
echo -e "Machine Type:\t\t"`vserver=$(lscpu | grep Hypervisor | wc -l); if [ $vserver -gt 0 ]; then echo "VM"; else echo "Physical"; fi`
echo -e "Operating System:\t"`hostnamectl | grep "Operating System" | cut -d ' ' -f5-`
echo -e "Kernel:\t\t\t"`uname -r`
echo -e "Architecture:\t\t"`arch`
echo -e "Processor Name:\t\t"`awk -F':' '/^model name/ {print $2}' /proc/cpuinfo | uniq | sed -e 's/^[ \t]*//'`
echo -e "Active User:\t\t"`w | cut -d ' ' -f1 | grep -v USER | xargs -n1`
echo -e "System Main IP:\t\t"`hostname -I`
echo -e "-------------------------------IP Information--------------------------------"
echo -e "ip:\t\t"`jq -r '.ip' "/root/.trojan/ip.json"`
echo -e "city:\t\t"`jq -r '.city' "/root/.trojan/ip.json"`
echo -e "region:\t\t"`jq -r '.region' "/root/.trojan/ip.json"`
echo -e "country:\t"`jq -r '.country' "/root/.trojan/ip.json"`
echo -e "loc:\t\t"`jq -r '.loc' "/root/.trojan/ip.json"`
echo -e "org:\t\t"`jq -r '.org' "/root/.trojan/ip.json"`
echo -e "postal:\t\t"`jq -r '.postal' "/root/.trojan/ip.json"`
echo -e "timezone:\t"`jq -r '.timezone' "/root/.trojan/ip.json"`
echo -e "-----------------------------------------------------------------------------"
if [[ -f /root/.trojan/ipv6.json ]]; then
echo -e "-------------------------------IPv6 Information------------------------------"
echo -e "ip:\t\t"$(jq -r '.ip' "/root/.trojan/ipv6.json")
echo -e "city:\t\t"$(jq -r '.city' "/root/.trojan/ipv6.json")
echo -e "region:\t\t"$(jq -r '.region' "/root/.trojan/ipv6.json")
echo -e "country:\t"$(jq -r '.country' "/root/.trojan/ipv6.json")
echo -e "loc:\t\t"$(jq -r '.loc' "/root/.trojan/ipv6.json")
echo -e "org:\t\t"$(jq -r '.org' "/root/.trojan/ipv6.json")
echo -e "postal:\t\t"$(jq -r '.postal' "/root/.trojan/ipv6.json")
echo -e "timezone:\t"$(jq -r '.timezone' "/root/.trojan/ipv6.json")
fi
}
#Set system language
setlanguage(){
set +e
if [[ ! -d /root/.trojan/ ]]; then
mkdir /root/.trojan/
mkdir /etc/certs/
fi
if [[ -f /root/.trojan/language.json ]]; then
language="$( jq -r '.language' "/root/.trojan/language.json" )"
fi
while [[ -z $language ]]; do
export LANGUAGE="C.UTF-8"
export LANG="C.UTF-8"
export LC_ALL="C.UTF-8"
if (whiptail --title "Script Language Setting" --yes-button "DO NOT CHOOSE" --no-button "English" --yesno "Language Selection (depreciated)" 8 68); then
chattr -i /etc/locale.gen
cat > '/etc/locale.gen' << EOF
en_US.UTF-8 UTF-8
EOF
language="cn"
locale-gen
update-locale
chattr -i /etc/default/locale
cat > '/etc/default/locale' << EOF
LANGUAGE="en_US.UTF-8"
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
EOF
cat > '/root/.trojan/language.json' << EOF
{
"language": "$language"
}
EOF
else
chattr -i /etc/locale.gen
cat > '/etc/locale.gen' << EOF
en_US.UTF-8 UTF-8
EOF
language="en"
locale-gen
update-locale
chattr -i /etc/default/locale
cat > '/etc/default/locale' << EOF
LANGUAGE="en_US.UTF-8"
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
EOF
cat > '/root/.trojan/language.json' << EOF
{
"language": "$language"
}
EOF
fi
done
if [[ $language == "cn" ]]; then
export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
else
export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
fi
}
#install acme.sh
installacme(){
set +e
curl -s https://get.acme.sh | sh
if [[ $? != 0 ]]; then
colorEcho ${ERROR} "Install acme.sh failed, check your internet connectivity"
exit 1
fi
~/.acme.sh/acme.sh --upgrade --auto-upgrade
}
#Issue Let's Encrypt Certificate using the http challenge type
httpissue(){
openfirewall
http_issue=1
installacme
installnginx
rm -rf /etc/nginx/sites-available/*
rm -rf /etc/nginx/sites-enabled/*
rm -rf /etc/nginx/conf.d/*
touch /etc/nginx/conf.d/default.conf
cat > '/etc/nginx/conf.d/default.conf' << EOF
server {
listen 80;
listen [::]:80;
server_name $domain;
root /usr/share/nginx/html;
}
EOF
systemctl start nginx
clear
colorEcho ${INFO} "Test issuing let\'s encrypt certificate"
~/.acme.sh/acme.sh --issue --test --nginx --cert-home /etc/certs -d $domain --force -k ec-256 --log
if [[ $? != 0 ]] && [[ $? != 2 ]]; then
colorEcho ${ERROR} "Cert issue failed, check DNS record"
colorEcho ${ERROR} "Check https://letsencrypt.status.io/"
colorEcho ${ERROR} "Cert issue failed, check if port 80 is open"
exit 1
fi
clear
colorEcho ${INFO} "issuing let\'s encrypt certificate"
~/.acme.sh/acme.sh --issue --nginx --cert-home /etc/certs -d $domain --force -k ec-256 --log --reloadcmd "systemctl reload trojan postfix dovecot nginx || true"
if [[ $? != 0 ]] && [[ $? != 2 ]]; then
colorEcho ${ERROR} "Cert issue failed, check if port 80 is open"
colorEcho ${ERROR} "Check https://letsencrypt.status.io/"
exit 1
fi
if [[ -f /etc/certs/${domain}_ecc/fullchain.cer ]] && [[ -f /etc/certs/${domain}_ecc/${domain}.key ]]; then
:
else
colorEcho ${ERROR} "Cert issue failed, check if port 80 is open"
colorEcho ${ERROR} "Check https://letsencrypt.status.io/"
exit 1
fi
chmod +r /etc/certs/${domain}_ecc/fullchain.cer
chmod +r /etc/certs/${domain}_ecc/${domain}.key
#write out current crontab
crontab -l > mycron
#echo new cron into cron file
echo "0 0 * * 0 /root/.acme.sh/acme.sh --cron --cert-home /etc/certs --reloadcmd 'systemctl reload trojan postfix dovecot nginx || true'" >> mycron
#install new cron file
crontab mycron
rm mycron
}
#Issue Let's Encrypt Certificate using the DNS challenge type
dnsissue(){
whiptail --title "Warning" --msgbox "Failed" 8 68
APIOPTION=$(whiptail --nocancel --clear --ok-button "Continue" --title "DNS resolver provider API selection" --menu --separate-output "domainAPI:Use Arrow key to choose" 15 68 6 \
"1" "Cloudflare" \
"2" "Namesilo" \
"3" "GoDaddy" \
"http" "HTTP challenge" 3>&1 1>&2 2>&3)
case $APIOPTION in
1)
while [[ -z ${CF_Key} ]] || [[ -z ${CF_Email} ]]; do
CF_Key=$(whiptail --passwordbox --nocancel "https://dash.cloudflare.com/profile/api-tokens,CF Global Key" 8 68 --title "CF_Key input" 3>&1 1>&2 2>&3)
CF_Email=$(whiptail --inputbox --nocancel "https://dash.cloudflare.com/profile, CF_Email" 8 68 --title "CF_Key input" 3>&1 1>&2 2>&3)
done
export CF_Key="$CF_Key"
export CF_Email="$CF_Email"
openfirewall
installacme
~/.acme.sh/acme.sh --issue --force --dns dns_cf --cert-home /etc/certs -d $domain -k ec-256 --force --log --reloadcmd "systemctl reload trojan postfix dovecot nginx || true"
#write out current crontab
crontab -l > mycron
#echo new cron into cron file
echo "0 0 * * 0 /root/.acme.sh/acme.sh --cron --cert-home /etc/certs --reloadcmd 'systemctl reload trojan postfix dovecot nginx || true'" >> mycron
#install new cron file
crontab mycron
rm mycron
;;
2)
while [[ -z $Namesilo_Key ]]; do
Namesilo_Key=$(whiptail --passwordbox --nocancel "https://www.namesilo.com/account_api.php, Namesilo_Key" 8 68 --title "Namesilo_Key input" 3>&1 1>&2 2>&3)
done
export Namesilo_Key="$Namesilo_Key"
openfirewall
installacme
~/.acme.sh/acme.sh --issue --force --dns dns_namesilo --cert-home /etc/certs --dnssleep 1800 -d $domain -k ec-256 --force --log --reloadcmd "systemctl reload trojan postfix dovecot nginx || true"
#write out current crontab
crontab -l > mycron
#echo new cron into cron file
echo "0 0 * * 0 /root/.acme.sh/acme.sh --cron --cert-home /etc/certs --reloadcmd 'systemctl reload trojan postfix dovecot nginx || true'" >> mycron
#install new cron file
crontab mycron
rm mycron
;;
3)
while [[ -z $CX_Key ]] || [[ -z $CX_Secret ]]; do
CX_Key=$(whiptail --passwordbox --nocancel "https://developer.godaddy.com/keys/, GD_Key" 8 68 --title "GD_Key input" 3>&1 1>&2 2>&3)
CX_Secret=$(whiptail --passwordbox --nocancel "https://developer.godaddy.com/keys/, GD_Secret" 8 68 --title "GD_Secret input" 3>&1 1>&2 2>&3)
done
export GD_Key="$CX_Key"
export GD_Secret="$CX_Secret"
openfirewall
installacme
~/.acme.sh/acme.sh --issue --force --dns dns_gd --cert-home /etc/certs -d $domain -k ec-256 --force --log --reloadcmd "systemctl reload trojan postfix dovecot nginx || true"
#write out current crontab
crontab -l > mycron
#echo new cron into cron file
echo "0 0 * * 0 /root/.acme.sh/acme.sh --cron --cert-home /etc/certs --reloadcmd 'systemctl reload trojan postfix dovecot nginx || true'" >> mycron
#install new cron file
crontab mycron
rm mycron
;;
http)
upgradesystem
httpissue
;;
*)
;;
esac
if [[ -f /etc/certs/${domain}_ecc/fullchain.cer ]] && [[ -f /etc/certs/${domain}_ecc/${domain}.key ]]; then
:
else
colorEcho ${ERROR} "DNS challenge failed, [please use] (using) HTTP method instead."
httpissue
fi
}
#Install Trojan-panel
install_tjp(){
TERM=ansi whiptail --title "Installing " --infobox "Installing Trojan-panel..." 7 68
colorEcho ${INFO} "Installing Trojan-panel"
cd /usr/share/nginx/
git clone https://github.com/trojan-gfw/trojan-panel.git
chown -R nginx:nginx /usr/share/nginx/trojan-panel
cd trojan-panel
composer install
npm install
npm audit fix
cp .env.example .env
php artisan key:generate
sed -i "s/example.com/${domain}/;" /usr/share/nginx/trojan-panel/.env
sed -i "s/DB_PASSWORD=/DB_PASSWORD=${password1}/;" /usr/share/nginx/trojan-panel/.env
clear
php artisan migrate --force
chown -R nginx:nginx /usr/share/nginx/
cd
}
#Set json file after installation
prasejson(){
set +e
cat > '/root/.trojan/config.json' << EOF
{
"installed": "1",
"domain": "$domain",
"password1": "$password1",
"password2": "$password2",
"qbtpath": "$qbtpath",
"trackerpath": "$trackerpath",
"trackerstatuspath": "$trackerstatuspath",
"ariapath": "$ariapath",
"ariapasswd": "$ariapasswd",
"filepath": "$filepath",
"netdatapath": "$netdatapath",
"tor_name": "$tor_name"
}
EOF
}
#Read var from json
readconfig(){
domain="$( jq -r '.domain' "/root/.trojan/config.json" )"
password1="$( jq -r '.password1' "/root/.trojan/config.json" )"
password2="$( jq -r '.password2' "/root/.trojan/config.json" )"
qbtpath="$( jq -r '.qbtpath' "/root/.trojan/config.json" )"
trackerpath="$( jq -r '.trackerpath' "/root/.trojan/config.json" )"
trackerstatuspath="$( jq -r '.username' "/root/.trojan/config.json" )"
ariapath="$( jq -r '.ariapath' "/root/.trojan/config.json" )"
ariapasswd="$( jq -r '.ariapasswd' "/root/.trojan/config.json" )"
filepath="$( jq -r '.filepath' "/root/.trojan/config.json" )"
netdatapath="$( jq -r '.netdatapath' "/root/.trojan/config.json" )"
tor_name="$( jq -r '.tor_name' "/root/.trojan/config.json" )"
}
#User input
userinput(){
set +e
clear
if [[ ${install_status} == 1 ]]; then
if (whiptail --title "Installed" --yesno "Trojan has already been installed, read the current configuration?" 8 68); then
readconfig
fi
fi
whiptail --clear --ok-button "Next" --backtitle "Press space to choose" --title "Install checklist" --checklist --separate-output --nocancel "Press space to choose" 24 65 16 \
"Back" "Back to main menu" off \
"" "Proxy" off \
"1" "Trojan-GFW TCP-BBR Dnscrypt-proxy (w/o Netdata)" on \
"2" "RSSHUB + TT-RSS" off \
"" "Download" off \
"3" "Qbittorrent" off \
"4" "Aria2" off \
"5" "Filebrowser" off \
"" "Speedtest" off \
"6" "Speedtest" off \
"" "Database" off \
"7" "MariaDB" off \
"" "Security" off \
"8" "Fail2ban" off \
"" "Mail" off \
"9" "Mail service" off \
"" "Others" off \
"13" "Qbt" off \
"10" "Bt-Tracker(Bittorrent-tracker)" off \
"11" "Trojan-panel (depreciated)" off \
"12" "Tor-Relay (depreciated)" off 2>results
while read choice
do
case $choice in
Back)
advancedMenu
break
;;
1)
install_trojan=1
install_bbr=1
dnsmasq_install=1
install_netdata=0
;;
2)
install_rsshub=1
install_docker=1
install_php=1
install_mariadb=1
;;
3)
install_qbt=1
;;
4)
install_aria=1
;;
5)
install_file=1
;;
6)
install_speedtest=1
install_php=1
;;
7)
install_mariadb=1
;;
8)
install_fail2ban=1
;;
9)
install_mail=1
install_php=1
install_mariadb=1
;;
10)
install_tracker=1
;;
11)
install_tjp=1
install_php=1
install_nodejs=1
install_mariadb=1
;;
12)
install_tor=1
;;
13)
install_qbt_origin=1
;;
*)
;;
esac
done < results
system_upgrade=1
if [[ ${system_upgrade} == 1 ]]; then
if [[ $(lsb_release -cs) == jessie ]]; then
if (whiptail --title "System Upgrade" --yesno "Upgrade to Debian 9 (recommended)?" 8 68); then
debian9_install=1
fi
fi
if [[ $(lsb_release -cs) == xenial ]]; then
if (whiptail --title "System Upgrade" --yesno "Upgrade to Ubuntu 18.04 (recommended)?" 8 68); then
ubuntu18_install=1
fi
fi
fi
#if [[ ${install_mail} == 1 ]]; then
#whiptail --title "Warning" --msgbox "Warning: root domain recommend" 8 68
#whiptail --title "Warning" --msgbox "Warning: manually pointing MX and PTR (reverse dns record) DNS Record required" 8 68
#fi
while [[ -z ${domain} ]]; do
domain=$(whiptail --inputbox --nocancel "Please enter your domain" 8 68 --title "Domain input" 3>&1 1>&2 2>&3)
TERM=ansi whiptail --title "Checking" --infobox "Validating domain name..." 7 68
colorEcho ${INFO} "Checking if domain is vaild."
host ${domain}
if [[ $? != 0 ]]; then
whiptail --title "Warning" --msgbox "Warning: Invaild Domain" 8 68
domain=""
clear
fi
done
clear
hostnamectl set-hostname ${domain}
echo "${domain}" > /etc/hostname
rm -rf /etc/dhcp/dhclient.d/google_hostname.sh
rm -rf /etc/dhcp/dhclient-exit-hooks.d/google_set_hostname
if [[ ${install_trojan} = 1 ]]; then
while [[ -z ${password1} ]]; do
password1=$(whiptail --passwordbox --nocancel "Trojan-GFW Password One (special character not allowed; keep it empty for access to the web interface)" 8 68 --title "password1 input" 3>&1 1>&2 2>&3)
if [[ -z ${password1} ]]; then
password1=$(head /dev/urandom | tr -dc a-z0-9 | head -c 9 ; echo '' )
fi
done
while [[ -z ${password2} ]]; do
password2=$(whiptail --passwordbox --nocancel "Trojan-GFW Password Two (recommend generating a 64 character long password w/o special character)" 8 68 --title "password2 input" 3>&1 1>&2 2>&3)
if [[ -z ${password2} ]]; then
password2=$(head /dev/urandom | tr -dc a-z0-9 | head -c 9 ; echo '' )
fi
done
fi
if [[ ${password1} == ${password2} ]]; then
password2=$(head /dev/urandom | tr -dc a-z0-9 | head -c 9 ; echo '' )
fi
if [[ -z ${password1} ]]; then
password1=$(head /dev/urandom | tr -dc a-z0-9 | head -c 9 ; echo '' )
fi
if [[ -z ${password2} ]]; then
password2=$(head /dev/urandom | tr -dc a-z0-9 | head -c 9 ; echo '' )
fi
if [[ ${install_mail} == 1 ]]; then
mailuser=$(whiptail --inputbox --nocancel "Please enter your desired email username" 8 68 admin --title "Mail user input" 3>&1 1>&2 2>&3)
if [[ -z ${mailuser} ]]; then
mailuser=$(head /dev/urandom | tr -dc a-z | head -c 4 ; echo '' )
fi
fi
if [[ $install_qbt = 1 ]]; then
while [[ -z $qbtpath ]]; do
qbtpath=$(whiptail --inputbox --nocancel "Qbittorrent Nginx Path(Path)" 8 68 /${password1}_qbt/ --title "Qbittorrent path input" 3>&1 1>&2 2>&3)
done
fi
if [[ ${install_aria} == 1 ]]; then
ariaport=$(shuf -i 13000-19000 -n 1)
while [[ -z ${ariapath} ]]; do
ariapath=$(whiptail --inputbox --nocancel "Aria2 RPC Nginx Path(Path)" 8 68 /${password1}_aria2/ --title "Aria2 path input" 3>&1 1>&2 2>&3)
done
while [[ -z $ariapasswd ]]; do
ariapasswd=$(whiptail --passwordbox --nocancel "Aria2 rpc token" 8 68 --title "Aria2 rpc token input" 3>&1 1>&2 2>&3)
if [[ -z ${ariapasswd} ]]; then
ariapasswd=$(head /dev/urandom | tr -dc 0-9 | head -c 10 ; echo '' )
fi
done
fi
if [[ ${install_file} = 1 ]]; then
while [[ -z ${filepath} ]]; do
filepath=$(whiptail --inputbox --nocancel "Filebrowser Nginx Path" 8 68 /${password1}_file/ --title "Filebrowser path input" 3>&1 1>&2 2>&3)
done
fi
if [[ ${install_netdata} = 1 ]]; then
while [[ -z ${netdatapath} ]]; do
netdatapath=$(whiptail --inputbox --nocancel "Netdata Nginx Path" 8 68 /${password1}_netdata/ --title "Netdata path input" 3>&1 1>&2 2>&3)
done
fi
if [[ ${install_tor} = 1 ]]; then
while [[ -z ${tor_name} ]]; do
tor_name=$(whiptail --inputbox --nocancel "Tor nickname" 8 68 --title "tor nickname input" 3>&1 1>&2 2>&3)
if [[ -z ${tor_name} ]]; then
tor_name="myrelay"
fi
done
fi
}
###############OS detect####################
initialize(){
set +e
TERM=ansi whiptail --title "initializing" --infobox "initializing" 7 68
if [[ -f /etc/sysctl.d/60-disable-ipv6.conf ]]; then
mv /etc/sysctl.d/60-disable-ipv6.conf /etc/sysctl.d/60-disable-ipv6.conf.bak
fi
if cat /etc/*release | grep ^NAME | grep -q Ubuntu; then
dist=ubuntu
enablebbr
if [[ -f /etc/sysctl.d/60-disable-ipv6.conf.bak ]]; then
sed -i 's/#//g' /etc/netplan/01-netcfg.yaml
netplan apply
fi
apt-get update
apt-get install sudo whiptail curl dnsutils locales lsb-release jq -y
elif cat /etc/*release | grep ^NAME | grep -q Debian; then
dist=debian
enablebbr
apt-get update
apt-get install sudo whiptail curl dnsutils locales lsb-release jq -y
else
whiptail --title "OS not supported" --msgbox "Please use Debian or Ubuntu to run this script." 8 68
echo "OS not supported),Please use Debian or Ubuntu to run this script."
exit 1;
fi
}
#Run apt upgrade
upgradesystem(){
set +e
if [[ $(lsb_release -cs) == stretch ]]; then
debian10_install=1
fi
if [[ $dist == ubuntu ]]; then
if [[ $ubuntu18_install == 1 ]]; then
cat > '/etc/apt/sources.list' << EOF
#------------------------------------------------------------------------------#
# OFFICIAL UBUNTU REPOS #
#------------------------------------------------------------------------------#
###### Ubuntu Main Repos
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
#deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
###### Ubuntu Update Repos
deb http://us.archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
#deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
#deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
EOF
fi
apt-get update --fix-missing
sh -c 'echo "y\n\ny\ny\ny\ny\ny\ny\ny\n" | DEBIAN_FRONTEND=noninteractive apt-get upgrade -q -y'
sh -c 'echo "y\n\ny\ny\ny\ny\ny\ny\ny\n" | DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -q -y'
sh -c 'echo "y\n\ny\ny\ny\ny\ny\ny\ny\n" | DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -q -y'
sh -c 'echo "y\n\ny\ny\ny\ny\ny\ny\ny\n" | DEBIAN_FRONTEND=noninteractive apt --fix-broken install -y'
sh -c 'echo "y\n\ny\ny\ny\ny\ny\ny\ny\n" | DEBIAN_FRONTEND=noninteractive apt-get autoremove -qq -y'
clear
elif [[ $dist == debian ]]; then
apt-get update --fix-missing
sh -c 'echo "y\n\ny\ny\ny\ny\ny\ny\ny\n" | DEBIAN_FRONTEND=noninteractive apt-get upgrade -q -y'
if [[ ${debian10_install} == 1 ]]; then
cat > '/etc/apt/sources.list' << EOF
#------------------------------------------------------------------------------#
# OFFICIAL DEBIAN REPOS
#------------------------------------------------------------------------------#
###### Debian Main Repos
deb http://deb.debian.org/debian/ stable main contrib non-free
#deb-src http://deb.debian.org/debian/ stable main contrib non-free
deb http://deb.debian.org/debian/ stable-updates main contrib non-free
#deb-src http://deb.debian.org/debian/ stable-updates main contrib non-free
deb http://deb.debian.org/debian-security stable/updates main
#deb-src http://deb.debian.org/debian-security stable/updates main
deb http://ftp.debian.org/debian buster-backports main
#deb-src http://ftp.debian.org/debian buster-backports main
EOF
fi
if [[ ${debian9_install} == 1 ]]; then
cat > '/etc/apt/sources.list' << EOF
#------------------------------------------------------------------------------#
# OFFICIAL DEBIAN REPOS
#------------------------------------------------------------------------------#
###### Debian Main Repos
deb http://deb.debian.org/debian/ oldstable main contrib non-free
#deb-src http://deb.debian.org/debian/ oldstable main contrib non-free
deb http://deb.debian.org/debian/ oldstable-updates main contrib non-free
#deb-src http://deb.debian.org/debian/ oldstable-updates main contrib non-free
deb http://deb.debian.org/debian-security oldstable/updates main
#deb-src http://deb.debian.org/debian-security oldstable/updates main
deb http://ftp.debian.org/debian stretch-backports main
#deb-src http://ftp.debian.org/debian stretch-backports main
EOF
fi
apt-get update --fix-missing
sh -c 'echo "y\n\ny\ny\ny\ny\ny\ny\ny\n" | DEBIAN_FRONTEND=noninteractive apt-get upgrade -q -y'
sh -c 'echo "y\n\ny\ny\ny\ny\ny\ny\ny\n" | DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -q -y'
sh -c 'echo "y\n\ny\ny\ny\ny\ny\ny\ny\n" | DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -q -y'
sh -c 'echo "y\n\ny\ny\ny\ny\ny\ny\ny\n" | DEBIAN_FRONTEND=noninteractive apt --fix-broken install -y'
sh -c 'echo "y\n\ny\ny\ny\ny\ny\ny\ny\n" | DEBIAN_FRONTEND=noninteractive apt-get autoremove -qq -y'
clear
else
clear
TERM=ansi whiptail --title "error can't upgrade system" --infobox "error occurred while upgrading the system" 8 68
exit 1;
fi
if [[ -f /etc/apt/sources.list.d/nginx.list ]]; then
cat > '/etc/apt/sources.list.d/nginx.list' << EOF
deb https://nginx.org/packages/mainline/${dist}/ $(lsb_release -cs) nginx
#deb-src https://nginx.org/packages/mainline/${dist}/ $(lsb_release -cs) nginx
EOF
apt-get update
fi
}
#Install Nginx
installnginx(){
clear
TERM=ansi whiptail --title "Installing " --infobox "Installing NGINX..." 7 68
colorEcho ${INFO} "Installing Nginx"
apt-get install ca-certificates lsb-release -y
apt-get install gnupg gnupg2 -y
apt-get install gpg-agent -y
touch /etc/apt/sources.list.d/nginx.list
cat > '/etc/apt/sources.list.d/nginx.list' << EOF
deb https://nginx.org/packages/mainline/${dist}/ $(lsb_release -cs) nginx
#deb-src https://nginx.org/packages/mainline/${dist}/ $(lsb_release -cs) nginx
EOF
curl -fsSL https://nginx.org/keys/nginx_signing.key | apt-key add -
apt-key fingerprint ABF5BD827BD9BF62
apt-get purge nginx -qq -y
apt-get update
#apt-get install nginx -q -y
sh -c 'echo "y\n\ny\ny\ny\n" | apt-get install nginx -y'
id -u nginx
if [[ $? != 0 ]]; then
useradd -r nginx --shell=/usr/sbin/nologin
apt-get install nginx -y
fi
cat > '/lib/systemd/system/nginx.service' << EOF
[Unit]
Description=The NGINX HTTP and reverse proxy server
Before=netdata.service trojan.service
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT \$MAINPID
PrivateTmp=true
LimitNOFILE=51200
LimitNPROC=51200
Restart=on-failure
RestartSec=3s
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable nginx
mkdir /usr/share/nginx/cache
mkdir /usr/share/nginx/php_cache
cat > '/etc/nginx/nginx.conf' << EOF
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 51200;
use epoll;
multi_accept on;
}
http {
proxy_cache_path /usr/share/nginx/cache levels=1:2 keys_zone=my_cache:10m max_size=100m inactive=60m use_temp_path=off;
proxy_cache_valid 200 302 10m;
proxy_cache_valid 404 1m;
proxy_cache_bypass \$http_pragma \$http_authorization \$http_cache_control;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_cache_revalidate on;
proxy_cache_background_update on;
proxy_cache_lock on;
proxy_cache my_cache;
fastcgi_cache_path /usr/share/nginx/php_cache levels=1:2 keys_zone=phpcache:10m max_size=100m inactive=60m use_temp_path=off;
fastcgi_cache_valid 200 302 10m;
fastcgi_cache_valid 404 1m;
fastcgi_cache_bypass \$http_pragma \$http_authorization \$http_cache_control;
fastcgi_cache_use_stale error timeout updating invalid_header http_500 http_503;
fastcgi_cache_revalidate on;
fastcgi_cache_background_update on;
fastcgi_cache_lock on;
fastcgi_cache phpcache;
fastcgi_cache_key "\$scheme\$proxy_host\$request_uri";
autoindex_exact_size off;
http2_push_preload on;
aio threads;
charset UTF-8;
tcp_nodelay on;
tcp_nopush on;
server_tokens off;
proxy_intercept_errors on;
proxy_socket_keepalive off;
proxy_http_version 1.1;
proxy_ssl_protocols TLSv1.2 TLSv1.3;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
log_format main '\$remote_addr - \$remote_user [\$time_local] "\$request" '
'\$status \$body_bytes_sent "\$http_referer" '
'"\$http_user_agent" "\$http_x_forwarded_for"';
sendfile on;
gzip on;
gzip_proxied any;
gzip_types *;
gzip_comp_level 9;
include /etc/nginx/conf.d/*.conf;
}
EOF
clear
#timedatectl set-timezone UTC
#timedatectl set-ntp off
}
#Open ports
openfirewall(){
set +e
TERM=ansi whiptail --title "Configuring" --infobox "Configuring firewall..." 7 68
colorEcho ${INFO} "Configuring firewall"
#policy
iptables -P INPUT ACCEPT &>/dev/null
iptables -P FORWARD ACCEPT &>/dev/null
iptables -P OUTPUT ACCEPT &>/dev/null
ip6tables -P INPUT ACCEPT &>/dev/null
ip6tables -P FORWARD ACCEPT &>/dev/null
ip6tables -P OUTPUT ACCEPT &>/dev/null
#flash
iptables -F &>/dev/null
ip6tables -F &>/dev/null
#tcp
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT &>/dev/null #HTTPS
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT &>/dev/null #HTTP
#udp
iptables -A INPUT -p udp -m udp --dport 443 -j ACCEPT &>/dev/null
iptables -A INPUT -p udp -m udp --dport 80 -j ACCEPT &>/dev/null
iptables -A OUTPUT -j ACCEPT &>/dev/null
#iptables -I FORWARD -j DROP
#tcp6
ip6tables -I INPUT -p tcp -m tcp --dport 443 -j ACCEPT &>/dev/null #HTTPSv6
ip6tables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT &>/dev/null #HTTPv6
#udp6
ip6tables -A INPUT -p udp -m udp --dport 443 -j ACCEPT &>/dev/null
ip6tables -A INPUT -p udp -m udp --dport 80 -j ACCEPT &>/dev/null
ip6tables -A OUTPUT -j ACCEPT &>/dev/null
#ip6tables -I FORWARD -j DROP
if [[ $install_qbt == 1 ]]; then
iptables -A INPUT ! -s 127.0.0.1 -p tcp -m tcp --dport 8080 -j DROP &>/dev/null
iptables -A INPUT ! -s 127.0.0.1 -p udp -m udp --dport 8080 -j DROP &>/dev/null
fi
if [[ ${install_mail} == 1 ]]; then
iptables -A INPUT -p tcp -m tcp --dport 25 -j ACCEPT &>/dev/null
iptables -A INPUT -p udp -m udp --dport 25 -j ACCEPT &>/dev/null
iptables -A INPUT -p tcp -m tcp --dport 143 -j ACCEPT &>/dev/null
iptables -A INPUT -p tcp -m tcp --dport 465 -j ACCEPT &>/dev/null
iptables -A INPUT -p tcp -m tcp --dport 587 -j ACCEPT &>/dev/null
iptables -A INPUT -p tcp -m tcp --dport 993 -j ACCEPT &>/dev/null
ip6tables -A INPUT -p tcp -m tcp --dport 25 -j ACCEPT &>/dev/null
ip6tables -A INPUT -p udp -m udp --dport 25 -j ACCEPT &>/dev/null
ip6tables -A INPUT -p tcp -m tcp --dport 143 -j ACCEPT &>/dev/null
ip6tables -A INPUT -p tcp -m tcp --dport 465 -j ACCEPT &>/dev/null
ip6tables -A INPUT -p tcp -m tcp --dport 587 -j ACCEPT &>/dev/null
ip6tables -A INPUT -p tcp -m tcp --dport 993 -j ACCEPT &>/dev/null
fi
if [[ ${dist} == debian ]]; then
apt-get install iptables-persistent -y > /dev/null
iptables-save > /etc/iptables/rules.v4
ip6tables-save > /etc/iptables/rules.v6
elif [[ ${dist} == ubuntu ]]; then
ufw allow http
ufw allow https
ufw allow ${ariaport}
apt-get install iptables-persistent -y > /dev/null
iptables-save > /etc/iptables/rules.v4
ip6tables-save > /etc/iptables/rules.v6
else
clear
TERM=ansi whiptail --title "error can't install iptables-persistent" --infobox "error can't install iptables-persistent" 8 68
exit 1;
fi
}
##########install dependencies#############
installdependency(){
set +e
TERM=ansi whiptail --title "Installing " --infobox "Installing necessary dependency..." 7 68
colorEcho ${INFO} "Updating system"
apt-get update
clear
colorEcho ${INFO} "Installing all necessary Software"
apt-get install sudo git curl xz-utils wget apt-transport-https gnupg lsb-release python-pil unzip resolvconf ntpdate systemd dbus ca-certificates locales iptables software-properties-common cron e2fsprogs less haveged neofetch -q -y
apt-get install python3-qrcode python-dnspython -q -y
sh -c 'echo "y\n\ny\ny\n" | DEBIAN_FRONTEND=noninteractive apt-get install ntp -q -y'
clear
if [[ $http_issue != 1 ]]; then
installnginx
fi
#Install docker
if [[ $install_docker == 1 ]]; then
clear
TERM=ansi whiptail --title "Installing " --infobox "Installing Docker..." 7 68
colorEcho ${INFO} "Installing Docker"
if [[ ${dist} == debian ]]; then
apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io -y
elif [[ ${dist} == ubuntu ]]; then
apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io -y
else
echo "fail"