-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathtwist
903 lines (852 loc) · 37.9 KB
/
twist
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
#! /bin/bash
## Twist Ver 0.2.1 Written by Unbinilium https://github.com/Unbinilium/Twist
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
date="$(date +%Y-%m-%d-%H:%M:%S)"
function shadowsocksconfig(){
SSLOCAL="[\"[::0]\",\"0.0.0.0\"]"
PORT="443"
LOACL="127.0.0.1"
LOCALPORT="1080"
PASSWORD=""
DNS="8.8.8.8"
TIMEOUT="600"
METHOD="xchacha20-ietf-poly1305"
OBFS="tls"
OBFSHOST="mzstatic.com"
OBFSURI="/"
BBR="enable"
FWS="enable"
}
function systemconfig(){
IPREGEX="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
ETH=""
PUBLICIP=""
PUBLICIPv6=""
ELREPOVER7="http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm"
ELREPOVER6="http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm"
libsodiumver=""
mbedtlsver=""
sslibevtag=""
ssobfstag=""
}
function install_twist(){
clear
twistprint
echo -e "#[\033[32;1m A Light Script For You To Setup Shadowsocks-libev Server \033[0m]#"
echo -e "#[\033[32;1m Twist Script Written By Unbinilium \033[0m]#"
echo -e "#[\033[32;1m Installation will Start in 5 Seconds \033[0m]#"
twistprint banner
echo ""
sleep 5
rootness
selinuxdisable
[ -d /etc/twistbackup ] || mkdir -p /etc/twistbackup
shadowsocksconfig
systemconfig
systemdetect
dependenciesinstall
tcpbbrenable
sslibevinstall
sslibevconfigure
firewallconfigure
servicesstart
servicesstatus
}
function update_twist(){
clear
twistprint
echo -e "#[\033[32;1m Update Twist Shadowsocks-libev \033[0m]#"
echo -e "#[\033[32;1m Update will Start in 5 Seconds \033[0m]#"
twistprint banner
echo ""
sleep 5
rootness
systemconfig
selinuxdisable
systemdetect
if [ "$twistinstalled" = "false" ]; then
twistprint banner nofile
else
if [ -r /var/run/shadowsocks-libev.pid ]; then
read pid < /var/run/shadowsocks-libev.pid
[ -e /var/log/twistprotect ] && { cp -f "/var/log/twistprotect" "/var/log/twistprotect-${date}"; rm -f /var/log/twistprotect; }
kill -9 $pid
rm -f /var/run/shadowsocks-libev.pid
fi
fi
dependenciesinstall
sslibevinstall
echo ""
servicesstart
sleep 2
clear
twistprint
echo -e "#[\033[32;1m Twist Update Finished \033[0m]#"
twistprint banner
serverrestart "Update"
echo ""
exit 1
}
function uninstall_twist(){
clear
twistprint
echo -e "#[\033[31;1m Uninstall Twist Shadowsocks-libev \033[0m]#"
echo -e "#[\033[31;1m Uninstall will Start in 5 Seconds \033[0m]#"
twistprint banner
echo ""
sleep 5
rootness
if ! grep -qs "Twist" /etc/sysctl.conf; then
twistprint banner nofile
else
sed -i "/# Twist/d" /etc/sysctl.conf
sed -i "/twistprotect/d" /etc/crontab
if [ "$packagemanagertype" = "p" ]; then
systemctl restart cronie.service
else
systemctl restart cron.service
fi
rm -f /root/twistprotect
twist stop
echo ""
sleep 2
fi
if [ -f /usr/local/bin/ss-server ]; then
ssinstallpath="/usr/local/bin"
else
ssinstallpath="/usr/bin"
fi
pushd ${ssinstallpath}
rm -f ss-local ss-tunnel ss-server ss-manager ss-redir ss-nat obfs-local obfs-server
popd
pushd /usr/local/lib
rm -f libshadowsocks-libev.a libshadowsocks-libev.la /pkgconfig/shadowsocks-libev.pc
popd
pushd /usr/local/share/man/man1
rm -f ss-local.1 ss-tunnel.1 ss-server.1 ss-manager.1 ss-redir.1 ss-nat.1
popd
rm -f /usr/local/include/shadowsocks.h /usr/local/share/man/man8/shadowsocks-libev.8
rm -fr /usr/local/share/doc/shadowsocks-libev /etc/shadowsocks-libev
timemachine restore "/etc/twistbackup/sysctl.conf" "/etc/sysctl.conf" && sysctl -e -p
timemachine restore "/etc/twistbackup/limits.conf" "/etc/security/limits.conf"
timemachine restore "/etc/twistbackup/login" "/etc/pam.d/login"
timemachine restore "/etc/twistbackup/iptables.rules" "/etc/iptables.rules" && iptables-restore < /etc/iptables.rules
timemachine restore "/etc/twistbackup/ip6tables.rules" "/etc/ip6tables.rules" && ip6tables-restore < /etc/ip6tables.rules
if [ -e /etc/twistbackup/iptablesload ]; then
cp -f "/etc/twistbackup/iptablesload" "/etc/network/if-pre-up.d/iptablesload"
else
rm -f /etc/network/if-pre-up.d/iptablesload
fi
if [ -e /etc/twistbackup/ip6tablesload ]; then
cp -f "/etc/twistbackup/ip6tablesload" "/etc/network/if-pre-up.d/ip6tablesload"
else
rm -f /etc/network/if-pre-up.d/ip6tablesload
fi
timemachine restore "/etc/twistbackup/crontab" "/etc/crontab"
timemachine restore "/etc/twistbackup/rc.local" "/etc/rc.local"
timemachine restore "/etc/twistbackup/.htaccess" "/var/www/html/.htaccess"
timemachine restore "/etc/twistbackup/index.html" "/var/www/html/index.html"
rm -fr /etc/twistbackup
systemctl restart fail2ban apache2
[ -e /var/www/html/index.html ] || systemctl stop apache2
ldconfig
clear
twistprint
echo -e "#[\033[32;1m Twist Uninstallation Finished \033[0m]#"
twistprint banner
echo ""
exit 1
}
function twistprint(){
if [ -z "$1" ]; then
echo "######################################################################"
echo "#####################################################################"
echo " ### ### ### ### ######### #########"
echo " ### ### # ### ### ## ##"
echo " ### ### ## ### ### ######### ##"
echo " ### ### ## ## ### ## ##"
echo " ### ### ### ### ######### ##"
echo ""
elif [ -z "$3" ]; then
echo "######################################################################"
else
echo -e "#[\033[31;1m Twist was not found on Your Server! \033[0m]#"
echo ""
exit 1
fi
}
function dependenciesinstallerr(){
echo ""
echo -e "# [\033[31;1mCannot ${1} Dependencies, Please check your network or errors displayed! \033[0m]"
echo ""
exit 1
}
function sslibevinstallerr(){
rm -rf libsodium-${libsodiumver}.tar.gz libsodium-${libsodiumver} mbedtls-${mbedtlsver}-gpl.tgz mbedtls-${mbedtlsver} ${sslibevver}.tar.gz $sslibevver ${ssobfsver}.tar.gz $ssobfsver
echo ""
if [ -z "$2" ]; then
echo -e "# [\033[31;1mCannot download ${1} source. Aborting! \033[0m]"
else
echo -e "# [\033[31;1m Error ${1} failed to build. Aborting! \033[0m]"
fi
echo ""
exit 1
}
function systemdetecterr(){
echo -e "# [\033[31;1mTwist could only run on Ubuntu, Debian, Raspbian, Arch Linux, CentOS, Red Hat or Fedora. Aborating! \033[0m]"
echo ""
exit 1
}
function timemachine(){
[ -e "$2" ] && cp -f "${2}" "${3}"
[ "$1" = "backup" ] && { [ -e "$2" ] && cp -f "${2}" "${3}.old-${date}"; }
}
function serverrestart(){
if [ "$serverrestart" = "true" ]; then
echo -e "# [\033[31;1mThe Server Requires Restart to Finish ${1}, Please Press Enter to Reboot! \033[0m]"
echo ""
read -p ""
sleep 3
reboot
fi
}
function rootness(){
if [ "$(id -u)" != 0 ]; then
echo -e "# [\033[31;1mError:Twist must run by root. Please run Twist with root access! \033[0m]"
echo ""
exit 1
fi
}
function selinuxdisable(){
[ -z "$(which grep)" ] && { echo ""; echo -e "# [\033[31;1mTwist requires the basic dependencies\033[0m \033[32;1mgrep\033[0m, \033[31;1mPlease Install the Dependencies first. \033[0m]"; echo ""; exit 1; }
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
fi
}
function systemdetect(){
if grep -Eqi "Ubuntu|Debian|Raspbian|Arch Linux" /etc/*-release || grep -Eqi "Ubuntu|Debian|Raspbian|Arch Linux" /proc/version; then
systemtype="1"
elif grep -Eqi "CentOS|Red Hat|Fedora" /etc/*-release || grep -Eqi "CentOS|Red Hat|Fedora" /proc/version; then
systemtype="0"
else
systemdetecterr
fi
if [ ! -z "$(which apt)" ]; then
packagemanagertype="a"
elif [ ! -z "$(which yum)" ]; then
packagemanagertype="y"
elif [ ! -z "$(which pacman)" ]; then
packagemanagertype="p"
else
systemdetecterr
fi
if [ -f /proc/user_beancounters ]; then
BBR="disable"
if [ "$packagemanagertype" = "a" ]; then
systemtype="1"
elif [ "$packagemanagertype" = "y" ]; then
systemtype="0"
elif [ "$packagemanagertype" = "p" ]; then
systemtype="1"
fi
fi
if [ "$packagemanagertype" = "a" ]; then
tries="0"
while fuser /var/lib/apt/lists/lock /var/cache/apt/archives/lock /var/lib/dpkg/lock; do
[ "$tries" = "0" ] && { echo ""; echo -e "# [\033[31;1mTrying to lock the Administration Directory, another Process may using it. \033[0m]"; echo ""; }
[ "$tries" = "20" ] && { rm -f /var/lib/apt/lists/lock; rm -f /var/cache/apt/archives/lock; rm -f /var/lib/dpkg/lock; }
[ "$tries" = "21" ] && dpkg --configure -a
[ "$tries" -ge "22" ] && { echo ""; echo -e "# [\033[31;1mUnable to lock the Administration Directory. \033[0m]"; echo ""; break; }
tries=$((tries+1))
sleep 3
done
fi
if [ -z "$(which awk)" ] || [ -z "$(which route)" ] || [ -z "$(which ip)" ] || [ -z "$(which dig)" ] || [ -z "$(which curl)" ]; then
if [ "$packagemanagertype" = "a" ]; then
apt-get update || dependenciesinstallerr "Update"
apt-get -yq install gawk curl net-tools dnsutils || dependenciesinstallerr "Install"
elif [ "$packagemanagertype" = "y" ]; then
yum -y update || dependenciesinstallerr "Update"
yum -y install gawk curl net-tools bind-utils || dependenciesinstallerr "Install"
else
pacman -Syyu --noconfirm || dependenciesinstallerr "Update and Upgrade"
pacman -Syu --noconfirm gawk curl net-tools || dependenciesinstallerr "Install"
fi
clear
fi
if ! grep -qs "Twist" /etc/sysctl.conf; then
twistinstalled="false"
fi
MAKECORES="$(grep -c ^processor /proc/cpuinfo)"
[ -z "$MAKECORES" ] && MAKECORES="1"
kernelverheader="$(uname -r | grep -oE '[0-9]+\.[0-9]+')"
if [ $(echo ${kernelverheader} | awk -v ver=4.9 '{print($1>ver)? "1":"0"}') -eq "1" ]; then
[ "$BBR" = "enable" ] && serverrestart="true"
fi
if [ "$(getconf LONG_BIT)" = "64" ]; then
shmmax="68719476736"
shmall="4294967296"
else
shmmax="4294967295"
shmall="268435456"
fi
if [ -z "$ETH" ]; then
ETH="$(route | grep '^default' | grep -o '[^ ]*$')"
[ -z "$ETH" ] && ETH="$(ip -4 route list 0/0 | grep -Po '(?<=dev )(\S+)')"
if [ ! "$(echo "$ETH" | xargs | awk '{print $2}')" = "" ]; then
if [ ! "$(echo "$ETH" | xargs | awk '{print $1}')" = "$(echo "$ETH" | xargs | awk '{print $2}')" ]; then
echo -e "# [\033[31;1mThere are more than 2 Default Network Interface. Please choose it manually! \033[0m]"
echo ""
ip link
echo ""
echo -e "Please Enter [\033[32;1mNetwork Interface Name\033[0m]:"
read -p "Input Interface Name:" ETH
else
ETH="$(echo "$ETH" | xargs | awk '{print $1}')"
fi
else
ETH="$(echo "$ETH" | xargs | awk '{print $1}')"
fi
fi
ethstatus="$(cat /sys/class/net/${ETH}/operstate)"
if [ -z "$ethstatus" ] || [ "$ethstatus" = "down" ]; then
echo -e "# [\033[31;1mNetwork Interface '${ETH}' is not available. Please try another Network Interface listed below! \033[0m]"
echo ""
ip link
echo ""
echo -e "Please Enter [\033[32;1mNetwork Interface Name\033[0m]:"
read -p "Input Interface Name:" eth
if [ ! "$eth" = "" ]; then
ethstatus="$(cat /sys/class/net/${eth}/operstate)"
if [ -z "$ethstatus" ] || [ "$ethstatus" = "down" ]; then
echo ""
echo -e "# [\033[31;1mThe Network Interface:${eth} you entered is not available. Aborting! \033[0m]"
echo ""
exit 1
else
ETH="$eth"
echo ""
echo -e "# [\033[33;1mNetwork Interface check passed, Using the new Interface\033[0m \033[32;1m${ETH} \033[0m]"
echo ""
fi
fi
fi
[ -z "$PUBLICIP" ] && PUBLICIP="$(dig @resolver1.opendns.com -t A -4 myip.opendns.com +short)"
if ! printf %s "$PUBLICIP" | grep -Eq "$IPREGEX"; then
echo ""
echo -e "# [\033[31;1mCannot detect a valid Public IP. Please fill your Public IP address below! \033[0m]"
read -p "Input Your Public IP:" publicip
if ! printf %s "$publicip" | grep -Eq "$IPREGEX"; then
echo ""
echo -e "# [\033[31;1mThe IP:${publicip} you entered is not vailed. Aborting! \033[0m]"
echo ""
exit 1
else
PUBLICIP="$publicip"
echo ""
echo -e "# [\033[32;1mYou are now using Public IP:${PUBLICIP} \033[0m]"
echo ""
fi
fi
[ -z "$(ip -6 addr show ${ETH})" ] && { SSLOCAL="\"0.0.0.0\""; IPV6ENABLE="false"; }
[ -z "$PUBLICIPv6" ] && PUBLICIPv6="$(curl -s diagnostic.opendns.com/myip)"
[ -z "$PUBLICIPv6" ] && IPV6ENABLE="false"
[ "$PUBLICIPv6" = "$PUBLICIP" ] && IPV6ENABLE="false"
}
function dependenciesinstall(){
if [ "$packagemanagertype" = "a" ]; then
apt-get -yq update || dependenciesinstallerr "Update"
apt-get -yq upgrade || dependenciesinstallerr "Upgrade"
apt-get -yq install wget gawk grep curl sed git gcc swig gettext autoconf automake make libtool perl cpio xmlto asciidoc cron fail2ban net-tools dnsutils rng-tools libc-ares-dev libev-dev openssl libssl-dev zlib1g-dev libpcre3-dev libevent-dev build-essential python-dev python-pip python-setuptools python-m2crypto
[ "$?" != "0" ] && dependenciesinstallerr "Install"
[ "$FWS" = "enable" ] && { apt-get -yq install apache2 || dependenciesinstallerr "Apache"; }
elif [ "$packagemanagertype" = "y" ]; then
yum -y update || dependenciesinstallerr "Update"
yum -y upgrade || dependenciesinstallerr "Upgrade"
[ -e /etc/yum.repos.d/epel.repo ] || { yum -y install epel-release yum-utils || { echo -e "# [\033[31;1mCannot add EPEL repository. Aborting! \033[0m]"; exit 1; }; }
yum -y install wget gawk grep curl sed git gcc swig gettext-devel autoconf automake make libtool pcre-devel perl-devel cpio xmlto asciidoc vixie-cron crontabs fail2ban net-tools bind-utils rng-tools expat-devel openssl-devel zlib-devel libev-devel c-ares-devel python-devel python-setuptools python-pip
[ "$?" != "0" ] && dependenciesinstallerr "Install"
[ "$FWS" = "enable" ] && { yum -y install httpd || dependenciesinstallerr "Apache"; }
else
pacman -Syyu --noconfirm || dependenciesinstallerr "Update and Upgrade"
pacman -Syu --noconfirm wget gawk grep curl sed git gcc swig gettext autoconf automake make libtool pcre perl cpio xmlto asciidoc cronie fail2ban net-tools rng-tools openssl zlib c-ares libev python-devel python-setuptools python-pip python2-m2crypto
[ "$?" != "0" ] && dependenciesinstallerr "Install"
[ "$FWS" = "enable" ] && { pacman -Syu --noconfirm apache || dependenciesinstallerr "Apache"; }
fi
pip install -q qrcode || { echo ""; echo -e "# [\033[31;1mCannot Install QRCode, You may unable to configure clients by QRCode! \033[0m]"; echo ""; sleep 3; }
}
function tcpbbrenable(){
if [ "$BBR" = "enable" ]; then
timemachine backup "/etc/sysctl.conf" "/etc/twistbackup/sysctl.conf"
if [ $(echo ${kernelverheader} | awk -v ver=4.9 '{print($1>ver)? "1":"0"}') -eq "0" ] || [ "$kernelupdated" = "true" ]; then
if [ ! "$(sysctl net.ipv4.tcp_available_congestion_control | awk '{print $3}')" = "bbr" ]; then
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr" >> /etc/sysctl.conf
fi
else
echo "net.ipv4.tcp_congestion_control = hybla" >> /etc/sysctl.conf
if grep -Eqi "Ubuntu|Arch Liunx|CentOS|Red Hat" /etc/*-release || grep -Eqi "Ubuntu|Arch Liunx|CentOS|Red Hat" /proc/version; then
kernelupdate
else
echo ""
echo -e "# [\033[34;1mYou may update server kernel and enable BBR manually. Aborting! \033[0m]"
BBR="disable"
sleep 3
fi
fi
fi
}
function kernelupdate(){
if [ "$packagemanagertype" = "a" ]; then
KERNELURL="http://kernel.ubuntu.com/~kernel-ppa/mainline/"
KERNELVER="$(wget -qO- ${KERNELURL} | awk -F'\"v' '/v[4-9]./{print $2}' | cut -d/ -f1 | grep -v - | sort -V | tail -1)"
[ -z "$KERNELVER" ] && { BBR="disable"; echo -e "# [\033[31;1mCannot get the newest linux kernel verison, bbr disabled! \033[0m]"; }
if [ "$BBR" = "enable" ]; then
SYSTYPE="$(dpkg --print-architecture)"
KERNEL="$(wget -qO- ${KERNELURL}v${KERNELVER}/ | grep "linux-image" | grep "generic" | awk -F'\">' '/${SYSTYPE}.deb/{print $2}' | cut -d'<' -f1 | head -1)"
[ "$BBR" = "enable" ] && wget -t 3 -T 30 -nv -O "$KERNEL" "${KERNELURL}v${KERNELVER}/${KERNEL}"
[ "$BBR" = "enable" ] && { dpkg -i $KERNEL || { echo ""; echo -e "# [\033[31;1mCannot update kernel, bbr disabled! \033[0m]"; echo ""; sleep 3; BBR="disable"; }; }
[ "$BBR" = "enable" ] && { dpkg -l | grep linux-image; rm -f $KERNEL; update-grub; }
fi
elif [ "$packagemanagertype" = "y" ]; then
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org || { echo ""; echo -e "# [\033[31;1mCannot get ELRepo key, you may unable to install ELRepo packages! \033[0m]"; echo ""; sleep 3; }
if grep -qs "release 7" /etc/*-release; then
rpm -Uvh $ELREPOVER7 || { echo ""; echo -e "# [\033[31;1mCannot Install ELRepo repository. Aborting! \033[0m]"; echo ""; sleep 3; BBR="disable"; }
[ "$BBR" = "enable" ] && yum --enablerepo=elrepo-kernel -y install kernel-ml kernel-ml-devel || { echo ""; echo -e "# [\033[31;1mCannot update kernel, bbr disabled! \033[0m]"; echo ""; sleep 3; BBR="disable"; }
[ "$BBR" = "enable" ] && grub2-set-default 0
elif grep -qs "release 6" /etc/*-release; then
rpm -Uvh $ELREPOVER6 || { echo ""; echo -e "# [\033[31;1mCannot Install ELRepo Repository. Aborting! \033[0m]"; echo ""; sleep 3; BBR="disable"; }
[ "$BBR" = "enable" ] && yum --enablerepo=elrepo-kernel -y install kernel-ml kernel-ml-devel || { echo ""; echo -e "# [\033[31;1mCannot update kernel, bbr disabled! \033[0m]"; echo ""; sleep 3; BBR="disable"; }
[ "$BBR" = "enable" ] && sed -i 's/^default=.*/default=0/g' /boot/grub/grub.conf
fi
elif [ "$packagemanagertype" = "p" ]; then
if grep -Eqi "IgnorePkg|IgnoreGroup" /etc/pacman.conf; then
sed -i "/IgnorePkg/d;/IgnoreGroup/d" /etc/pacman.conf
fi
pacman -Syyu --noconfirm || { echo ""; echo -e "# [\033[31;1mCannot update kernel and sources, bbr disabled! \033[0m]"; echo ""; sleep 3; BBR="disable"; }
fi
[ "$BBR" = "enable" ] && { kernelupdated="true"; serverrestart="true"; }
kernelverheader="$(uname -r | grep -oE '[0-9]+\.[0-9]+')"
tcpbbrenable
}
function sslibevinstall(){
[ -z "$libsodiumver" ] && libsodiumver="$(wget -qO- https://api.github.com/repos/jedisct1/libsodium/releases/latest | grep 'tag_name' | cut -d\" -f4)"
wget -t 3 -T 30 -nv -O libsodium-${libsodiumver}.tar.gz https://github.com/jedisct1/libsodium/releases/download/${libsodiumver}/libsodium-${libsodiumver}.tar.gz
[ "$?" != "0" ] && sslibevinstallerr "libsodium-${libsodiumver}"
[ -d libsodium-${libsodiumver} ] && rm -rf libsodium-${libsodiumver}
tar zxf libsodium-${libsodiumver}.tar.gz
pushd libsodium-${libsodiumver}
./configure --prefix=/usr && make "-j$((MAKECORES+1))" && make install || sslibevinstallerr "libsodium-${libsodiumver}" err
popd
if ! ldconfig -p | grep -wq "/usr/lib"; then
echo "/usr/lib" > /etc/ld.so.conf.d/lib.conf
fi
ldconfig
[ -z "$mbedtlsver" ] && mbedtlsver="$(wget -qO- https://tls.mbed.org/download-archive | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | cut -d'.' -f1,2,3 | sort -V | tail -1)"
wget -t 3 -T 30 -nv -O mbedtls-${mbedtlsver}-gpl.tgz https://tls.mbed.org/download/mbedtls-${mbedtlsver}-gpl.tgz
[ "$?" != "0" ] && sslibevinstallerr "mbedtls-${mbedtlsver}"
[ -d mbedtls-${mbedtlsver} ] && rm -rf mbedtls-${mbedtlsver}
tar xf mbedtls-${mbedtlsver}-gpl.tgz
pushd mbedtls-${mbedtlsver}
make SHARED=1 CFLAGS=-fPIC "-j$((MAKECORES+1))" && make DESTDIR=/usr install || sslibevinstallerr "mbedtls-${mbedtlsver}" err
popd
ldconfig
[ -z "$sslibevtag" ] && sslibevtag="$(wget -qO- https://api.github.com/repos/shadowsocks/shadowsocks-libev/releases/latest | grep 'tag_name' | cut -d\" -f4)"
sslibevver="shadowsocks-libev-$(echo ${sslibevtag} | sed -e 's/^[a-zA-Z]//g')"
wget -t 3 -T 30 -nv -O ${sslibevver}.tar.gz https://github.com/shadowsocks/shadowsocks-libev/releases/download/${sslibevtag}/${sslibevver}.tar.gz
[ "$?" != "0" ] && sslibevinstallerr "shadowsocks-libev-$(echo ${sslibevtag} | sed -e 's/^[a-zA-Z]//g')"
[ -d ${sslibevver} ] && rm -rf $sslibevver
tar zxf ${sslibevver}.tar.gz
pushd $sslibevver
./configure --disable-documentation
make "-j$((MAKECORES+1))" && make install || sslibevinstallerr "shadowsocks-libev-$(echo ${sslibevtag} | sed -e 's/^[a-zA-Z]//g')" err
popd
ldconfig
[ -z "$ssobfstag" ] && ssobfstag="$(wget -qO- https://api.github.com/repos/shadowsocks/simple-obfs/releases/latest | grep 'tag_name' | cut -d\" -f4)"
ssobfsver="simple-obfs-$(echo ${ssobfstag} | sed -e 's/^[a-zA-Z]//g')"
wget -t 3 -T 30 -nv -O ${ssobfsver}.tar.gz https://github.com/shadowsocks/simple-obfs/archive/${ssobfstag}.tar.gz
[ "$?" != "0" ] && sslibevinstallerr "simple-obfs-$(echo ${ssobfstag} | sed -e 's/^[a-zA-Z]//g')"
[ -d ${ssobfsver} ] && rm -rf $ssobfsver
tar zxf ${ssobfsver}.tar.gz
pushd $ssobfsver
[ -d libcork ] && rm -rf libcork
git clone https://github.com/shadowsocks/libcork.git -b simple-obfs
[ "$?" != "0" ] && sslibevinstallerr "libcork"
./autogen.sh
./configure
make "-j$((MAKECORES+1))" && make install || sslibevinstallerr "simple-obfs-$(echo ${ssobfstag} | sed -e 's/^[a-zA-Z]//g')" err
popd
ldconfig
[ -f /usr/local/bin/obfs-server ] && ln -s /usr/local/bin/obfs-server /usr/bin
rm -rf libsodium-${libsodiumver}.tar.gz libsodium-${libsodiumver} mbedtls-${mbedtlsver}-gpl.tgz mbedtls-${mbedtlsver} ${sslibevver}.tar.gz $sslibevver ${ssobfsver}.tar.gz $ssobfsver
}
function sslibevconfigure(){
OBFSLOCAL="obfs-host"
OBFSURL=";obfs-uri=${OBFSURI}"
[ "$FWS" = "enable" ] && OBFSLOCAL="failover"
[ -z "$OBFSURI" ] && OBFSURL=""
[ "$OBFSURI" = "/" ] && OBFSURL=""
[ -z "$PASSWORD" ] && PASSWORD="$(< /dev/urandom tr -dc 'A-HJ-NPR-Za-km-z2-9-._+?%^&*()' | head -c 8)"
[ -d /etc/shadowsocks-libev ] || mkdir -p /etc/shadowsocks-libev
timemachine backup "/etc/shadowsocks-libev/config.json" "/etc/twistbackup/config.json"
cat > /etc/shadowsocks-libev/config.json <<-EOF
{
"server":${SSLOCAL},
"server_port":${PORT},
"local_address":"${LOACL}",
"local_port":${LOCALPORT},
"password":"${PASSWORD}",
"nameserver":"${DNS}",
"timeout":${TIMEOUT},
"udp_timeout":${TIMEOUT},
"method":"${METHOD}",
"plugin":"obfs-server",
"plugin_opts":"obfs=${OBFS};fast-open;${OBFSLOCAL}=${OBFSHOST}${OBFSURL}",
"mode":"tcp_and_udp",
"fast_open":true,
}
EOF
if [ "$twistinstalled" = "false" ]; then
timemachine backup "/etc/sysctl.conf" "/etc/twistbackup/sysctl.conf"
cat >> /etc/sysctl.conf <<-EOF
# Twist
fs.file-max = 1024000
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmall = ${shmall}
kernel.shmmax = ${shmmax}
net.core.rmem_max = 12582912
net.core.wmem_max = 12582912
net.core.default_qdisc = fq
net.ipv4.ip_forward = 1
net.ipv4.ip_local_port_range = 2000 65535
net.ipv4.tcp_rmem = 10240 87380 12582912
net.ipv4.tcp_wmem = 10240 87380 12582912
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_fastopen = 3
net.ipv4.conf.all.accept_source_route = 1
net.ipv4.conf.default.accept_source_route = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.lo.send_redirects = 0
net.ipv4.conf.${ETH}.send_redirects = 0
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.lo.rp_filter = 0
net.ipv4.conf.${ETH}.rp_filter = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.all.accept_source_route = 1
net.ipv6.conf.default.accept_source_route = 1
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
net.ipv6.conf.all.autoconf = 1
net.ipv6.conf.all.accept_ra = 2
net.ipv6.conf.${ETH}.accept_ra = 2
EOF
timemachine backup "/etc/security/limits.conf" "/etc/twistbackup/limits.conf"
echo "* soft nofile 512000" >> /etc/security/limits.conf
echo "* hard nofile 1024000" >> /etc/security/limits.conf
echo "" >> /etc/security/limits.conf
if ! grep -qs "pam_limits.so" /etc/pam.d/login; then
timemachine backup "/etc/pam.d/login" "/etc/twistbackup/login"
[ "$systemtype" = "0" ] && echo "session required pam_limits.so" >> /etc/pam.d/login
fi
fi
}
function firewallconfigure(){
iptables-save > "/etc/twistbackup/iptables.rules"
iptables-save > "/etc/twistbackup/iptables.rules.old-${date}"
iptables -I INPUT -m conntrack --ctstate INVALID -j DROP
iptables -I INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -I INPUT -p tcp -m multiport --dports $PORT -j ACCEPT
iptables -I INPUT -p udp -m multiport --dports $PORT -j ACCEPT
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $PORT -j ACCEPT
iptables -I INPUT -m state --state NEW -m udp -p udp --dport $PORT -j ACCEPT
iptables -I FORWARD -m conntrack --ctstate INVALID -j DROP
iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
iptables -t nat -A POSTROUTING -o $ETH -j MASQUERADE
iptables-save > "/etc/iptables.rules"
timemachine backup "/etc/ip6tables.rules" "/etc/twistbackup/ip6tables.rules"
cp -f "/etc/iptables.rules" "/etc/ip6tables.rules"
[ -d /etc/network/if-pre-up.d ] || mkdir -p /etc/network/if-pre-up.d
timemachine backup "/etc/network/if-pre-up.d/iptablesload" "/etc/twistbackup/iptablesload"
cat > /etc/network/if-pre-up.d/iptablesload <<-EOF
#!/bin/sh
iptables-restore < /etc/iptables.rules
exit 0
EOF
timemachine backup "/etc/network/if-pre-up.d/ip6tablesload" "/etc/twistbackup/ip6tablesload"
cat > /etc/network/if-pre-up.d/ip6tablesload <<-EOF
#!/bin/sh
ip6tables-restore < /etc/ip6tables.rules
exit 0
EOF
if [ "$systemtype" = "0" ]; then
systemctl start firewalld
firewall-cmd --permanent --zone=public --add-port=${PORT}/tcp
firewall-cmd --permanent --zone=public --add-port=${PORT}/udp
firewall-cmd --reload
fi
}
function servicesstart(){
recheckkernelverheader="$(uname -r | grep -oE '[0-9]+\.[0-9]+')"
if [ $(echo ${recheckkernelverheader} | awk -v ver="${kernelverheader}" '{print($1>ver)? "1":"0"}') -eq "0" ]; then
serverrestart="true"
fi
if [ -f /usr/local/bin/ss-server ]; then
ssserverpath="/usr/local/bin/ss-server"
else
ssserverpath="/usr/bin/ss-server"
fi
if [ "$twistinstalled" = "false" ]; then
[ -e /etc/crontab ] && cp -f "/etc/crontab" "/etc/twistbackup/crontab"
[ -e /etc/crontab ] || touch /etc/crontab
echo "*/5 * * * * root bash /root/twistprotect" >> /etc/crontab
[ -e /etc/rc.local ] && cp -f "/etc/rc.local" "/etc/twistbackup/rc.local"
[ -e /etc/rc.local ] || echo "#!/bin/bash" > /etc/rc.local
sed --follow-symlinks -i '/^exit 0/d' /etc/rc.local
cat >> /etc/rc.local <<-EOF
sysctl -q -p
iptables-restore < /etc/iptables.rules
ip6tables-restore < /etc/ip6tables.rules
systemctl start fail2ban
[ -e /var/log/twistprotect ] && ${ssserverpath} -uv -c /etc/shadowsocks-libev/config.json -f /var/run/shadowsocks-libev.pid
EOF
if [ "$packagemanagertype" = "p" ]; then
echo "systemctl start cronie.service" >> /etc/rc.local
else
echo "systemctl start cron.service" >> /etc/rc.local
fi
cat >> /etc/rc.local <<-EOF
rngd -r /dev/urandom
exit 0
EOF
else
[ -e /etc/rc.local ] && cp -f "/etc/rc.local" "/etc/twistbackup/rc.local.old-${date}"
fi
cat > /usr/bin/twist <<-EOF
#!/bin/bash
date="\$(date +%Y-%m-%d-%H:%M:%S)"
if [ ! -f /etc/shadowsocks-libev/config.json ]; then
echo -e "# \033[31;1mError: Shadowsocks-libev Config File\033[0m \033[32;1m/etc/shadowsocks-libev/config.json\033[0m \033[31;1mWas Lost... \033[0m"
status="1"
fi
ssserverpid(){
if [ -r /var/run/shadowsocks-libev.pid ]; then
read pid < /var/run/shadowsocks-libev.pid
if [ -d "/proc/\${pid}" ]; then
return 0
else
rm -f /var/run/shadowsocks-libev.pid
return 1
fi
else
return 2
fi
}
twist_status(){
echo -e "# [\033[34;1mTWIST Checking Shadowsocks Status...\033[0m]"
ssserverpid
case \$? in
0)
echo -e "# \033[32;1mShadowsocks-libev is Running... \033[0m"
status="0"
;;
1|2)
echo -e "# \033[31;1mShadowsocks-libev is Stopped... \033[0m"
status="1"
;;
esac
}
twist_start(){
echo -e "# [\033[34;1mTWIST Starting Shadowsocks Service...\033[0m]"
ssserverpid
case \$? in
0)
echo -e "# \033[32;1mShadowsocks-libev is Already Running... \033[0m"
status="0"
;;
1|2)
${ssserverpath} -uv -c /etc/shadowsocks-libev/config.json -f /var/run/shadowsocks-libev.pid
[ -e /var/log/twistprotect ] || touch /var/log/twistprotect
ssserverpid
if [ "\$?" = "0" ]; then
echo -e "# \033[32;1mStarting Shadowsocks-libev Success... \033[0m"
status="0"
else
echo -e "# \033[31;1mStarting Shadowsocks-libev Failed... \033[0m"
status="1"
fi
;;
esac
}
twist_stop(){
echo -e "# [\033[34;1mTWIST Stopping Shadowsocks Service...\033[0m]"
echo -e "# \${date} TWIST Shadowsocks Protect Services Disabled " >> /var/log/twistprotect
ssserverpid
case \$? in
0)
[ -e /var/log/twistprotect ] && { cp -f "/var/log/twistprotect" "/var/log/twistprotect-\${date}"; rm -f /var/log/twistprotect; }
kill -9 \$pid
rm -f /var/run/shadowsocks-libev.pid
[ -e /etc/systemd/system/shadowsocks-libev.service ] && systemctl stop shadowsocks-libev
ssserverpid
if [ "\$?" = "0" ]; then
echo -e "# \033[31;1mStopping Shadowsocks-libev Failed... \033[0m"
status="1"
else
echo -e "# \033[32;1mStopping Shadowsocks-libev Success... \033[0m"
status="0"
fi
;;
1|2)
echo -e "# \033[31;1mShadowsocks-libev is Already Stopped... \033[0m"
status="0"
;;
esac
}
twist_restart(){
echo -e "# [\033[34;1mTWIST Restarting Shadowsocks Service...\033[0m]"
twist stop
twist start
}
twist_custom(){
echo -e "# [\033[34;1mTWIST Loading Shadowsocks Configuration using\033[0m \033[32;1mnano\033[0m \033[32;1mEditor\033[0m]"
sleep 2
sudo nano /etc/shadowsocks-libev/config.json
twist restart
}
twist_update(){
echo -e "# [\033[34;1mTWIST Preparing Update...\033[0m]"
sleep 2
sudo wget https://raw.githubusercontent.com/Unbinilium/Twist/master/twist -O twist.sh && chmod -x twist.sh && bash twist.sh update && rm twist.sh
status="0"
}
twist_uninstall(){
echo -e "# [\033[31;1mTWIST Preparing Uninstallation...\033[0m]"
sleep 2
sudo wget https://raw.githubusercontent.com/Unbinilium/Twist/master/twist -O twist.sh && chmod -x twist.sh && bash twist.sh uninstall && rm twist.sh
status="0"
}
case "\$1" in
status|start|stop|restart|custom|update|uninstall)
twist_\${1}
;;
*)
echo "Usage: \$0 { status | start | stop | restart | custom | update | uninstall }"
status="0"
;;
esac
exit \$status
EOF
cat > /root/twistprotect <<-EOF
#!/bin/bash
date="\$(date +%Y-%m-%d-%H:%M:%S)"
echo -e "# [\033[34;1mTWIST Shadowsocks Protect Services\033[0m \033[32;1m/var/log/twistprotect\033[0m]"
twistprotectenable(){
echo -e "# \033[32;1mTWIST Shadowsocks Protect Services Enabled \033[0m"
echo -e "# \${date} TWIST Shadowsocks Protect Services Enabled " >> /var/log/twistprotect
status=\$(ps -ef | grep -v grep | grep -i "${ssserverpath}" | awk '{print \$2}')
if [ -z \$status ]; then
echo -e "# \033[31;1mShadowsocks Stopped Detected... \033[0m"
echo -e "# \${date} Shadowsocks Stopped Detected " >> /var/log/twistprotect
${ssserverpath} -uv -c /etc/shadowsocks-libev/config.json -f /var/run/shadowsocks-libev.pid || echo "# \${date} Shadowsocks Unable to Run " >> /var/log/twistprotect
else
echo -e "# \033[32;1mShadowsocks Running Detected... \033[0m"
echo -e "# \${date} Shadowsocks Running Detected " >> /var/log/twistprotect
fi
}
EOF
chmod +x /etc/network/if-pre-up.d/iptablesload /etc/network/if-pre-up.d/ip6tablesload /etc/rc.local /usr/bin/twist /root/twistprotect
chmod 600 /etc/shadowsocks-libev/config.json
[ "$systemtype" = "0" ] && systemctl --now mask firewalld
systemctl enable iptables fail2ban
iptables-restore < /etc/iptables.rules
ip6tables-restore < /etc/ip6tables.rules
systemctl restart fail2ban
if [ "$packagemanagertype" = "p" ]; then
systemctl enable cronie.service
systemctl start cronie.service
else
systemctl enable cron.service
systemctl start cron.service
fi
sysctl -p
ldconfig
if [ "$FWS" = "enable" ]; then
if [ "$twistinstalled" = "false" ]; then
[ -e /var/www/html/.htaccess ] && cp -f "/var/www/html/.htaccess" "/etc/twistbackup/.htaccess"
[ -e /var/www/html/index.html ] && cp -f "/var/www/html/index.html" "/etc/twistbackup/index.html"
else
[ -e /var/www/html/.htaccess ] && cp -f "/var/www/html/.htaccess" "/etc/twistbackup/.htaccess.old-${date}"
[ -e /var/www/html/index.html ] && cp -f "/var/www/html/index.html" "/etc/twistbackup/index.html.old-${date}"
fi
rm -f /var/www/html/.htaccess && echo "" > /var/www/html/.htaccess
cat >> /var/www/html/.htaccess <<-EOF
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^$(echo $PUBLICIP | cut -d'.' -f1)\.$(echo $PUBLICIP | cut -d'.' -f2)\.$(echo $PUBLICIP | cut -d'.' -f3)\.$(echo $PUBLICIP | cut -d'.' -f4)
RewriteRule (.*) http://${OBFSHOST}/\$1 [R=301,L]
</IfModule>
EOF
rm -f /var/www/html/index.html && echo "" > /var/www/html/index.html
cat >> /var/www/html/index.html <<-EOF
<head><meta http-equiv="refresh" content="0;url=http://${OBFSHOST}"></head>
EOF
systemctl restart apache2
fi
rngd -r /dev/urandom
sleep 3
echo ""
twist start && twist status
echo ""
if [ "$twistinstalled" = "false" ]; then
cat >> /root/twistprotect <<-EOF
if [ -e /var/log/twistprotect ]; then
twistprotectenable
else
echo -e "# \033[31;1mTWIST Shadowsocks Protect Services Disabled \033[0m"
fi
EOF
fi
sleep 2
}
function servicesstatus(){
clear
twistprint
echo -e " [\033[32;1mInstall Complete\033[0m]"
echo -e " [\033[32;1mPlease Press Enter to Show Connect Infomation and EXIT\033[0m]"
twistprint banner
read -p ""
echo "ss://$(echo -n "${METHOD}:${PASSWORD}@${PUBLICIP}:${PORT}?plugin=obfs-local;obfs-host=${OBFSHOST};obfs-uri=${OBFSURI};obfs=${OBFS}#Twist" | base64 -w 0)" | qr
echo -e "# [\033[32;1mss://\033[0m\033[34;1m$(echo -n "${METHOD}:${PASSWORD}@${PUBLICIP}:${PORT}?plugin=obfs-local;obfs-host=${OBFSHOST};obfs-uri=${OBFSURI};obfs=${OBFS}#Twist" | base64 -w 0)\033[0m]"
echo -e "# [\033[32;1mServer IP:\033[0m \033[34;1m${PUBLICIP}\033[0m\c"
[ ! "$IPV6ENABLE" = "false" ] && echo -e "(\033[34;1m${PUBLICIPv6}\033[0m)\c"
echo -e " \033[32;1mPassWord:\033[0m \033[34;1m${PASSWORD}\033[0m \033[32;1mEncryption:\033[0m \033[34;1m${METHOD}\033[0m \033[32;1mOBFS:\033[0m \033[34;1m${OBFS}\033[0m \033[32;1mOBFS-HOST:\033[0m \033[34;1m${OBFSHOST}\033[0m \033[32;1mOBFS-URI:\033[0m \033[34;1m${OBFSURI}\033[0m \033[32;1mLOCALHOST:\033[0m \033[34;1m${LOACL}:${LOCALPORT}\033[0m]"
serverrestart "Installation"
echo ""
}
case "$1" in
install|update|uninstall)
${1}_twist
exit 0
;;
*)
if [ -z "$1" ]; then
install_twist
else
echo "Usage: $0 { install | update | uninstall }"
exit 1
fi
;;
esac