forked from zw963/asuswrt-merlin-transparent-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_ss_to_vps
executable file
·67 lines (50 loc) · 1.95 KB
/
deploy_ss_to_vps
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
#!/bin/sh
self="$(curl https://raw.githubusercontent.com/zw963/deployment_bash/v0.3.6/deploy_start.sh)" && eval "$self"
export target=$1
copy ss-server/config.json /etc/shadowsocks/config.json
deploy_start
# Following code is execute on remote VPS
if which ss-server &>/dev/null; then
echo 'ss-server is exist, skip deploy.'
exit
fi
# replace `你的密码' to yours REALLY PASSWORD before deploy.
replace_string 'mypassword' "你的密码" /etc/shadowsocks/config.json
if grep -qs -e '你的密码' /etc/shadowsocks/config.json; then
echo 'You must specify shadowsocks server password!'
exit
fi
cat <<'HEREDOC' > /etc/sysctl.d/98-shadowsocks.conf
fs.file-max=51200
net.core.rmem_max=67108864
net.core.wmem_max=67108864
net.core.netdev_max_backlog=250000
net.core.somaxconn=4096
net.ipv4.tcp_syncookies=1
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_tw_recycle=0
net.ipv4.tcp_fin_timeout=30
net.ipv4.tcp_keepalive_time=1200
net.ipv4.ip_local_port_range=10000 65000
net.ipv4.tcp_max_syn_backlog=8192
net.ipv4.tcp_max_tw_buckets=5000
net.ipv4.tcp_fastopen=3
net.ipv4.tcp_mem=25600 51200 102400
net.ipv4.tcp_rmem=4096 87380 67108864
net.ipv4.tcp_wmem=4096 65536 67108864
net.ipv4.tcp_mtu_probing=1
net.ipv4.tcp_congestion_control=hybla
# 开启内核 fastopen, Linux 3.7 以上支持, 3.13 才默认开启.
# 等价于 echo 1 > /proc/sys/net/ipv4/tcp_fastopen
net.ipv4.tcp_fastopen=1
HEREDOC
sysctl -p
package compile-tools pcre-devel asciidoc xmlto mbedtls-devel libsodium-devel udns-devel libev-devel haveged
[ -d shadowsocks-libev-3.0.8 ] || download_and_extract https://github.com/shadowsocks/shadowsocks-libev/releases/download/v3.0.8/shadowsocks-libev-3.0.8.tar.gz
cd shadowsocks-libev-3.0.8/ &&
configure shadowsocks &&
make &&
make install-strip &&
daemon shadowsocks '/usr/bin/ss-server -u --fast-open -c /etc/shadowsocks/config.json -vvv'
server_port=$(cat /etc/shadowsocks/config.json |grep 'server_port"' |grep -o '[0-9]*')
expose_port $server_port