窝最近由于一些需求所以经常要在 VPS 上安装 shadowsocks,但是每一次都按照窝以前写的那篇文章那样一个个配置真是有够麻烦,虽然别人早就写了很多比窝这个更好的脚本,但是感觉比较臃肿,比较窝的需求也就那么点。正好可以学习学习写 shell 嘛~ (`・ω・)

注意,这个脚本只适用于 Ubuntu,而且窝几乎一点 排错/DEBUG 代码都没有写,如果你真的想用那就用吧(没错写这篇文只是为了水一发 20150715224933 并不觉得有人会用。

下面贴代码:

! /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):" ssport [ -z "$ssport" ] && ssport="62100" if [ $ssport -ge 1 ] && [ $ssport -le 65535 ]; then echo "" echo "================================" echo "= port = $ssport " echo "================================" echo "" break else echo "NOT AVAILABLE PORT NUMBER" fi #PASSWORD echo "Please input the password for shadowsocks:" read -p "(Default password: prinzeugen.net):" sspasswd [ -z "$sspasswd" ] && sspasswd="prinzeugen.net" echo "" echo "================================" echo "= password : $sspasswd " echo "================================" echo "" #ENABLE FAST OPEN echo "" echo "Do you want to enable fastopen?(true/false)" read -p "(Default: false):" ssfastopen [ -z "$ssfastopen" ] && ssopen="false" #INSTALL DEPENDENCIES apt-get update -y apt-get install python-pip supervisor -y #CONFIG SHADOWSOCKS.JSON cat > /etc/shadowsocks.json<<-EOF { "server":"::", "serverport":${ssport}, "localport":1080, "password":"${sspasswd}", "timeout":300, "method":"rc4-md5", "fastopen":${ssfastopen} } 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 ""

除另有声明外,本博客文章均采用 知识共享(Creative Commons) 署名-非商业性使用-相同方式共享 3.0 中国大陆许可协议 进行许可。