1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
| #!/bin/sh export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
#Check OS if [ -n "$(grep 'Aliyun Linux release' /etc/issue)" -o -e /etc/redhat-release ];then OS=CentOS [ -n "$(grep ' 7\.' /etc/redhat-release)" ] && CentOS_RHEL_version=7 [ -n "$(grep ' 6\.' /etc/redhat-release)" -o -n "$(grep 'Aliyun Linux release6 15' /etc/issue)" ] && CentOS_RHEL_version=6 [ -n "$(grep ' 5\.' /etc/redhat-release)" -o -n "$(grep 'Aliyun Linux release5' /etc/issue)" ] && CentOS_RHEL_version=5 elif [ -n "$(grep 'Amazon Linux AMI release' /etc/issue)" -o -e /etc/system-release ];then OS=CentOS CentOS_RHEL_version=6 elif [ -n "$(grep bian /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'Debian' ];then OS=Debian [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; } Debian_version=$(lsb_release -sr | awk -F. '{print $1}') elif [ -n "$(grep Deepin /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'Deepin' ];then OS=Debian [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; } Debian_version=$(lsb_release -sr | awk -F. '{print $1}') elif [ -n "$(grep Ubuntu /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'Ubuntu' -o -n "$(grep 'Linux Mint' /etc/issue)" ];then OS=Ubuntu [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; } Ubuntu_version=$(lsb_release -sr | awk -F. '{print $1}') [ -n "$(grep 'Linux Mint 18' /etc/issue)" ] && Ubuntu_version=16 else echo "Does not support this OS, Please contact the author! " kill -9 $$ fi
#Install Basic Tools if [[ ${OS} == Ubuntu ]];then echo "" echo "***********************" echo "*目前不支持Ubuntu系统!*" echo "*请使用CentOS搭建 *" echo "**********************" exit 0 apt-get install git unzip wget -y
fi if [[ ${OS} == CentOS ]];then
yum install git unzip wget -y
fi if [[ ${OS} == Debian ]];then echo "***********************" echo "*目前不支持Debian系统!*" echo "*请使用CentOS搭建 *" echo "**********************" apt-get install git unzip wget -y
fi
#1.清理旧环境和配置新环境 Clear(){ unInstall clear echo "旧环境清理完毕!" echo "" echo "安装Socks5所依赖的组件,请稍等..." yum -y install gcc gcc-c++ automake make pam-devel openldap-devel cyrus-sasl-devel openssl-devel yum update -y nss curl libcurl
#配置环境变量 sed -i '$a export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' ~/.bash_profile source ~/.bash_profile
#关闭防火墙 newVersion=`cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'` if [[ ${newVersion} = "7" ]] ; then systemctl stop firewalld systemctl disable firewalld
elif [[ ${newVersion} = "6" ]] ;then service iptables stop chkconfig iptables off else echo "Exception version" fi }
#2.下载Socks5服务 Download() { echo "" echo "下载Socks5服务中..." cd /root git clone https://github.com/wyx176/Socks5 }
#3.安装Socks5服务程序 InstallSock5() { echo "" echo "解压文件中..." cd /root/Socks5 tar zxvf ./ss5-3.8.9-8.tar.gz
echo "安装中..." cd /root/Socks5/ss5-3.8.9 ./configure make make install }
#4.安装控制面板配置参数 InstallPanel() { #cd /root/Socks5 mv /root/Socks5/service.sh /etc/opt/ss5/ mv /root/Socks5/user.sh /etc/opt/ss5/ mv /root/Socks5/version.txt /etc/opt/ss5/ mv /root/Socks5/ss5 /etc/sysconfig/ mv /root/Socks5/s5 /usr/local/bin/ chmod +x /usr/local/bin/s5
#设置默认用户名、默认开启帐号验证 uname="123456" upasswd="654321" port="5555" confFile=/etc/opt/ss5/ss5.conf echo -e $uname $upasswd >> /etc/opt/ss5/ss5.passwd sed -i '87c auth 0.0.0.0/0 - u' $confFile sed -i '203c permit u 0.0.0.0/0 - 0.0.0.0/0 - - - - -' $confFile
#添加开机启动 chmod +x /etc/init.d/ss5 chkconfig --add ss5 chkconfig --level 345 ss5 on confFile=/etc/rc.d/init.d/ss5 sed -i '/echo -n "Starting ss5... "/a if [ ! -d "/var/run/ss5/" ];then mkdir /var/run/ss5/; fi' $confFile sed -i '54c rm -rf /var/run/ss5/' $confFile sed -i '18c [[ ${NETWORKING} = "no" ]] && exit 0' $confFile
#判断ss5文件夹是否存在、 if [ ! -d "/var/run/ss5/" ];then mkdir /var/run/ss5/ echo "create ss5 success!" else echo "/ss5/ is OK!" fi }
#5.检测是否安装完整 check(){ cd /root rm -rf /root/Socks5 rm -rf /root/install.sh errorMsg="" isError=false if [ ! -f "/usr/local/bin/s5" ] ; then errorMsg=${errorMsg}"001|" isError=true
fi if [ ! -f "/etc/opt/ss5/service.sh" ]; then errorMsg=${errorMsg}"002|" isError=true
fi if [ ! -f "/etc/opt/ss5/user.sh" ]; then errorMsg=${errorMsg}"003|" isError=true fi
if [ ! -f "/etc/opt/ss5/ss5.conf" ]; then errorMsg=${errorMsg}"004|" isError=true fi
if [ "$isError" = "true" ] ; then unInstall clear echo "" echo "缺失文件,安装失败!!!" echo "错误提示:"${errorMsg} echo "发送邮件反馈bug :wyx176@gmail.com" echo "或者添加Telegram群反馈" echo "Telegram群:t.me/Socks55555" exit 0 else clear echo "" #service ss5 start if [[ ${newVersion} = "7" ]] ; then systemctl daemon-reload fi service ss5 start echo "" echo "Socks5安装完毕!" echo "" echo "输入"s5"启动Socks5控制面板" echo "" echo "默认用户名: "${uname} echo "默认密码 : "${upasswd} echo "默认端口 : "${port} echo "" echo "添加Telegram群组@Socks55555及时获取更新" echo "" exit 0 fi }
#6.卸载 unInstall(){ service ss5 stop rm -rf /run/ss5 rm -f /run/lock/subsys/ss5 rm -rf /etc/opt/ss5 rm -f /usr/local/bin/s5 rm -rf /usr/lib/ss5 rm -f /usr/sbin/ss5 rm -rf /usr/share/doc/ss5 rm -rf /root/ss5-3.8.9 rm -f /etc/sysconfig/ss5 rm -f /etc/rc.d/init.d/ss5 rm -f /etc/pam.d/ss5 rm -rf /var/log/ss5 }
Clear Download InstallSock5 InstallPanel check
|