-
Notifications
You must be signed in to change notification settings - Fork 1
/
startup.sh
22 lines (18 loc) · 1.19 KB
/
startup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
apt update
apt install -y shadowsocks-libev haveged
# Set the password to our variable, listen on all interfaces(0.0.0.0), change server port to 8888 and set enable TCP Fast Open
sed -i 's/"password":".*",/"password":"${password}",/g' /etc/shadowsocks-libev/config.json
sed -i 's/"server":\["::1", "127.0.0.1"\],/"server":\["::0", "0.0.0.0"\],/g' /etc/shadowsocks-libev/config.json
sed -i 's/"server_port":8388,/"server_port":8888,/g' /etc/shadowsocks-libev/config.json
sed -i 's/"method":"chacha20-ietf-poly1305"/"method":"chacha20-ietf-poly1305",\n "fast_open": true/g' /etc/shadowsocks-libev/config.json
# Enable TCP BBR and TCP Fast Open
echo "net.ipv4.tcp_fastopen=3" >> /etc/sysctl.conf
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
/usr/sbin/sysctl -p
# Restart Shadowsocks server to apply changes
/usr/sbin/service shadowsocks-libev restart
/usr/sbin/service shadowsocks-libev enable
# The SS Proxy server process sometimes stops on its own. I've added this cron job to restart it every 3hrs to make sure its keeps running.
echo "0 */3 * * * root /usr/sbin/service shadowsocks-libev restart" > /etc/cron.d/restart_ss