update comment

This commit is contained in:
Teddysun 2016-09-17 18:08:24 +09:00
parent 00979d4afb
commit 8c1bd08aef
2 changed files with 67 additions and 79 deletions

View File

@ -22,14 +22,6 @@ echo
#Current folder #Current folder
cur_dir=`pwd` cur_dir=`pwd`
# Get public IP address
get_ip(){
local IP=$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1 )
[ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )
[ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip )
[ ! -z ${IP} ] && echo ${IP} || echo
}
# Make sure only root can run our script # Make sure only root can run our script
rootness(){ rootness(){
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
@ -38,6 +30,14 @@ rootness(){
fi fi
} }
# Disable selinux
disable_selinux(){
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
fi
}
#Check system #Check system
check_sys(){ check_sys(){
local checkType=$1 local checkType=$1
@ -109,12 +109,12 @@ centosversion(){
fi fi
} }
# Disable selinux # Get public IP address
disable_selinux(){ get_ip(){
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then local IP=$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1 )
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )
setenforce 0 [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip )
fi [ ! -z ${IP} ] && echo ${IP} || echo
} }
# Pre-installation settings # Pre-installation settings
@ -154,10 +154,10 @@ pre_install(){
echo echo
break break
else else
echo "Input error! Please input correct numbers." echo "Input error, please input correct number"
fi fi
else else
echo "Input error! Please input correct numbers." echo "Input error, please input correct number"
fi fi
done done
get_char(){ get_char(){
@ -174,8 +174,7 @@ pre_install(){
char=`get_char` char=`get_char`
#Install necessary dependencies #Install necessary dependencies
if check_sys packageManager yum; then if check_sys packageManager yum; then
yum install -y wget unzip openssl-devel gcc swig python python-devel python-setuptools autoconf libtool libevent yum install -y unzip openssl-devel gcc swig python python-devel python-setuptools autoconf libtool libevent automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel
yum install -y automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel
elif check_sys packageManager apt; then elif check_sys packageManager apt; then
apt-get -y update apt-get -y update
apt-get -y install python python-dev python-pip python-setuptools python-m2crypto curl wget unzip gcc swig automake make perl cpio build-essential apt-get -y install python python-dev python-pip python-setuptools python-m2crypto curl wget unzip gcc swig automake make perl cpio build-essential
@ -195,7 +194,7 @@ download_files(){
echo "Failed to download shadowsocks python file!" echo "Failed to download shadowsocks python file!"
exit 1 exit 1
fi fi
# Download Shadowsocks chkconfig file # Download Shadowsocks init script
if check_sys packageManager yum; then if check_sys packageManager yum; then
if ! wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks -O /etc/init.d/shadowsocks; then if ! wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks -O /etc/init.d/shadowsocks; then
echo "Failed to download shadowsocks chkconfig file!" echo "Failed to download shadowsocks chkconfig file!"
@ -225,7 +224,7 @@ config_shadowsocks(){
EOF EOF
} }
# firewall set # Firewall set
firewall_set(){ firewall_set(){
echo "firewall set start..." echo "firewall set start..."
if centosversion 6; then if centosversion 6; then
@ -265,10 +264,10 @@ firewall_set(){
} }
# Install Shadowsocks # Install Shadowsocks
install_ss(){ install(){
# Install libsodium # Install libsodium
tar zxf libsodium-1.0.11.tar.gz tar zxf libsodium-1.0.11.tar.gz
cd libsodium-1.0.11/ cd libsodium-1.0.11
./configure && make && make install ./configure && make && make install
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "libsodium install failed!" echo "libsodium install failed!"
@ -291,14 +290,12 @@ install_ss(){
if [ -f /usr/bin/ssserver ] || [ -f /usr/local/bin/ssserver ]; then if [ -f /usr/bin/ssserver ] || [ -f /usr/local/bin/ssserver ]; then
chmod +x /etc/init.d/shadowsocks chmod +x /etc/init.d/shadowsocks
# Add run on system start up
if check_sys packageManager yum; then if check_sys packageManager yum; then
chkconfig --add shadowsocks chkconfig --add shadowsocks
chkconfig shadowsocks on chkconfig shadowsocks on
elif check_sys packageManager apt; then elif check_sys packageManager apt; then
update-rc.d -f shadowsocks defaults update-rc.d -f shadowsocks defaults
fi fi
# Run shadowsocks in the background
/etc/init.d/shadowsocks start /etc/init.d/shadowsocks start
else else
echo echo
@ -306,6 +303,7 @@ install_ss(){
install_cleanup install_cleanup
exit 1 exit 1
fi fi
clear clear
echo echo
echo "Congratulations, shadowsocks server install completed!" echo "Congratulations, shadowsocks server install completed!"
@ -324,10 +322,7 @@ install_ss(){
# Install cleanup # Install cleanup
install_cleanup(){ install_cleanup(){
cd ${cur_dir} cd ${cur_dir}
rm -f shadowsocks-master.zip rm -rf shadowsocks-master.zip shadowsocks-master libsodium-1.0.11.tar.gz libsodium-1.0.11
rm -rf shadowsocks-master
rm -f libsodium-1.0.11.tar.gz
rm -rf libsodium-1.0.11
} }
# Uninstall Shadowsocks # Uninstall Shadowsocks
@ -356,7 +351,9 @@ uninstall_shadowsocks(){
fi fi
echo "Shadowsocks uninstall success!" echo "Shadowsocks uninstall success!"
else else
echo
echo "uninstall cancelled, nothing to do..." echo "uninstall cancelled, nothing to do..."
echo
fi fi
} }
@ -370,7 +367,7 @@ install_shadowsocks(){
if check_sys packageManager yum; then if check_sys packageManager yum; then
firewall_set firewall_set
fi fi
install_ss install
install_cleanup install_cleanup
} }
@ -378,11 +375,8 @@ install_shadowsocks(){
action=$1 action=$1
[ -z $1 ] && action=install [ -z $1 ] && action=install
case "$action" in case "$action" in
install) install|uninstall)
install_shadowsocks ${action}_shadowsocks
;;
uninstall)
uninstall_shadowsocks
;; ;;
*) *)
echo "Arguments error! [${action}]" echo "Arguments error! [${action}]"

View File

@ -22,14 +22,6 @@ echo
#Current folder #Current folder
cur_dir=`pwd` cur_dir=`pwd`
# Get public IP address
get_ip(){
local IP=$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1 )
[ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )
[ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip )
[ ! -z ${IP} ] && echo ${IP} || echo
}
# Make sure only root can run our script # Make sure only root can run our script
rootness(){ rootness(){
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
@ -38,6 +30,14 @@ rootness(){
fi fi
} }
# Disable selinux
disable_selinux(){
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
fi
}
#Check system #Check system
check_sys(){ check_sys(){
local checkType=$1 local checkType=$1
@ -109,12 +109,12 @@ centosversion(){
fi fi
} }
# Disable selinux # Get public IP address
disable_selinux(){ get_ip(){
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then local IP=$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1 )
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )
setenforce 0 [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip )
fi [ ! -z ${IP} ] && echo ${IP} || echo
} }
# Pre-installation settings # Pre-installation settings
@ -154,10 +154,10 @@ pre_install(){
echo echo
break break
else else
echo "Input error! Please input correct number." echo "Input error, please input correct number"
fi fi
else else
echo "Input error! Please input correct number." echo "Input error, please input correct number"
fi fi
done done
get_char(){ get_char(){
@ -174,8 +174,7 @@ pre_install(){
char=`get_char` char=`get_char`
# Install necessary dependencies # Install necessary dependencies
if check_sys packageManager yum; then if check_sys packageManager yum; then
yum install -y wget unzip openssl-devel gcc swig python python-devel python-setuptools autoconf libtool libevent yum install -y unzip openssl-devel gcc swig python python-devel python-setuptools autoconf libtool libevent automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel
yum install -y m2crypto automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel
elif check_sys packageManager apt; then elif check_sys packageManager apt; then
apt-get -y update apt-get -y update
apt-get -y install python python-dev python-pip python-m2crypto curl wget unzip gcc swig automake make perl cpio build-essential apt-get -y install python python-dev python-pip python-m2crypto curl wget unzip gcc swig automake make perl cpio build-essential
@ -195,7 +194,7 @@ download_files(){
echo "Failed to download ShadowsocksR file!" echo "Failed to download ShadowsocksR file!"
exit 1 exit 1
fi fi
# Download ShadowsocksR chkconfig file # Download ShadowsocksR init script
if check_sys packageManager yum; then if check_sys packageManager yum; then
if ! wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocksR -O /etc/init.d/shadowsocks; then if ! wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocksR -O /etc/init.d/shadowsocks; then
echo "Failed to download ShadowsocksR chkconfig file!" echo "Failed to download ShadowsocksR chkconfig file!"
@ -209,7 +208,7 @@ download_files(){
fi fi
} }
# firewall set # Firewall set
firewall_set(){ firewall_set(){
echo "firewall set start..." echo "firewall set start..."
if centosversion 6; then if centosversion 6; then
@ -273,10 +272,10 @@ EOF
} }
# Install ShadowsocksR # Install ShadowsocksR
install_ss(){ install(){
# Install libsodium # Install libsodium
tar zxf libsodium-1.0.11.tar.gz tar zxf libsodium-1.0.11.tar.gz
cd libsodium-1.0.11/ cd libsodium-1.0.11
./configure && make && make install ./configure && make && make install
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "libsodium install failed!" echo "libsodium install failed!"
@ -291,15 +290,14 @@ install_ss(){
mv shadowsocks-manyuser/shadowsocks /usr/local/ mv shadowsocks-manyuser/shadowsocks /usr/local/
if [ -f /usr/local/shadowsocks/server.py ]; then if [ -f /usr/local/shadowsocks/server.py ]; then
chmod +x /etc/init.d/shadowsocks chmod +x /etc/init.d/shadowsocks
# Add run on system start up
if check_sys packageManager yum; then if check_sys packageManager yum; then
chkconfig --add shadowsocks chkconfig --add shadowsocks
chkconfig shadowsocks on chkconfig shadowsocks on
elif check_sys packageManager apt; then elif check_sys packageManager apt; then
update-rc.d -f shadowsocks defaults update-rc.d -f shadowsocks defaults
fi fi
# Run ShadowsocksR in the background
/etc/init.d/shadowsocks start /etc/init.d/shadowsocks start
clear clear
echo echo
echo "Congratulations, ShadowsocksR install completed!" echo "Congratulations, ShadowsocksR install completed!"
@ -319,7 +317,7 @@ install_ss(){
echo "Enjoy it!" echo "Enjoy it!"
echo echo
else else
echo "Shadowsocks install failed! Please Email to Teddysun <i@teddysun.com> and contact." echo "ShadowsocksR install failed, please Email to Teddysun <i@teddysun.com> and contact"
install_cleanup install_cleanup
exit 1 exit 1
fi fi
@ -328,10 +326,7 @@ install_ss(){
# Install cleanup # Install cleanup
install_cleanup(){ install_cleanup(){
cd ${cur_dir} cd ${cur_dir}
rm -f manyuser.zip rm -rf manyuser.zip shadowsocks-manyuser libsodium-1.0.11.tar.gz libsodium-1.0.11
rm -rf shadowsocks-manyuser
rm -f libsodium-1.0.11.tar.gz
rm -rf libsodium-1.0.11
} }
@ -357,7 +352,9 @@ uninstall_shadowsocks(){
rm -rf /usr/local/shadowsocks rm -rf /usr/local/shadowsocks
echo "ShadowsocksR uninstall success!" echo "ShadowsocksR uninstall success!"
else else
echo
echo "uninstall cancelled, nothing to do..." echo "uninstall cancelled, nothing to do..."
echo
fi fi
} }
@ -368,7 +365,7 @@ install_shadowsocks(){
pre_install pre_install
download_files download_files
config_shadowsocks config_shadowsocks
install_ss install
if check_sys packageManager yum; then if check_sys packageManager yum; then
firewall_set firewall_set
fi fi
@ -379,11 +376,8 @@ install_shadowsocks(){
action=$1 action=$1
[ -z $1 ] && action=install [ -z $1 ] && action=install
case "$action" in case "$action" in
install) install|uninstall)
install_shadowsocks ${action}_shadowsocks
;;
uninstall)
uninstall_shadowsocks
;; ;;
*) *)
echo "Arguments error! [${action}]" echo "Arguments error! [${action}]"