Remove unsafe shadowsocks server version

This commit is contained in:
Yuk1n0 2020-03-04 01:32:43 +08:00
parent 8b3324e003
commit 2f948276bb
No known key found for this signature in database
GPG key ID: 19A0D6377E84BEE6
6 changed files with 114 additions and 861 deletions

View file

@ -21,36 +21,24 @@ chmod +x shadowsocks-all.sh
**How to start | stop | restart your server**
Shadowsocks-Python
/etc/init.d/shadowsocks-python start | stop | restart | status
Shadowsocks-libev
/etc/init.d/shadowsocks-libev start | stop | restart | status
ShadowsocksR
/etc/init.d/shadowsocks-r start | stop | restart | status
Shadowsocks-Go
/etc/init.d/shadowsocks-go start | stop | restart | status
Shadowsocks-libev
/etc/init.d/shadowsocks-libev start | stop | restart | status
****
**Configuration Files**
Shadowsocks-Python :
/etc/shadowsocks-python/config.json
ShadowsocksR
/etc/shadowsocks-r/config.json
Shadowsocks-Go
/etc/shadowsocks-go/config.json
Shadowsocks-libev
/etc/shadowsocks-libev/config.json
ShadowsocksR
/etc/shadowsocks-r/config.json
****
**CiphersPython and libev:**
**Cipherslibev:**
aes-256-gcm
aes-192-gcm
aes-128-gcm
@ -66,15 +54,6 @@ camellia-256-cfb
chacha20-ietf-poly1305
chacha20-ietf
**CiphersGo:**
aes-256-cfb
aes-192-cfb
aes-128-cfb
aes-256-ctr
aes-192-ctr
aes-128-ctr
chacha20-ietf
**ciphersnone means unencryptedShadowsocksR:**
none
aes-256-cfb

View file

@ -1,97 +0,0 @@
#!/bin/bash
# chkconfig: 2345 90 10
# description: A secure socks5 proxy, designed to protect your Internet traffic.
### BEGIN INIT INFO
# Provides: Shadowsocks
# Required-Start: $network $syslog
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Fast tunnel proxy that helps you bypass firewalls
# Description: Start or stop the Shadowsocks server
### END INIT INFO
# Author: Teddysun <i@teddysun.com>
NAME=Shadowsocks
if [ -f /usr/bin/ssserver ]; then
DAEMON=/usr/bin/ssserver
elif [ -f /usr/local/bin/ssserver ]; then
DAEMON=/usr/local/bin/ssserver
fi
if [ -f /etc/shadowsocks-python/config.json ]; then
CONF=/etc/shadowsocks-python/config.json
elif [ -f /etc/shadowsocks.json ]; then
CONF=/etc/shadowsocks.json
fi
RETVAL=0
check_running() {
PID=$(ps -ef | grep -v grep | grep -i "${DAEMON}" | awk '{print $2}')
if [ -n "$PID" ]; then
return 0
else
return 1
fi
}
do_start() {
check_running
if [ $? -eq 0 ]; then
echo "$NAME (pid $PID) is already running..."
exit 0
else
$DAEMON -c $CONF -d start
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "Starting $NAME success"
else
echo "Starting $NAME failed"
fi
fi
}
do_stop() {
check_running
if [ $? -eq 0 ]; then
$DAEMON -c $CONF -d stop
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "Stopping $NAME success"
else
echo "Stopping $NAME failed"
fi
else
echo "$NAME is stopped"
RETVAL=1
fi
}
do_status() {
check_running
if [ $? -eq 0 ]; then
echo "$NAME (pid $PID) is running..."
else
echo "$NAME is stopped"
RETVAL=1
fi
}
do_restart() {
do_stop
sleep 0.5
do_start
}
case "$1" in
start | stop | restart | status)
do_$1
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
RETVAL=1
;;
esac
exit $RETVAL

View file

@ -38,7 +38,7 @@ plain='\033[0m'
[[ $EUID -ne 0 ]] && echo -e "[${red}Error${plain}] This script must be run as root!" && exit 1
cur_dir=$(pwd)
software=(Shadowsocks-Python ShadowsocksR Shadowsocks-Go Shadowsocks-libev)
software=(Shadowsocks-libev ShadowsocksR)
libsodium_file="libsodium-1.0.18"
libsodium_url="https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz"
@ -46,12 +46,11 @@ libsodium_url="https://github.com/jedisct1/libsodium/releases/download/1.0.18-RE
mbedtls_file="mbedtls-2.16.3"
mbedtls_url="https://tls.mbed.org/download/mbedtls-2.16.3-gpl.tgz"
shadowsocks_python_file="shadowsocks-master"
shadowsocks_python_url="https://github.com/shadowsocks/shadowsocks/archive/master.zip"
shadowsocks_python_init="/etc/init.d/shadowsocks-python"
shadowsocks_python_config="/etc/shadowsocks-python/config.json"
shadowsocks_python_centos="https://raw.githubusercontent.com/Yuk1n0/Shadowsocks-Install/master/shadowsocks"
shadowsocks_python_debian="https://raw.githubusercontent.com/Yuk1n0/Shadowsocks-Install/master/shadowsocks-debian"
shadowsocks_libev_init="/etc/init.d/shadowsocks-libev"
shadowsocks_libev_config="/etc/shadowsocks-libev/config.json"
shadowsocks_libev_centos="https://raw.githubusercontent.com/Yuk1n0/Shadowsocks-Install/master/shadowsocks-libev"
shadowsocks_libev_debian="https://raw.githubusercontent.com/Yuk1n0/Shadowsocks-Install/master/shadowsocks-libev-debian"
v2ray_file=$(wget -qO- https://api.github.com/repos/shadowsocks/v2ray-plugin/releases/latest | grep linux-amd64 | grep name | cut -f4 -d\")
shadowsocks_r_file="shadowsocksr-3.2.2"
shadowsocks_r_url="https://github.com/shadowsocksrr/shadowsocksr/archive/3.2.2.tar.gz"
@ -60,21 +59,6 @@ shadowsocks_r_config="/etc/shadowsocks-r/config.json"
shadowsocks_r_centos="https://raw.githubusercontent.com/Yuk1n0/Shadowsocks-Install/master/shadowsocksR"
shadowsocks_r_debian="https://raw.githubusercontent.com/Yuk1n0/Shadowsocks-Install/master/shadowsocksR-debian"
shadowsocks_go_file_64="shadowsocks-server-linux64-1.2.2"
shadowsocks_go_url_64="https://dl.lamp.sh/shadowsocks/shadowsocks-server-linux64-1.2.2.gz"
shadowsocks_go_file_32="shadowsocks-server-linux32-1.2.2"
shadowsocks_go_url_32="https://dl.lamp.sh/shadowsocks/shadowsocks-server-linux32-1.2.2.gz"
shadowsocks_go_init="/etc/init.d/shadowsocks-go"
shadowsocks_go_config="/etc/shadowsocks-go/config.json"
shadowsocks_go_centos="https://raw.githubusercontent.com/Yuk1n0/Shadowsocks-Install/master/shadowsocks-go"
shadowsocks_go_debian="https://raw.githubusercontent.com/Yuk1n0/Shadowsocks-Install/master/shadowsocks-go-debian"
shadowsocks_libev_init="/etc/init.d/shadowsocks-libev"
shadowsocks_libev_config="/etc/shadowsocks-libev/config.json"
shadowsocks_libev_centos="https://raw.githubusercontent.com/Yuk1n0/Shadowsocks-Install/master/shadowsocks-libev"
shadowsocks_libev_debian="https://raw.githubusercontent.com/Yuk1n0/Shadowsocks-Install/master/shadowsocks-libev-debian"
v2ray_file=$(wget -qO- https://api.github.com/repos/shadowsocks/v2ray-plugin/releases/latest | grep linux-amd64 | grep name | cut -f4 -d\")
# Stream Ciphers
common_ciphers=(
aes-256-gcm
@ -93,15 +77,6 @@ common_ciphers=(
chacha20-ietf-poly1305
chacha20-ietf
)
go_ciphers=(
aes-256-cfb
aes-192-cfb
aes-128-cfb
aes-256-ctr
aes-192-ctr
aes-128-ctr
chacha20-ietf
)
r_ciphers=(
none
aes-256-cfb
@ -306,15 +281,6 @@ get_opsy() {
[ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
}
# shadowsocks-go
is_64bit() {
if [ $(getconf WORD_BIT) = '32' ] && [ $(getconf LONG_BIT) = '64' ]; then
return 0
else
return 1
fi
}
debianversion() {
if check_sys sysRelease debian; then
local version=$(get_opsy)
@ -346,33 +312,7 @@ download() {
download_files() {
cd ${cur_dir}
if [ "${selected}" == "1" ]; then
download "${shadowsocks_python_file}.zip" "${shadowsocks_python_url}"
if check_sys packageManager yum; then
download "${shadowsocks_python_init}" "${shadowsocks_python_centos}"
elif check_sys packageManager apt; then
download "${shadowsocks_python_init}" "${shadowsocks_python_debian}"
fi
elif [ "${selected}" == "2" ]; then
download "${shadowsocks_r_file}.tar.gz" "${shadowsocks_r_url}"
if check_sys packageManager yum; then
download "${shadowsocks_r_init}" "${shadowsocks_r_centos}"
elif check_sys packageManager apt; then
download "${shadowsocks_r_init}" "${shadowsocks_r_debian}"
fi
elif [ "${selected}" == "3" ]; then
if is_64bit; then
download "${shadowsocks_go_file_64}.gz" "${shadowsocks_go_url_64}"
else
download "${shadowsocks_go_file_32}.gz" "${shadowsocks_go_url_32}"
fi
if check_sys packageManager yum; then
download "${shadowsocks_go_init}" "${shadowsocks_go_centos}"
elif check_sys packageManager apt; then
download "${shadowsocks_go_init}" "${shadowsocks_go_debian}"
fi
elif [ "${selected}" == "4" ]; then
get_libev_ver
shadowsocks_libev_file="shadowsocks-libev-$(echo ${libev_ver} | sed -e 's/^[a-zA-Z]//g')"
shadowsocks_libev_url="https://github.com/shadowsocks/shadowsocks-libev/releases/download/${libev_ver}/${shadowsocks_libev_file}.tar.gz"
@ -383,8 +323,14 @@ download_files() {
elif check_sys packageManager apt; then
download "${shadowsocks_libev_init}" "${shadowsocks_libev_debian}"
fi
elif [ "${selected}" == "2" ]; then
download "${shadowsocks_r_file}.tar.gz" "${shadowsocks_r_url}"
if check_sys packageManager yum; then
download "${shadowsocks_r_init}" "${shadowsocks_r_centos}"
elif check_sys packageManager apt; then
download "${shadowsocks_r_init}" "${shadowsocks_r_debian}"
fi
fi
}
get_char() {
@ -448,60 +394,6 @@ config_shadowsocks() {
fi
if [ "${selected}" == "1" ]; then
if [ ! -d "$(dirname ${shadowsocks_python_config})" ]; then
mkdir -p $(dirname ${shadowsocks_python_config})
fi
cat >${shadowsocks_python_config} <<-EOF
{
"server":"0.0.0.0",
"server_port":${shadowsocksport},
"local_address":"127.0.0.1",
"local_port":1080,
"password":"${shadowsockspwd}",
"timeout":300,
"method":"${shadowsockscipher}",
"fast_open":${fast_open}
}
EOF
elif [ "${selected}" == "2" ]; then
if [ ! -d "$(dirname ${shadowsocks_r_config})" ]; then
mkdir -p $(dirname ${shadowsocks_r_config})
fi
cat >${shadowsocks_r_config} <<-EOF
{
"server":"0.0.0.0",
"server_ipv6":"::",
"server_port":${shadowsocksport},
"local_address":"127.0.0.1",
"local_port":1080,
"password":"${shadowsockspwd}",
"timeout":120,
"method":"${shadowsockscipher}",
"protocol":"${shadowsockprotocol}",
"protocol_param":"",
"obfs":"${shadowsockobfs}",
"obfs_param":"",
"redirect":"",
"dns_ipv6":false,
"fast_open":${fast_open},
"workers":1
}
EOF
elif [ "${selected}" == "3" ]; then
if [ ! -d "$(dirname ${shadowsocks_go_config})" ]; then
mkdir -p $(dirname ${shadowsocks_go_config})
fi
cat >${shadowsocks_go_config} <<-EOF
{
"server":"0.0.0.0",
"server_port":${shadowsocksport},
"local_port":1080,
"password":"${shadowsockspwd}",
"method":"${shadowsockscipher}",
"timeout":300
}
EOF
elif [ "${selected}" == "4" ]; then
local server_value="\"0.0.0.0\""
if get_ipv6; then
server_value="[\"[::0]\",\"0.0.0.0\"]"
@ -556,6 +448,30 @@ EOF
EOF
fi
elif [ "${selected}" == "2" ]; then
if [ ! -d "$(dirname ${shadowsocks_r_config})" ]; then
mkdir -p $(dirname ${shadowsocks_r_config})
fi
cat >${shadowsocks_r_config} <<-EOF
{
"server":"0.0.0.0",
"server_ipv6":"::",
"server_port":${shadowsocksport},
"local_address":"127.0.0.1",
"local_port":1080,
"password":"${shadowsockspwd}",
"timeout":120,
"method":"${shadowsockscipher}",
"protocol":"${shadowsockprotocol}",
"protocol_param":"",
"obfs":"${shadowsockobfs}",
"obfs_param":"",
"redirect":"",
"dns_ipv6":false,
"fast_open":${fast_open},
"workers":1
}
EOF
fi
}
@ -619,19 +535,19 @@ install_select() {
echo -e "${green}${i}${plain}) ${hint}"
done
read -p "Please enter a number (Default ${software[3]}):" selected
[ -z "${selected}" ] && selected="4"
[ -z "${selected}" ] && selected="1"
case "${selected}" in
1 | 2 | 3 | 4)
1 | 2)
echo
echo "You choose = ${software[${selected} - 1]}"
if [ "${selected}" == "4" ]; then
if [ "${selected}" == "1" ]; then
echo -e "[${green}Info${plain}] Current official Shadowsocks-libev Version:${libev_ver}"
fi
echo
break
;;
*)
echo -e "[${red}Error${plain}] Please only enter a number [1-4]"
echo -e "[${red}Error${plain}] Please only enter a number [1-2]"
;;
esac
done
@ -639,8 +555,8 @@ install_select() {
install_prepare_password() {
echo "Please enter password for ${software[${selected} - 1]}"
read -p "(Default password: teddysun.com):" shadowsockspwd
[ -z "${shadowsockspwd}" ] && shadowsockspwd="teddysun.com"
read -p "(Default password: shadowsocks):" shadowsockspwd
[ -z "${shadowsockspwd}" ] && shadowsockspwd="shadowsocks"
echo
echo "password = ${shadowsockspwd}"
echo
@ -669,7 +585,7 @@ install_prepare_cipher() {
while true; do
echo -e "Please select stream cipher for ${software[${selected} - 1]}:"
if [[ "${selected}" == "1" || "${selected}" == "4" ]]; then
if [ "${selected}" == "1" ]; then
for ((i = 1; i <= ${#common_ciphers[@]}; i++)); do
hint="${common_ciphers[$i - 1]}"
echo -e "${green}${i}${plain}) ${hint}"
@ -703,23 +619,6 @@ install_prepare_cipher() {
continue
fi
shadowsockscipher=${r_ciphers[$pick - 1]}
elif [ "${selected}" == "3" ]; then
for ((i = 1; i <= ${#go_ciphers[@]}; i++)); do
hint="${go_ciphers[$i - 1]}"
echo -e "${green}${i}${plain}) ${hint}"
done
read -p "Which cipher you'd select(Default: ${go_ciphers[0]}):" pick
[ -z "$pick" ] && pick=1
expr ${pick} + 1 &>/dev/null
if [ $? -ne 0 ]; then
echo -e "[${red}Error${plain}] Please enter a number"
continue
fi
if [[ "$pick" -lt 1 || "$pick" -gt ${#go_ciphers[@]} ]]; then
echo -e "[${red}Error${plain}] Please enter a number between 1 and ${#go_ciphers[@]}"
continue
fi
shadowsockscipher=${go_ciphers[$pick - 1]}
fi
echo
@ -883,14 +782,12 @@ get_cert() {
}
install_prepare() {
if [[ "${selected}" == "1" || "${selected}" == "3" || "${selected}" == "4" ]]; then
if [ "${selected}" == "1" ]; then
install_prepare_password
install_prepare_port
install_prepare_cipher
if [ "${selected}" == "4" ]; then
install_prepare_libev_obfs
install_prepare_domain
fi
install_prepare_libev_obfs
install_prepare_domain
elif [ "${selected}" == "2" ]; then
install_prepare_password
install_prepare_port
@ -938,21 +835,14 @@ install_mbedtls() {
fi
}
install_shadowsocks_python() {
install_shadowsocks_libev() {
cd ${cur_dir}
unzip -q ${shadowsocks_python_file}.zip
if [ $? -ne 0 ]; then
echo -e "[${red}Error${plain}] unzip ${shadowsocks_python_file}.zip failed, please check unzip command."
install_cleanup
exit 1
fi
cd ${shadowsocks_python_file}
python setup.py install --record /usr/local/shadowsocks_python.log
if [ -f /usr/bin/ssserver ] || [ -f /usr/local/bin/ssserver ]; then
chmod +x ${shadowsocks_python_init}
local service_name=$(basename ${shadowsocks_python_init})
tar zxf ${shadowsocks_libev_file}.tar.gz
cd ${shadowsocks_libev_file}
./configure --disable-documentation && make && make install
if [ $? -eq 0 ]; then
chmod +x ${shadowsocks_libev_init}
local service_name=$(basename ${shadowsocks_libev_init})
if check_sys packageManager yum; then
chkconfig --add ${service_name}
chkconfig ${service_name} on
@ -961,7 +851,7 @@ install_shadowsocks_python() {
fi
else
echo
echo -e "[${red}Error${plain}] ${software[0]} install failed."
echo -e "[${red}Error${plain}] ${software[3]} install failed."
install_cleanup
exit 1
fi
@ -988,67 +878,6 @@ install_shadowsocks_r() {
fi
}
install_shadowsocks_go() {
cd ${cur_dir}
if is_64bit; then
gzip -d ${shadowsocks_go_file_64}.gz
if [ $? -ne 0 ]; then
echo -e "[${red}Error${plain}] Decompress ${shadowsocks_go_file_64}.gz failed."
install_cleanup
exit 1
fi
mv -f ${shadowsocks_go_file_64} /usr/bin/shadowsocks-server
else
gzip -d ${shadowsocks_go_file_32}.gz
if [ $? -ne 0 ]; then
echo -e "[${red}Error${plain}] Decompress ${shadowsocks_go_file_32}.gz failed."
install_cleanup
exit 1
fi
mv -f ${shadowsocks_go_file_32} /usr/bin/shadowsocks-server
fi
if [ -f /usr/bin/shadowsocks-server ]; then
chmod +x /usr/bin/shadowsocks-server
chmod +x ${shadowsocks_go_init}
local service_name=$(basename ${shadowsocks_go_init})
if check_sys packageManager yum; then
chkconfig --add ${service_name}
chkconfig ${service_name} on
elif check_sys packageManager apt; then
update-rc.d -f ${service_name} defaults
fi
else
echo
echo -e "[${red}Error${plain}] ${software[2]} install failed."
install_cleanup
exit 1
fi
}
install_shadowsocks_libev() {
cd ${cur_dir}
tar zxf ${shadowsocks_libev_file}.tar.gz
cd ${shadowsocks_libev_file}
./configure --disable-documentation && make && make install
if [ $? -eq 0 ]; then
chmod +x ${shadowsocks_libev_init}
local service_name=$(basename ${shadowsocks_libev_init})
if check_sys packageManager yum; then
chkconfig --add ${service_name}
chkconfig ${service_name} on
elif check_sys packageManager apt; then
update-rc.d -f ${service_name} defaults
fi
else
echo
echo -e "[${red}Error${plain}] ${software[3]} install failed."
install_cleanup
exit 1
fi
}
install_shadowsocks_libev_obfs() {
if [ "${libev_obfs}" == "y" ] || [ "${libev_obfs}" == "Y" ]; then
cd ${cur_dir}
@ -1100,41 +929,6 @@ install_shadowsocks_libev_v2ray_plugin() {
fi
}
install_completed_python() {
clear
${shadowsocks_python_init} start
echo
echo -e "Congratulations, ${green}${software[0]}${plain} server install completed!"
echo -e "Your Server IP : ${red} $(get_ip) ${plain}"
echo -e "Your Server Port : ${red} ${shadowsocksport} ${plain}"
echo -e "Your Password : ${red} ${shadowsockspwd} ${plain}"
echo -e "Your Encryption Method: ${red} ${shadowsockscipher} ${plain}"
}
install_completed_r() {
clear
${shadowsocks_r_init} start
echo
echo -e "Congratulations, ${green}${software[1]}${plain} server install completed!"
echo -e "Your Server IP : ${red} $(get_ip) ${plain}"
echo -e "Your Server Port : ${red} ${shadowsocksport} ${plain}"
echo -e "Your Password : ${red} ${shadowsockspwd} ${plain}"
echo -e "Your Protocol : ${red} ${shadowsockprotocol} ${plain}"
echo -e "Your obfs : ${red} ${shadowsockobfs} ${plain}"
echo -e "Your Encryption Method: ${red} ${shadowsockscipher} ${plain}"
}
install_completed_go() {
clear
${shadowsocks_go_init} start
echo
echo -e "Congratulations, ${green}${software[2]}${plain} server install completed!"
echo -e "Your Server IP : ${red} $(get_ip) ${plain}"
echo -e "Your Server Port : ${red} ${shadowsocksport} ${plain}"
echo -e "Your Password : ${red} ${shadowsockspwd} ${plain}"
echo -e "Your Encryption Method: ${red} ${shadowsockscipher} ${plain}"
}
install_completed_libev() {
clear
ldconfig
@ -1158,16 +952,29 @@ install_completed_libev() {
echo -e "Your Encryption Method: ${red} ${shadowsockscipher} ${plain}"
}
qr_generate_python() {
install_completed_r() {
clear
${shadowsocks_r_init} start
echo
echo -e "Congratulations, ${green}${software[1]}${plain} server install completed!"
echo -e "Your Server IP : ${red} $(get_ip) ${plain}"
echo -e "Your Server Port : ${red} ${shadowsocksport} ${plain}"
echo -e "Your Password : ${red} ${shadowsockspwd} ${plain}"
echo -e "Your Protocol : ${red} ${shadowsockprotocol} ${plain}"
echo -e "Your obfs : ${red} ${shadowsockobfs} ${plain}"
echo -e "Your Encryption Method: ${red} ${shadowsockscipher} ${plain}"
}
qr_generate_libev() {
if [ "$(command -v qrencode)" ]; then
local tmp=$(echo -n "${shadowsockscipher}:${shadowsockspwd}@$(get_ip):${shadowsocksport}" | base64 -w0)
local qr_code="ss://${tmp}"
echo
echo "Your QR Code: (For Shadowsocks Windows, OSX, Android and iOS clients)"
echo -e "${green} ${qr_code} ${plain}"
echo -n "${qr_code}" | qrencode -s8 -o ${cur_dir}/shadowsocks_python_qr.png
echo -n "${qr_code}" | qrencode -s8 -o ${cur_dir}/shadowsocks_libev_qr.png
echo "Your QR Code has been saved as a PNG file path:"
echo -e "${green} ${cur_dir}/shadowsocks_python_qr.png ${plain}"
echo -e "${green} ${cur_dir}/shadowsocks_libev_qr.png ${plain}"
fi
}
@ -1185,32 +992,6 @@ qr_generate_r() {
fi
}
qr_generate_go() {
if [ "$(command -v qrencode)" ]; then
local tmp=$(echo -n "${shadowsockscipher}:${shadowsockspwd}@$(get_ip):${shadowsocksport}" | base64 -w0)
local qr_code="ss://${tmp}"
echo
echo "Your QR Code: (For Shadowsocks Windows, OSX, Android and iOS clients)"
echo -e "${green} ${qr_code} ${plain}"
echo -n "${qr_code}" | qrencode -s8 -o ${cur_dir}/shadowsocks_go_qr.png
echo "Your QR Code has been saved as a PNG file path:"
echo -e "${green} ${cur_dir}/shadowsocks_go_qr.png ${plain}"
fi
}
qr_generate_libev() {
if [ "$(command -v qrencode)" ]; then
local tmp=$(echo -n "${shadowsockscipher}:${shadowsockspwd}@$(get_ip):${shadowsocksport}" | base64 -w0)
local qr_code="ss://${tmp}"
echo
echo "Your QR Code: (For Shadowsocks Windows, OSX, Android and iOS clients)"
echo -e "${green} ${qr_code} ${plain}"
echo -n "${qr_code}" | qrencode -s8 -o ${cur_dir}/shadowsocks_libev_qr.png
echo "Your QR Code has been saved as a PNG file path:"
echo -e "${green} ${cur_dir}/shadowsocks_libev_qr.png ${plain}"
fi
}
install_main() {
install_libsodium
if ! ldconfig -p | grep -wq "/usr/lib"; then
@ -1219,24 +1000,16 @@ install_main() {
ldconfig
if [ "${selected}" == "1" ]; then
install_shadowsocks_python
install_completed_python
qr_generate_python
elif [ "${selected}" == "2" ]; then
install_shadowsocks_r
install_completed_r
qr_generate_r
elif [ "${selected}" == "3" ]; then
install_shadowsocks_go
install_completed_go
qr_generate_go
elif [ "${selected}" == "4" ]; then
install_mbedtls
install_shadowsocks_libev
install_shadowsocks_libev_obfs
install_shadowsocks_libev_v2ray_plugin
install_completed_libev
qr_generate_libev
elif [ "${selected}" == "2" ]; then
install_shadowsocks_r
install_completed_r
qr_generate_r
fi
echo
@ -1249,10 +1022,8 @@ install_cleanup() {
rm -rf simple-obfs
rm -rf ${libsodium_file} ${libsodium_file}.tar.gz
rm -rf ${mbedtls_file} ${mbedtls_file}-gpl.tgz
rm -rf ${shadowsocks_python_file} ${shadowsocks_python_file}.zip
rm -rf ${shadowsocks_r_file} ${shadowsocks_r_file}.tar.gz
rm -rf ${shadowsocks_go_file_64}.gz ${shadowsocks_go_file_32}.gz
rm -rf ${shadowsocks_libev_file} ${shadowsocks_libev_file}.tar.gz
rm -rf ${shadowsocks_r_file} ${shadowsocks_r_file}.tar.gz
rm -rf $v2ray_file
}
@ -1270,90 +1041,6 @@ install_shadowsocks() {
install_cleanup
}
uninstall_shadowsocks_python() {
printf "Are you sure uninstall ${red}${software[0]}${plain}? [y/n]\n"
read -p "(default: n):" answer
[ -z ${answer} ] && answer="n"
if [ "${answer}" == "y" ] || [ "${answer}" == "Y" ]; then
${shadowsocks_python_init} status >/dev/null 2>&1
if [ $? -eq 0 ]; then
${shadowsocks_python_init} stop
fi
local service_name=$(basename ${shadowsocks_python_init})
if check_sys packageManager yum; then
chkconfig --del ${service_name}
elif check_sys packageManager apt; then
update-rc.d -f ${service_name} remove
fi
rm -fr $(dirname ${shadowsocks_python_config})
rm -f ${shadowsocks_python_init}
rm -f /var/log/shadowsocks.log
if [ -f /usr/local/shadowsocks_python.log ]; then
cat /usr/local/shadowsocks_python.log | xargs rm -rf
rm -f /usr/local/shadowsocks_python.log
fi
echo -e "[${green}Info${plain}] ${software[0]} uninstall success"
else
echo
echo -e "[${green}Info${plain}] ${software[0]} uninstall cancelled, nothing to do..."
echo
fi
}
uninstall_shadowsocks_r() {
printf "Are you sure uninstall ${red}${software[1]}${plain}? [y/n]\n"
read -p "(default: n):" answer
[ -z ${answer} ] && answer="n"
if [ "${answer}" == "y" ] || [ "${answer}" == "Y" ]; then
${shadowsocks_r_init} status >/dev/null 2>&1
if [ $? -eq 0 ]; then
${shadowsocks_r_init} stop
fi
local service_name=$(basename ${shadowsocks_r_init})
if check_sys packageManager yum; then
chkconfig --del ${service_name}
elif check_sys packageManager apt; then
update-rc.d -f ${service_name} remove
fi
rm -fr $(dirname ${shadowsocks_r_config})
rm -f ${shadowsocks_r_init}
rm -f /var/log/shadowsocks.log
rm -fr /usr/local/shadowsocks
echo -e "[${green}Info${plain}] ${software[1]} uninstall success"
else
echo
echo -e "[${green}Info${plain}] ${software[1]} uninstall cancelled, nothing to do..."
echo
fi
}
uninstall_shadowsocks_go() {
printf "Are you sure uninstall ${red}${software[2]}${plain}? [y/n]\n"
read -p "(default: n):" answer
[ -z ${answer} ] && answer="n"
if [ "${answer}" == "y" ] || [ "${answer}" == "Y" ]; then
${shadowsocks_go_init} status >/dev/null 2>&1
if [ $? -eq 0 ]; then
${shadowsocks_go_init} stop
fi
local service_name=$(basename ${shadowsocks_go_init})
if check_sys packageManager yum; then
chkconfig --del ${service_name}
elif check_sys packageManager apt; then
update-rc.d -f ${service_name} remove
fi
rm -fr $(dirname ${shadowsocks_go_config})
rm -f ${shadowsocks_go_init}
rm -f /usr/bin/shadowsocks-server
echo -e "[${green}Info${plain}] ${software[2]} uninstall success"
else
echo
echo -e "[${green}Info${plain}] ${software[2]} uninstall cancelled, nothing to do..."
echo
fi
}
uninstall_shadowsocks_libev() {
printf "Are you sure uninstall ${red}${software[3]}${plain}? [y/n]\n"
read -p "(default: n):" answer
@ -1402,6 +1089,33 @@ uninstall_shadowsocks_libev() {
fi
}
uninstall_shadowsocks_r() {
printf "Are you sure uninstall ${red}${software[1]}${plain}? [y/n]\n"
read -p "(default: n):" answer
[ -z ${answer} ] && answer="n"
if [ "${answer}" == "y" ] || [ "${answer}" == "Y" ]; then
${shadowsocks_r_init} status >/dev/null 2>&1
if [ $? -eq 0 ]; then
${shadowsocks_r_init} stop
fi
local service_name=$(basename ${shadowsocks_r_init})
if check_sys packageManager yum; then
chkconfig --del ${service_name}
elif check_sys packageManager apt; then
update-rc.d -f ${service_name} remove
fi
rm -fr $(dirname ${shadowsocks_r_config})
rm -f ${shadowsocks_r_init}
rm -f /var/log/shadowsocks.log
rm -fr /usr/local/shadowsocks
echo -e "[${green}Info${plain}] ${software[1]} uninstall success"
else
echo
echo -e "[${green}Info${plain}] ${software[1]} uninstall cancelled, nothing to do..."
echo
fi
}
uninstall_shadowsocks() {
while true; do
echo "Which Shadowsocks server you want to uninstall?"
@ -1409,23 +1123,23 @@ uninstall_shadowsocks() {
hint="${software[$i - 1]}"
echo -e "${green}${i}${plain}) ${hint}"
done
read -p "Please enter a number [1-4]:" un_select
read -p "Please enter a number [1-2]:" un_select
case "${un_select}" in
1 | 2 | 3 | 4)
1 | 2)
echo
echo "You choose = ${software[${un_select} - 1]}"
echo
break
;;
*)
echo -e "[${red}Error${plain}] Please only enter a number [1-4]"
echo -e "[${red}Error${plain}] Please only enter a number [1-2]"
;;
esac
done
if [ "${un_select}" == "1" ]; then
if [ -f ${shadowsocks_python_init} ]; then
uninstall_shadowsocks_python
if [ -f ${shadowsocks_libev_init} ]; then
uninstall_shadowsocks_libev
else
echo -e "[${red}Error${plain}] ${software[${un_select} - 1]} not installed, please check it and try again."
echo
@ -1439,22 +1153,6 @@ uninstall_shadowsocks() {
echo
exit 1
fi
elif [ "${un_select}" == "3" ]; then
if [ -f ${shadowsocks_go_init} ]; then
uninstall_shadowsocks_go
else
echo -e "[${red}Error${plain}] ${software[${un_select} - 1]} not installed, please check it and try again."
echo
exit 1
fi
elif [ "${un_select}" == "4" ]; then
if [ -f ${shadowsocks_libev_init} ]; then
uninstall_shadowsocks_libev
else
echo -e "[${red}Error${plain}] ${software[${un_select} - 1]} not installed, please check it and try again."
echo
exit 1
fi
fi
}

View file

@ -1,95 +0,0 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: Shadowsocks
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Fast tunnel proxy that helps you bypass firewalls
# Description: Start or stop the Shadowsocks server
### END INIT INFO
# Author: Teddysun <i@teddysun.com>
NAME=Shadowsocks
if [ -f /usr/bin/ssserver ]; then
DAEMON=/usr/bin/ssserver
elif [ -f /usr/local/bin/ssserver ]; then
DAEMON=/usr/local/bin/ssserver
fi
if [ -f /etc/shadowsocks-python/config.json ]; then
CONF=/etc/shadowsocks-python/config.json
elif [ -f /etc/shadowsocks.json ]; then
CONF=/etc/shadowsocks.json
fi
RETVAL=0
check_running() {
PID=$(ps -ef | grep -v grep | grep -i "${DAEMON}" | awk '{print $2}')
if [ -n "$PID" ]; then
return 0
else
return 1
fi
}
do_start() {
check_running
if [ $? -eq 0 ]; then
echo "$NAME (pid $PID) is already running..."
exit 0
else
$DAEMON -c $CONF -d start
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "Starting $NAME success"
else
echo "Starting $NAME failed"
fi
fi
}
do_stop() {
check_running
if [ $? -eq 0 ]; then
$DAEMON -c $CONF -d stop
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "Stopping $NAME success"
else
echo "Stopping $NAME failed"
fi
else
echo "$NAME is stopped"
RETVAL=1
fi
}
do_status() {
check_running
if [ $? -eq 0 ]; then
echo "$NAME (pid $PID) is running..."
else
echo "$NAME is stopped"
RETVAL=1
fi
}
do_restart() {
do_stop
sleep 0.5
do_start
}
case "$1" in
start | stop | restart | status)
do_$1
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
RETVAL=1
;;
esac
exit $RETVAL

View file

@ -1,120 +0,0 @@
#!/bin/bash
# chkconfig: 2345 90 10
# description: A secure socks5 proxy, designed to protect your Internet traffic.
### BEGIN INIT INFO
# Provides: Shadowsocks-go
# Required-Start: $network $syslog
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Fast tunnel proxy that helps you bypass firewalls
# Description: Start or stop the Shadowsocks-go server
### END INIT INFO
# Author: Teddysun <i@teddysun.com>
# Source function library
. /etc/rc.d/init.d/functions
# Check that networking is up.
[ ${NETWORKING} ="yes" ] || exit 0
NAME=Shadowsocks-go
DAEMON=/usr/bin/shadowsocks-server
if [ -f /etc/shadowsocks-go/config.json ]; then
CONF=/etc/shadowsocks-go/config.json
elif [ -f /etc/shadowsocks/config.json ]; then
CONF=/etc/shadowsocks/config.json
fi
PID_DIR=/var/run
PID_FILE=$PID_DIR/shadowsocks-go.pid
RET_VAL=0
[ -x $DAEMON ] || exit 0
if [ ! -d $PID_DIR ]; then
mkdir -p $PID_DIR
if [ $? -ne 0 ]; then
echo "Creating PID directory $PID_DIR failed"
exit 1
fi
fi
if [ ! -f $CONF ]; then
echo "$NAME config file $CONF not found"
exit 1
fi
check_running() {
if [ -r $PID_FILE ]; then
read PID <$PID_FILE
if [ -d "/proc/$PID" ]; then
return 0
else
rm -f $PID_FILE
return 1
fi
else
return 2
fi
}
do_status() {
check_running
case $? in
0)
echo "$NAME (pid $PID) is running..."
;;
1 | 2)
echo "$NAME is stopped"
RET_VAL=1
;;
esac
}
do_start() {
if check_running; then
echo "$NAME (pid $PID) is already running..."
return 0
fi
$DAEMON -u -c $CONF 2>&1 >/dev/null &
PID=$!
echo $PID >$PID_FILE
sleep 0.3
if check_running; then
echo "Starting $NAME success"
else
echo "Starting $NAME failed"
RET_VAL=1
fi
}
do_stop() {
if check_running; then
kill -9 $PID
rm -f $PID_FILE
echo "Stopping $NAME success"
else
echo "$NAME is stopped"
RET_VAL=1
fi
}
do_restart() {
do_stop
sleep 0.5
do_start
}
case "$1" in
start | stop | restart | status)
do_$1
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
RET_VAL=1
;;
esac
exit $RET_VAL

View file

@ -1,112 +0,0 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: Shadowsocks-go
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Fast tunnel proxy that helps you bypass firewalls
# Description: Start or stop the Shadowsocks-go server
### END INIT INFO
# Author: Teddysun <i@teddysun.com>
NAME=Shadowsocks-go
DAEMON=/usr/bin/shadowsocks-server
if [ -f /etc/shadowsocks-go/config.json ]; then
CONF=/etc/shadowsocks-go/config.json
elif [ -f /etc/shadowsocks/config.json ]; then
CONF=/etc/shadowsocks/config.json
fi
PID_DIR=/var/run
PID_FILE=$PID_DIR/shadowsocks-go.pid
RET_VAL=0
[ -x $DAEMON ] || exit 0
if [ ! -d $PID_DIR ]; then
mkdir -p $PID_DIR
if [ $? -ne 0 ]; then
echo "Creating PID directory $PID_DIR failed"
exit 1
fi
fi
if [ ! -f $CONF ]; then
echo "$NAME config file $CONF not found"
exit 1
fi
check_running() {
if [ -r $PID_FILE ]; then
read PID <$PID_FILE
if [ -d "/proc/$PID" ]; then
return 0
else
rm -f $PID_FILE
return 1
fi
else
return 2
fi
}
do_status() {
check_running
case $? in
0)
echo "$NAME (pid $PID) is running..."
;;
1 | 2)
echo "$NAME is stopped"
RET_VAL=1
;;
esac
}
do_start() {
if check_running; then
echo "$NAME (pid $PID) is already running..."
return 0
fi
$DAEMON -u -c $CONF 2>&1 >/dev/null &
PID=$!
echo $PID >$PID_FILE
sleep 0.3
if check_running; then
echo "Starting $NAME success"
else
echo "Starting $NAME failed"
RET_VAL=1
fi
}
do_stop() {
if check_running; then
kill -9 $PID
rm -f $PID_FILE
echo "Stopping $NAME success"
else
echo "$NAME is stopped"
RET_VAL=1
fi
}
do_restart() {
do_stop
sleep 0.5
do_start
}
case "$1" in
start | stop | restart | status)
do_$1
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
RET_VAL=1
;;
esac
exit $RET_VAL