Skip to content

Instantly share code, notes, and snippets.

@tuxlinuxien
Last active October 25, 2023 02:08
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxlinuxien/31819c99067af06cfe074006cf49b3a2 to your computer and use it in GitHub Desktop.
Save tuxlinuxien/31819c99067af06cfe074006cf49b3a2 to your computer and use it in GitHub Desktop.
Shadowsocks installer for ubuntu 16.04
#!/bin/sh
cd $HOME;
echo "Running apt-get update ..."
sudo apt-get update > /dev/null
echo "Install installing dependencies ..."
sudo apt-get install -y --no-install-recommends gettext build-essential autoconf libtool libpcre3-dev asciidoc xmlto libev-dev libc-ares-dev automake libmbedtls-dev libsodium-dev > /dev/null
if [ -d "shadowsocks-libev" ]; then
echo -n;
else
git clone https://github.com/shadowsocks/shadowsocks-libev.git $HOME/shadowsocks-libev;
fi
cd $HOME/shadowsocks-libev
git submodule update --init --recursive
if [ -f "configure" ]; then
echo -n;
else
./autogen.sh;
fi
if [ -f "Makefile" ]; then
echo -n;
else
./configure;
fi
make >> /dev/null
sudo make install >> /dev/null
cat << EOF
#################################
# #
# Configure shadowsocks service #
# #
#################################
EOF
read -p "Port to listen: " PORT
read -p "Password: " PASSWORD
cat << EOF > /etc/systemd/system/ss-server.service
[Unit]
Description=Shadowsocks server
After=network.target
[Service]
LimitNOFILE=49152
ExecStart=/usr/local/bin/ss-server -u -p $PORT -k $PASSWORD -m aes-256-cfb
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
echo "Adding service to systemd: /etc/systemd/system/ss-server.service"
systemctl daemon-reload
systemctl enable ss-server.service
systemctl start ss-server.service
echo "Please check https://gist.github.com/tuxlinuxien/31819c99067af06cfe074006cf49b3a2 for better performance settings."
# /etc/security/limits.conf
* soft nofile 102400
* hard nofile 102400
* soft nproc 10240
* hard nproc 10240
# /etc/sysctl.conf
fs.file-max = 102400
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment