Created
June 27, 2017 18:06
-
-
Save fanlushuai/09d1d3c8af74abd3104604ce77ef856f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
echo "Install Shadowsocks on CentOS 7" | |
CONFIG_FILE=/etc/shadowsocks.json | |
SERVICE_FILE=/etc/systemd/system/shadowsocks.service | |
SS_METHOD=aes-256-cfb | |
SS_IP=`ip route get 1 | awk '{print $NF;exit}'` | |
GET_PIP_FILE=/tmp/get-pip.py | |
echo "============Software install=====================" | |
echo "1/2 install pip" | |
curl "https://bootstrap.pypa.io/get-pip.py" -o "${GET_PIP_FILE}" | |
python ${GET_PIP_FILE} | |
echo "2/2 install shadowsocks" | |
pip install --upgrade pip | |
pip install shadowsocks | |
echo "============Define Config======================" | |
echo "1/2 Please set ss port:" | |
read SS_PORT | |
echo "2/2 Please set ss password:" | |
read SS_PASSWORD | |
echo "set prot ${SS_PORT} and pw ${SS_PASSWORD}" | |
echo "============Create shadowsocls config file===========" | |
cat <<EOF | sudo tee ${CONFIG_FILE} | |
{ | |
"server": "0.0.0.0", | |
"server_port": ${SS_PORT}, | |
"password": "${SS_PASSWORD}", | |
"method": "${SS_METHOD}" | |
} | |
EOF | |
echo "Config file path=/etc/shadowsocks.json" | |
echo "============Create service======================" | |
cat <<EOF | sudo tee ${SERVICE_FILE} | |
[Unit] | |
Description=Shadowsocks | |
[Service] | |
TimeoutStartSec=0 | |
ExecStart=/usr/bin/ssserver -c ${CONFIG_FILE} | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
echo "Service file path=/etc/shadowsocks.json" | |
echo "============Start service......=====================" | |
systemctl enable shadowsocks | |
systemctl start shadowsocks | |
sleep 5 | |
echo "============View service status=====================" | |
systemctl status shadowsocks -l | |
echo "================================" | |
echo "" | |
echo "Congratulations! Shadowsocks has been installed on your system." | |
echo "You shadowsocks connection info:" | |
echo "--------------------------------" | |
echo "server: ${SS_IP}" | |
echo "server_port: ${SS_PORT}" | |
echo "password: ${SS_PASSWORD}" | |
echo "method: ${SS_METHOD}" | |
echo "========================================" | |
echo "==========Next To Open Firewall Port=============" | |
echo "Auto open firewall port ${SS_PORT} ? (y/n) " | |
read Y | |
if [ $Y == 'y' ] | |
then | |
sudo firewall-cmd --zone=public --add-port=${SS_PORT}/tcp --permanent | |
sudo firewall-cmd --reload | |
echo "Port Opend !" | |
else | |
echo "See you then !" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment