Add support Debian & Ubuntu
This commit is contained in:
parent
642494ff31
commit
fc26dd616f
|
|
@ -2,15 +2,16 @@
|
||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
export PATH
|
export PATH
|
||||||
#===============================================================================================
|
#===============================================================================================
|
||||||
# System Required: CentOS 5.x & 6.x & 7 (32bit/64bit)
|
# System Required: CentOS, Debian, Ubuntu
|
||||||
# Description: Install Shadowsocks(go) for CentOS
|
# Description: One click Install Shadowsocks(go)
|
||||||
# Author: Teddysun <i@teddysun.com>
|
# Author: Teddysun <i@teddysun.com>
|
||||||
# Intro: http://teddysun.com/392.html
|
# Intro: http://teddysun.com/392.html
|
||||||
#===============================================================================================
|
#===============================================================================================
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
echo ""
|
||||||
echo "#############################################################"
|
echo "#############################################################"
|
||||||
echo "# Install Shadowsocks(go) for CentOS 5 or 6 or 7 (32bit/64bit)"
|
echo "# One click Install Shadowsocks(go)"
|
||||||
echo "# Intro: http://teddysun.com/392.html"
|
echo "# Intro: http://teddysun.com/392.html"
|
||||||
echo "#"
|
echo "#"
|
||||||
echo "# Author: Teddysun <i@teddysun.com>"
|
echo "# Author: Teddysun <i@teddysun.com>"
|
||||||
|
|
@ -26,6 +27,20 @@ if [[ $EUID -ne 0 ]]; then
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check OS
|
||||||
|
function checkos(){
|
||||||
|
if [ -f /etc/redhat-release ];then
|
||||||
|
OS=CentOS
|
||||||
|
elif [ ! -z "`cat /etc/issue | grep bian`" ];then
|
||||||
|
OS=Debian
|
||||||
|
elif [ ! -z "`cat /etc/issue | grep Ubuntu`" ];then
|
||||||
|
OS=Ubuntu
|
||||||
|
else
|
||||||
|
echo "Not supported OS, Please reinstall OS and retry!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Get version
|
# Get version
|
||||||
function getversion(){
|
function getversion(){
|
||||||
if [[ -s /etc/redhat-release ]];then
|
if [[ -s /etc/redhat-release ]];then
|
||||||
|
|
@ -87,12 +102,17 @@ function pre_install(){
|
||||||
echo "Press any key to start...or Press Ctrl+C to cancel"
|
echo "Press any key to start...or Press Ctrl+C to cancel"
|
||||||
char=`get_char`
|
char=`get_char`
|
||||||
#Install necessary dependencies
|
#Install necessary dependencies
|
||||||
|
if [ "$OS" == 'CentOS' ];then
|
||||||
yum install -y wget unzip gzip curl
|
yum install -y wget unzip gzip curl
|
||||||
|
else
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y wget unzip gzip curl
|
||||||
|
fi
|
||||||
# Get IP address
|
# Get IP address
|
||||||
echo "Getting Public IP address, Please wait a moment..."
|
echo "Getting Public IP address, Please wait a moment..."
|
||||||
IP=`curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1`
|
IP=$(curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1)
|
||||||
if [ $? -ne 0 -o -z $IP ]; then
|
if [ $? -ne 0 -o -z $IP ]; then
|
||||||
IP=`curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}'`
|
IP=$(curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}')
|
||||||
fi
|
fi
|
||||||
echo -e "Your main public IP is\t\033[32m$IP\033[0m"
|
echo -e "Your main public IP is\t\033[32m$IP\033[0m"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -132,10 +152,17 @@ function download_files(){
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download start script
|
# Download start script
|
||||||
|
if [ "$OS" == 'CentOS' ];then
|
||||||
if ! wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-go; then
|
if ! wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-go; then
|
||||||
echo "Failed to download shadowsocks-go start script!"
|
echo "Failed to download shadowsocks-go start script!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
if ! wget --no-check-certificate -O shadowsocks-go https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-go-debian; then
|
||||||
|
echo "Failed to download shadowsocks-go start script!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Config shadowsocks
|
# Config shadowsocks
|
||||||
|
|
@ -174,7 +201,7 @@ function iptables_set(){
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
function install(){
|
function install_go(){
|
||||||
# Install shadowsocks-go
|
# Install shadowsocks-go
|
||||||
if [ -s /usr/bin/shadowsocks-server ]; then
|
if [ -s /usr/bin/shadowsocks-server ]; then
|
||||||
echo "shadowsocks-go install success!"
|
echo "shadowsocks-go install success!"
|
||||||
|
|
@ -182,8 +209,12 @@ function install(){
|
||||||
mv $cur_dir/shadowsocks-go /etc/init.d/shadowsocks
|
mv $cur_dir/shadowsocks-go /etc/init.d/shadowsocks
|
||||||
chmod +x /etc/init.d/shadowsocks
|
chmod +x /etc/init.d/shadowsocks
|
||||||
# Add run on system start up
|
# Add run on system start up
|
||||||
|
if [ "$OS" == 'CentOS' ]; then
|
||||||
chkconfig --add shadowsocks
|
chkconfig --add shadowsocks
|
||||||
chkconfig shadowsocks on
|
chkconfig shadowsocks on
|
||||||
|
else
|
||||||
|
update-rc.d shadowsocks defaults
|
||||||
|
fi
|
||||||
# Start shadowsocks
|
# Start shadowsocks
|
||||||
/etc/init.d/shadowsocks start
|
/etc/init.d/shadowsocks start
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
|
|
@ -192,6 +223,7 @@ function install(){
|
||||||
echo "Shadowsocks-go start failure!"
|
echo "Shadowsocks-go start failure!"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
echo ""
|
||||||
echo "shadowsocks-go install failed!"
|
echo "shadowsocks-go install failed!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
@ -224,7 +256,12 @@ function uninstall_shadowsocks_go(){
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
/etc/init.d/shadowsocks stop
|
/etc/init.d/shadowsocks stop
|
||||||
fi
|
fi
|
||||||
|
checkos
|
||||||
|
if [ "$OS" == 'CentOS' ]; then
|
||||||
chkconfig --del shadowsocks
|
chkconfig --del shadowsocks
|
||||||
|
else
|
||||||
|
update-rc.d -f shadowsocks remove
|
||||||
|
fi
|
||||||
# delete config file
|
# delete config file
|
||||||
rm -rf /etc/shadowsocks
|
rm -rf /etc/shadowsocks
|
||||||
# delete shadowsocks
|
# delete shadowsocks
|
||||||
|
|
@ -238,15 +275,18 @@ function uninstall_shadowsocks_go(){
|
||||||
|
|
||||||
# Install Shadowsocks-go
|
# Install Shadowsocks-go
|
||||||
function install_shadowsocks_go(){
|
function install_shadowsocks_go(){
|
||||||
|
checkos
|
||||||
rootness
|
rootness
|
||||||
disable_selinux
|
disable_selinux
|
||||||
pre_install
|
pre_install
|
||||||
download_files
|
download_files
|
||||||
config_shadowsocks
|
config_shadowsocks
|
||||||
|
if [ "$OS" == 'CentOS' ]; then
|
||||||
if ! centosversion 7; then
|
if ! centosversion 7; then
|
||||||
iptables_set
|
iptables_set
|
||||||
fi
|
fi
|
||||||
install
|
fi
|
||||||
|
install_go
|
||||||
}
|
}
|
||||||
|
|
||||||
# Initialization step
|
# Initialization step
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user