Skip to content

Instantly share code, notes, and snippets.

@MelvinTo
Last active November 20, 2018 17:20
Show Gist options
  • Save MelvinTo/0fa272ee11c7d6af5e3fc1b9a76cb3b1 to your computer and use it in GitHub Desktop.
Save MelvinTo/0fa272ee11c7d6af5e3fc1b9a76cb3b1 to your computer and use it in GitHub Desktop.
SS Install
#!/bin/bash
echo "Warning: This script is only tested on ubuntu 18.04 LTS"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# Require sudo privilege to setup and install packages
echo "Turning on BBR..."
sudo bash -c "modprobe tcp_bbr" &>/dev/null
sudo bash -c "echo tcp_bbr >> /etc/modules-load.d/modules.conf" &>/dev/null
sudo bash -c "echo net.core.default_qdisc=fq >> /etc/sysctl.conf" &>/dev/null
sudo bash -c "echo net.ipv4.tcp_congestion_control=bbr >> /etc/sysctl.conf" &>/dev/null
sudo sysctl -p &>/dev/null
echo "Installing shadowsocks..."
sudo apt-get install -y shadowsocks-libev &>/dev/null
echo "Creating random password, you can change later"
PASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')
cat > ss.config.json <<EOF
{
"password" : "$PASSWORD",
"timeout" : 1000,
"server_port" : 8488,
"method" : "chacha20-ietf-poly1305",
"local_port" : 1080
}
EOF
echo "Adding shadowsocks to system service..."
sudo bash -c "cat > /etc/systemd/system/ss.service" <<EOF
[Unit]
Description=SS server
After=network.target
[Service]
User=$(whoami)
Restart=always
WorkingDirectory=$DIR
ExecStart=$(which ss-server) -c ss.config.json -u
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable ss
echo "Installation complete!"
echo "You can manage ss by 'sudo systemctl status/start/stop/restart ss'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment