Skip to content

Instantly share code, notes, and snippets.

@prinsss
Created August 12, 2015 09:25
Show Gist options
  • Save prinsss/0e900c2e2fdd034aac5c to your computer and use it in GitHub Desktop.
Save prinsss/0e900c2e2fdd034aac5c to your computer and use it in GitHub Desktop.
shadowsocks one-key install shell
#! /bin/bash
#==================================
# AUTHOR: printempw
# NOTE: I HAVEN'T WRITE ANY DEBUG CODE IN THIS SHELL,
# IF ANY ERROR RAISES,UMM,JUST LET IT GO
# SYSTEM REQUIRED: ONLY FOR UBUNTU
#==================================
clear
echo ""
echo "======================================="
echo "= NOW START TO INSTALL SHADOWSOCKS ="
echo "= NOTE: PLEASE RUN THIS SHELL AS ROOT ="
echo "======================================="
echo ""
echo "Press any key to install or Press Ctrl+C to cancel"
#PORT
echo "Please input the port for shadowsocks [1-65535]:"
read -p "(Default port: 62100):" ss_port
[ -z "$ss_port" ] && ss_port="62100"
if [ $ss_port -ge 1 ] && [ $ss_port -le 65535 ]; then
echo ""
echo "===================================="
echo "= port = $ss_port "
echo "===================================="
echo ""
break
else
echo "NOT AVAILABLE PORT NUMBER"
fi
#PASSWORD
echo "Please input the password for shadowsocks:"
read -p "(Default password: prinzeugen.net):" ss_passwd
[ -z "$ss_passwd" ] && ss_passwd="prinzeugen.net"
echo ""
echo "===================================="
echo "= password : $ss_passwd "
echo "===================================="
echo ""
#ENABLE FAST OPEN
echo ""
echo "Do you want to enable fast_open?(true/false)"
read -p "(Default: false):" ss_fastopen
[ -z "$ss_fastopen" ] && ss_open="false"
#INSTALL DEPENDENCIES
apt-get update -y
apt-get install python-pip supervisor -y
#CONFIG SHADOWSOCKS.JSON
cat > /etc/shadowsocks.json<<-EOF
{
"server":"::",
"server_port":${ss_port},
"local_port":1080,
"password":"${ss_passwd}",
"timeout":300,
"method":"rc4-md5",
"fast_open":${ss_fastopen}
}
EOF
#CONFIG SUPERVISOR
cat > /etc/supervisor/conf.d/shadowsocks.conf<<-EOF
[program:shadowsocks]
command=ssserver -c /etc/shadowsocks.json
autorestart=true
user=nobody
EOF
echo "ulimit -n 51200" >> /etc/default/supervisor
#SET IPTABLES
iptables -I INPUT -p tcp -m tcp --dport ${ss_port} -j ACCEPT
iptables-save
iptables restart
#INSTALL SHADOWSOCKS
pip install shadowsocks
#START SHADOWSOCKS
service supervisor start
supervisorctl reload
supervisorctl restart shadowsocks
echo ""
echo "===================================="
echo "= INSTALLITION DONE ="
echo "= ENJOY IT ="
echo "===================================="
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment