Last active
August 21, 2017 06:36
-
-
Save lackofdream/671927bc33618c3878eb6ca460bb2b12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function _pre_read_input { | |
apt-get update | |
apt-get install -y pwgen | |
} | |
function read_input { | |
_pre_read_input | |
read -p "shadowsocks config dir[/etc/shadowsocks-libev]: " SS_CONFIG_DIR | |
if [ -z $SS_DIR ]; then | |
SS_CONFIG_DIR=/etc/shadowsocks-libev | |
fi | |
read -p "shadowsocks server port: " SS_PORT | |
if [ -z $SS_PORT ]; then | |
SS_PORT=$((2000+RANDOM%7592)) | |
fi | |
read -p "shadowsocks server password: " SS_PASSWORD | |
if [ -z $SS_PASSWORD ]; then | |
SS_PASSWORD=$(pwgen 12 1) | |
fi | |
mkdir -p $SS_CONFIG_DIR | |
cat > $SS_CONFIG_DIR/config.json << EOF | |
{ | |
"server": "0.0.0.0", | |
"server_port": $SS_PORT, | |
"local_port": 1080, | |
"password": "$SS_PASSWORD", | |
"timeout": 60, | |
"method": "chacha20-ietf-poly1305", | |
"plugin": "obfs-server", | |
"plugin_opts": "obfs=tls" | |
} | |
EOF | |
} | |
function _pre_install_simple_obfs { | |
apt-get update | |
apt-get install -y --no-install-recommends build-essential autoconf libtool libssl-dev libpcre3-dev libudns-dev libev-dev asciidoc xmlto automake git ca-certificates | |
} | |
function install_simple_obfs { | |
_pre_install_simple_obfs | |
cd $HOME | |
git clone --depth 1 https://github.com/shadowsocks/simple-obfs | |
cd simple-obfs | |
git submodule update --init --recursive | |
./autogen.sh && ./configure && make && make install | |
} | |
function _pre_install_ss { | |
apt-get install -y software-properties-common | |
add-apt-repository -y ppa:max-c-lv/shadowsocks-libev | |
apt-get update | |
} | |
function install_ss { | |
_pre_install_ss | |
apt install -y shadowsocks-libev | |
} | |
function enable_ss { | |
systemctl enable shadowsocks-libev-server@config | |
} | |
function start_ss { | |
systemctl start shadowsocks-libev-server@config | |
} | |
function done_prompt { | |
echo "Everything is done!" | |
echo "Your shadowsocks-libev server is listening on 0.0.0.0:$SS_PORT" | |
echo "Your password is $SS_PASSWORD" | |
} | |
read_input | |
install_simple_obfs | |
install_ss | |
enable_ss | |
start_ss | |
done_prompt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment