Skip to content

Commit e7c9b20

Browse files
committed
refactor(*.sh): 1. ss fix ipv6 bug; 2. trojan use menu
1 parent c029838 commit e7c9b20

File tree

9 files changed

+253
-82
lines changed

9 files changed

+253
-82
lines changed

centos_install_ss.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,16 @@ installSS() {
238238

239239
echo "3" > /proc/sys/net/ipv4/tcp_fastopen
240240
echo "net.ipv4.tcp_fastopen = 3" >> /etc/sysctl.conf
241-
241+
242+
interface="0.0.0.0"
243+
if [[ "$V6_PROXY" != "" ]]; then
244+
interface="::"
245+
fi
242246
mkdir -p /etc/shadowsocks-libev
243247
ssPath=`which ss-server`
244248
cat > $CONFIG_FILE<<-EOF
245249
{
246-
"server":"::",
250+
"server":"$interface",
247251
"server_port":${PORT},
248252
"local_port":1080,
249253
"password":"${PASSWORD}",

ss.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ checkSystem() {
4242
PMT="apt"
4343
CMD_INSTALL="apt install -y "
4444
CMD_REMOVE="apt remove -y "
45-
CMD_UPGRADE="apt update && apt upgrade -y"
45+
CMD_UPGRADE="apt update; apt upgrade -y; apt autoremove -y"
4646
else
4747
PMT="yum"
4848
CMD_INSTALL="yum install -y "
@@ -176,18 +176,18 @@ getData() {
176176

177177
preinstall() {
178178
$PMT clean all
179-
$CMD_UPGRADE
179+
echo $CMD_UPGRADE | bash
180180

181181
colorEcho $BULE " 安装必要软件"
182182
if [[ "$PMT" = "yum" ]]; then
183183
$CMD_INSTALL epel-release
184184
fi
185185
$CMD_INSTALL telnet wget vim net-tools unzip tar qrencode
186-
$CMD_INSTALL openssl openssl-devel gettext gcc autoconf libtool automake make asciidoc xmlto
186+
$CMD_INSTALL openssl gettext gcc autoconf libtool automake make asciidoc xmlto
187187
if [[ "$PMT" = "yum" ]]; then
188-
$CMD_INSTALL udns-devel libev-devel pcre pcre-devel mbedtls mbedtls-devel libsodium libsodium-devel c-ares c-ares-devel
188+
$CMD_INSTALL openssl-devel udns-devel libev-devel pcre pcre-devel mbedtls mbedtls-devel libsodium libsodium-devel c-ares c-ares-devel
189189
else
190-
$CMD_INSTALL libudns-dev libev-dev libpcre3 libpcre3-dev libmbedtls-dev libc-ares2 libc-ares-dev g++
190+
$CMD_INSTALL libssl-dev libudns-dev libev-dev libpcre3 libpcre3-dev libmbedtls-dev libc-ares2 libc-ares-dev g++
191191
$CMD_INSTALL libsodium*
192192
fi
193193
res=`which wget`
@@ -255,11 +255,15 @@ installSS() {
255255
echo "3" > /proc/sys/net/ipv4/tcp_fastopen
256256
echo "net.ipv4.tcp_fastopen = 3" >> /etc/sysctl.conf
257257

258+
interface="0.0.0.0"
259+
if [[ "$V6_PROXY" != "" ]]; then
260+
interface="::"
261+
fi
258262
mkdir -p /etc/shadowsocks-libev
259263
ssPath=`which ss-server`
260264
cat > $CONFIG_FILE<<-EOF
261265
{
262-
"server":"::",
266+
"server":"$interface",
263267
"server_port":${PORT},
264268
"local_port":1080,
265269
"password":"${PASSWORD}",

ssr.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ checkSystem() {
4646
PMT="apt"
4747
CMD_INSTALL="apt install -y "
4848
CMD_REMOVE="apt remove -y "
49-
CMD_UPGRADE="apt update && apt upgrade -y"
49+
CMD_UPGRADE="apt update && apt upgrade -y; apt autoremove -y"
5050
else
5151
PMT="yum"
5252
CMD_INSTALL="yum install -y "
@@ -270,7 +270,7 @@ getData() {
270270
preinstall() {
271271
colorEcho $BLUE " 更新系统..."
272272
$PMT clean all
273-
$CMD_UPGRADE
273+
echo $CMD_UPGRADE | bash
274274
colorEcho $BLUE " 安装必要软件"
275275
if [[ "$PMT" = "yum" ]]; then
276276
$CMD_INSTALL epel-release

trojan-go.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ checkSystem() {
6060
PMT="apt"
6161
CMD_INSTALL="apt install -y "
6262
CMD_REMOVE="apt remove -y "
63-
CMD_UPGRADE="apt update && apt upgrade -y"
63+
CMD_UPGRADE="apt update; apt upgrade -y; apt autoremove -y"
6464
else
6565
PMT="yum"
6666
CMD_INSTALL="yum install -y "
@@ -667,7 +667,7 @@ installBBR() {
667667

668668
install() {
669669
$PMT clean all
670-
$CMD_UPGRADE
670+
echo $CMD_UPGRADE | bash
671671
$CMD_INSTALL wget net-tools unzip vim
672672
res=`which unzip`
673673
if [[ $? -ne 0 ]]; then
@@ -725,6 +725,7 @@ update() {
725725
}
726726

727727
uninstall() {
728+
echo ""
728729
read -p " 确定卸载trojan-go?[y/n]:" answer
729730
if [[ "${answer,,}" = "y" ]]; then
730731
domain=`grep sni $CONFIG_FILE | cut -d\" -f4`
@@ -737,6 +738,9 @@ uninstall() {
737738

738739
systemctl disable nginx
739740
$CMD_REMOVE nginx
741+
if [[ "$PMT" = "apt" ]]; then
742+
$CMD_REMOVE nginx-common
743+
fi
740744
rm -rf /etc/nginx/nginx.conf
741745
if [[ -f /etc/nginx/nginx.conf.bak ]]; then
742746
mv /etc/nginx/nginx.conf.bak /etc/nginx/nginx.conf
@@ -766,12 +770,14 @@ run() {
766770
start() {
767771
systemctl restart nginx
768772
systemctl restart trojan-go
769-
sleep 3
773+
sleep 2
774+
statusText
770775
}
771776

772777
stop() {
773778
systemctl stop nginx
774779
systemctl stop trojan-go
780+
colorEcho $BLUE " trojan-go停止成功"
775781
}
776782

777783

@@ -784,10 +790,10 @@ restart() {
784790

785791
stop
786792
colorEcho $BLUE " trojan-go停止成功"
787-
sleep 3
793+
sleep 2
788794
start
789795
colorEcho $BLUE " trojan-go启动成功"
790-
sleep 3
796+
sleep 2
791797
statusText
792798
}
793799

0 commit comments

Comments
 (0)