├── LICENSE ├── README.md ├── shadowsocks.sh └── shadowsocks_new.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 wulabing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sspanel v3 glzjin 后端一键安装配置管理脚本 2 | 3 | * 适用于glzjin面板ssr后端的一键安装脚本 实现输入配置信息、以及全自动安装,配置一键修改,一键启动暂停等功能 支持 modwebapi 及 glzjinmod(mysql connect) 4 | * 旧版支持 Ubuntu14.04+ / Centos 6+ / Debian7+ 5 | * 新版(supervisor版本)支持 Ubuntu16.04+ / Centos 6+ / Debian 8+ 6 | * 默认安装目录:/root/shadowsocks 7 | * 请注意:4.0版本未经过严格的测试,若出现问题请及时提交 issue ,本人将会对相关内容进行排查,感谢理解 8 | * 由于零散更新,内容上出现部分代码冗余,会在未来进行部分代码重构 9 | 10 | # 安装方法 ( 2017/12/21 更新) 11 | ``` 12 | git clone https://github.com/wulabing/SSR-manyuser_glzjin_shell.git SSR 13 | 14 | cd SSR 15 | ``` 16 | 旧版本停止维护,目前不可用 17 | 18 | 新版本安装: 19 | ``` 20 | chmod +x shadowsocks_new.sh 21 | 22 | ./shadowsocks_new.sh install | tee ss.log 23 | 24 | chmod +x /root/shadowsocks/*.sh 25 | ``` 26 | # 相关目录 27 | 28 | 后端默认安装目录:`/root/shadowsocks` 29 | 30 | supervisor 默认配置目录 :`/etc/supervisor/conf.d/shadowsocks.conf (Centos:/etc/supervisord.conf)` 31 | 32 | # 启动方式() 33 | 34 | ### 旧版本: 35 | 36 | * 启动:`/root/shadowsocks/log.sh` 37 | * 启动(日志模式):`/root/shadowsocks/logrun.sh` 38 | * 停止:`/root/shadowsocks/stop.sh` 39 | * 日志:`/root/shadowsocks/tail.sh` 40 | 41 | ### 新版本: 42 | 43 | * 启动 shadowsocks :`./shadowsocks_new.sh start` 44 | * 停止 shadowsocks :`./shadowsocks_new.sh stop` 45 | * 重启 shadowsocks :`./shadowsocks_new.sh restart` 46 | * 强制停止 shadowsocks :`./shadowsocks_new.sh fstop` 47 | * 配置信息变更:`./shadowsocks_new.sh modify` 48 | * 添加 supervisor 开机启动: `systemctl enable supervisor (centos6:chkconfig --add supervisord)` 49 | * 日志 :`tail -f /var/log/sslog.txt` 50 | 51 | 52 | # 问题反馈 53 | 54 | 携带 ss.log 文件提交 issue 55 | 56 | # 更新 57 | ## 2017-12-21 58 | V4.0 59 | * 添加 基本init选项,可以直接通过脚本控制后端启动,暂停等基本功能 60 | * 添加 配置信息自助修改功能 61 | * 修复 细节性bug 62 | 63 | ## 2017-12-12 64 | V3.11 65 | * 修复 easy_install pip 出错后 python-pip 安装的逻辑错误 66 | 67 | ## 2017-12-10 68 | V3.1 69 | * 添加 部分选项默认配置 70 | * 修复 部分交互提示错误 71 | * 添加 Centos6 支持 72 | * 修复 部分bug 73 | 74 | ## 2017-12-10 75 | V3.0 76 | ### 从本版本开始 仅支持具有 Systemd 特性的发行版系统 并启用 shadowsocks_new.sh 更新,旧版本停止维护 77 | 78 | * 1.添加 supervisor 守护程序安装 79 | * 2.添加 选择列表,可以手动选择安装 SSR 或 supervisor 80 | * 3.修复 webapi模式下运行出现 no module named requests 的情况 (由于缺少 requests 模块) 81 | * 4.改善 部分交互内容 82 | 83 | ## 2017-08-09 84 | V2.1.2 85 | 86 | * 1.调整顺序。优先进行信息输入,然后进入安装流程 87 | 88 | ## 2017-07-29 89 | V2.1.1 90 | 91 | * 1.libsodium 版本由早期 1.0.10 调整至 1.0.13 92 | 93 | 94 | ## 2017-05-07 95 | V2.1 96 | 97 | * 1.修复因逻辑问题导致配置文件内容异常从而导致的运行报错 98 | * 2.修复由于 debian 源中有 deb cdrom 而导致的安装中断 99 | * 3.添加了禁用防火墙的相关内容 100 | 101 | V2.0 102 | 103 | * 1.实现输入配置信息、以及全自动安装,支持 modwebapi 及 glzjinmod(mysql connect) 104 | * 2.修复bug 105 | 106 | ## 2017-05-06 107 | V1.1 108 | 109 | * 1、自动进行相关依赖的安装,支持 ubuntu14.04+ / centos6+ /debian7+ 110 | 111 | -------------------------------------------------------------------------------- /shadowsocks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #==================================================== 4 | # System Request:Debian 7+/Ubuntu 14.04+/Centos 6+ 5 | # Author: wulabing 6 | # Dscription: SSR glzjin server for manyuser (only) 7 | # Version: 2.1 8 | # Blog: https://www.wulabing.com 9 | # Special thanks: Toyo 10 | #==================================================== 11 | 12 | sh_ver="2.1.1" 13 | libsodium_folder="/etc/libsodium" 14 | shadowsocks_install_folder="/root" 15 | shadowsocks_folder="${shadowsocks_install_folder}/shadowsocks" 16 | config="${shadowsocks_folder}/userapiconfig.py" 17 | debian_sourcelist="/etc/apt/source.list" 18 | 19 | #fonts color 20 | Green="\033[32m" 21 | Red="\033[31m" 22 | Yellow="\033[33m" 23 | GreenBG="\033[42;37m" 24 | RedBG="\033[41;37m" 25 | Font="\033[0m" 26 | 27 | 28 | #notification information 29 | Info="${Green}[Info]${Font}" 30 | OK="${Green}[OK]${Font}" 31 | Error="${Red}[Error]${Font}" 32 | Notification="${Yellow}[Notification]${Font}" 33 | 34 | check_system(){ 35 | if [[ -f /etc/redhat-system ]]; then 36 | system="centos" 37 | elif cat /etc/issue | grep -q -E -i "debian"; then 38 | system="debian" 39 | elif cat /etc/issue | grep -q -E -i "ubuntu"; then 40 | system="ubuntu" 41 | elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then 42 | system="centos" 43 | elif cat /proc/version | grep -q -E -i "debian"; then 44 | system="debian" 45 | elif cat /proc/version | grep -q -E -i "ubuntu"; then 46 | system="ubuntu" 47 | elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then 48 | system="centos" 49 | else 50 | system="other" 51 | fi 52 | } 53 | basic_installation(){ 54 | if [[ ${system} == "centos" ]]; then 55 | yum -y install vim tar wget git 56 | elif [[ ${system} == "debian" || ${system} == "ubuntu" ]]; then 57 | sed -i '/^deb cdrom/'d /etc/apt/sources.list 58 | apt-get update 59 | apt-get -y install vim tar wget git 60 | else 61 | echo -e "${Error} Don't support this System" 62 | exit 1 63 | fi 64 | } 65 | 66 | dependency_installation(){ 67 | if [[ ${system} == "centos" ]]; then 68 | yum -y install python-setuptools && easy_install pip 69 | yum -y install git 70 | elif [[ ${system} == "debian" || ${system} == "ubuntu" ]]; then 71 | apt-get -y install python-setuptools && easy_install pip 72 | apt-get -y install git 73 | fi 74 | 75 | } 76 | development_tools_installation(){ 77 | if [[ ${system} == "centos" ]]; then 78 | yum -y groupinstall "Development Tools" 79 | if [[ $? -ne 0 ]]; then 80 | echo -e "${Error} Development Tools installation FAIL" 81 | exit 1 82 | fi 83 | else 84 | apt-get -y install build-essential 85 | if [[ $? -ne 0 ]]; then 86 | echo -e "${Error} build-essential installation FAIL" 87 | exit 1 88 | fi 89 | fi 90 | 91 | } 92 | libsodium_installation(){ 93 | mkdir -p ${libsodium_folder} && cd ${libsodium_folder} 94 | wget https://github.com/jedisct1/libsodium/releases/download/1.0.13/libsodium-1.0.13.tar.gz 95 | if [[ ! -f ${libsodium_folder}/libsodium-1.0.13.tar.gz ]]; then 96 | echo -e "${Error} libsodium download FAIL" 97 | exit 1 98 | fi 99 | tar xf libsodium-1.0.13.tar.gz && cd libsodium-1.0.13 100 | ./configure && make -j2 && make install 101 | if [[ $? -ne 0 ]]; then 102 | echo -e "${Error} libsodium install FAIL" 103 | exit 1 104 | fi 105 | echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf 106 | ldconfig 107 | 108 | rm -rf ${libsodium_folder} 109 | 110 | } 111 | SSR_dependency_installation(){ 112 | if [[ ${system} == "centos" ]]; then 113 | cd ${shadowsocks_folder} 114 | yum -y install python-devel 115 | yum -y install libffi-devel 116 | yum -y install openssl-devel 117 | pip install requests 118 | pip install -r requirements.txt 119 | else 120 | pip install cymysql 121 | pip install requests 122 | fi 123 | } 124 | 125 | modify_API(){ 126 | sed -i '/API_INTERFACE/c \API_INTERFACE = '\'${API}\''' ${config} 127 | } 128 | modify_NODE_ID(){ 129 | sed -i '/NODE_ID/c \NODE_ID = '${NODE_ID}'' ${config} 130 | } 131 | modify_SPEEDTEST(){ 132 | sed -i '/SPEED/c \SPEEDTEST = '${SPEEDTEST}'' ${config} 133 | } 134 | modify_CLOUDSAFE(){ 135 | sed -i '/CLOUD/c \CLOUDSAFE = '${CLOUDSAFE}'' ${config} 136 | } 137 | modify_MU_SUFFIX(){ 138 | sed -i '/MU_SUFFIX/c \MU_SUFFIX = '\'${MU_SUFFIX}\''' ${config} 139 | } 140 | modify_MU_REGEX(){ 141 | sed -i '/MU_REGEX/c \MU_REGEX = '\'${MU_REGEX}\''' ${config} 142 | } 143 | modify_WEBAPI_URL(){ 144 | sed -i '/WEBAPI_URL/c \WEBAPI_URL = '\'${WEBAPI_URL}\''' ${config} 145 | } 146 | modify_WEBAPI_TOKEN(){ 147 | sed -i '/WEBAPI_TOKEN/c \WEBAPI_TOKEN = '\'${WEBAPI_TOKEN}\''' ${config} 148 | } 149 | modify_MYSQL(){ 150 | sed -i '/MYSQL_HOST/c \MYSQL_HOST = '\'${MYSQL_HOST}\''' ${config} 151 | sed -i '/MYSQL_PORT/c \MYSQL_PORT = '${MYSQL_PORT}'' ${config} 152 | sed -i '/MYSQL_USER/c \MYSQL_USER = '\'${MYSQL_USER}\''' ${config} 153 | sed -i '/MYSQL_PASS/c \MYSQL_PASS = '\'${MYSQL_PASS}\''' ${config} 154 | sed -i '/MYSQL_DB/c \MYSQL_DB = '\'${MYSQL_DB}\''' ${config} 155 | } 156 | selectApi(){ 157 | echo -e "${Yellow}please select the api:${Font}" 158 | echo -e "1.modwebapi" 159 | echo -e "2.glzjinmod(mysql_connect)" 160 | stty erase '^H' && read -p "(default:modwebapi):" API 161 | if [[ -z ${API} || ${API} == "1" ]]; then 162 | API="modwebapi" 163 | elif [[ ${API} == "2" ]]; then 164 | API="glzjinmod" 165 | else 166 | echo -e "${Error} you can only select in 1 or 2" 167 | exit 1 168 | fi 169 | } 170 | common_set(){ 171 | stty erase '^H' && read -p "NODE_ID(num_only):" NODE_ID 172 | stty erase '^H' && read -p "SPEEDTEST_CIRCLE(num_only):" SPEEDTEST 173 | stty erase '^H' && read -p "CLOUDSAFE_ON(0 or 1):" CLOUDSAFE 174 | stty erase '^H' && read -p "MU_SUFFIX(default:zhaoj.in):" MU_SUFFIX 175 | [[ -z ${MU_SUFFIX} ]] && MU_SUFFIX="zhaoj.in" 176 | stty erase '^H' && read -p "MU_REGEX(default:%5m%id.%suffix):" MU_REGEX 177 | [[ -z ${MU_REGEX} ]] && MU_REGEX="%5m%id.%suffix" 178 | } 179 | modwebapi_set(){ 180 | stty erase '^H' && read -p "WEBAPI_URL(example: https://www.zhaoj.in):" WEBAPI_URL 181 | stty erase '^H' && read -p "WEBAPI_TOKEN(example: zhaoj.in):" WEBAPI_TOKEN 182 | } 183 | mysql_set(){ 184 | stty erase '^H' && read -p "MYSQL_HOST(IP addr):" MYSQL_HOST 185 | stty erase '^H' && read -p "MYSQL_PORT(default:3306):" MYSQL_PORT 186 | [[ -z ${MYSQL_PORT} ]] && MYSQL_PORT="3306" 187 | stty erase '^H' && read -p "MYSQL_USER(default:root):" MYSQL_USER 188 | [[ -z ${MYSQL_USER} ]] && MYSQL_USER="root" 189 | stty erase '^H' && read -p "MYSQL_PASS:" MYSQL_PASS 190 | stty erase '^H' && read -p "MYSQL_DB:" MYSQL_DB 191 | } 192 | modify_ALL(){ 193 | modify_CLOUDSAFE 194 | modify_API 195 | modify_MU_REGEX 196 | modify_MU_SUFFIX 197 | modify_MYSQL 198 | modify_NODE_ID 199 | modify_SPEEDTEST 200 | modify_WEBAPI_TOKEN 201 | modify_WEBAPI_URL 202 | } 203 | iptables_OFF(){ 204 | systemctl disable firewalld &>/dev/null 205 | systemctl disable iptables &>/dev/null 206 | chkconfig iptables off &>/dev/null 207 | iptables -F &>/dev/null 208 | } 209 | SSR_installation(){ 210 | check_system 211 | #select api 212 | 213 | selectApi 214 | echo ${API} 215 | common_set 216 | 217 | if [[ ${API} == "modwebapi" ]]; then 218 | modwebapi_set 219 | else 220 | mysql_set 221 | fi 222 | 223 | #basic install 224 | basic_installation 225 | dependency_installation 226 | development_tools_installation 227 | libsodium_installation 228 | 229 | cd ${shadowsocks_install_folder} && git clone -b manyuser https://github.com/glzjin/shadowsocks.git 230 | cd shadowsocks && cp apiconfig.py userapiconfig.py && cp config.json user-config.json 231 | 232 | SSR_dependency_installation 233 | 234 | 235 | #final option 236 | modify_ALL 237 | iptables_OFF 238 | 239 | echo -e "${OK} SSR manyuser for glzjin installation complete" 240 | } 241 | 242 | 243 | 244 | SSR_installation 245 | -------------------------------------------------------------------------------- /shadowsocks_new.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #==================================================== 4 | # System Request:Debian 7+/Ubuntu 14.04+/Centos 6+ 5 | # Author: wulabing 6 | # Dscription: SSR glzjin server for manyuser (only) 7 | # Version: 4.0 8 | # Blog: https://www.wulabing.com 9 | # Special thanks: Toyo 10 | #==================================================== 11 | 12 | sh_ver="4.0" 13 | libsodium_folder="/etc/libsodium" 14 | shadowsocks_install_folder="/root" 15 | supervisor_dir="/etc/supervisor" 16 | suerpvisor_conf_dir="${supervisor_dir}/conf.d" 17 | shadowsocks_folder="${shadowsocks_install_folder}/shadowsocks" 18 | config="${shadowsocks_folder}/userapiconfig.py" 19 | debian_sourcelist="/etc/apt/source.list" 20 | 21 | #fonts color 22 | Green="\033[32m" 23 | Red="\033[31m" 24 | Yellow="\033[33m" 25 | GreenBG="\033[42;37m" 26 | RedBG="\033[41;37m" 27 | Font="\033[0m" 28 | 29 | 30 | #notification information 31 | Info="${Green}[Info]${Font}" 32 | OK="${Green}[OK]${Font}" 33 | Error="${Red}[Error]${Font}" 34 | Notification="${Yellow}[Notification]${Font}" 35 | 36 | source /etc/os-release &>/dev/null 37 | 38 | check_system(){ 39 | if [[ "${ID}" == "centos" && ${VERSION_ID} -ge 7 ]];then 40 | echo -e "${OK} ${GreenBG} 当前系统为 Centos ${VERSION_ID} ${Font} " 41 | INS="yum" 42 | elif [[ "${ID}" == "debian" && ${VERSION_ID} -ge 8 ]];then 43 | echo -e "${OK} ${GreenBG} 当前系统为 Debian ${VERSION_ID} ${Font} " 44 | INS="apt-get" 45 | elif [[ "${ID}" == "ubuntu" && `echo "${VERSION_ID}" | cut -d '.' -f1` -ge 16 ]];then 46 | echo -e "${OK} ${GreenBG} 当前系统为 Ubuntu ${VERSION_ID} ${Font} " 47 | INS="apt-get" 48 | elif [[ `rpm -q centos-release |cut -d - -f1` == "centos" && `rpm -q centos-release |cut -d - -f3` == 6 ]];then 49 | echo -e "${OK} ${GreenBG} 当前系统为 Centos 6 ${Font} " 50 | INS="yum" 51 | ID="centos" 52 | VERSION_ID="6" 53 | else 54 | echo -e "${Error} ${RedBG} 当前系统为 ${ID} ${VERSION_ID} 不在支持的系统列表内,安装中断 ${Font} " 55 | exit 1 56 | fi 57 | } 58 | basic_installation(){ 59 | if [[ ${ID} == "centos" ]]; then 60 | ${INS} install tar wget epel-release -y 61 | else 62 | sed -i '/^deb cdrom/'d /etc/apt/sources.list 63 | ${INS} update 64 | ${INS} install tar wget -y 65 | fi 66 | } 67 | 68 | dependency_installation(){ 69 | ${INS} -y install python-setuptools && easy_install pip 70 | if [[ $? -ne 0 ]]; then 71 | if [[ ${ID} == "centos" ]];then 72 | echo -e "${OK} ${GreenBG} 尝试 yum 安装 python-pip ${Font}" 73 | sleep 2 74 | yum -y install python-pip 75 | else 76 | echo -e "${OK} ${GreenBG} 尝试 apt 安装 python-pip ${Font}" 77 | sleep 2 78 | apt-get install python-pip -y 79 | fi 80 | if [[ $? -eq 0 ]]; then 81 | echo -e "${OK} ${GreenBG} pip installation Successfully ${Font}" 82 | sleep 1 83 | else 84 | echo -e "${Error} ${RedBG} pip installation FAIL ${Font}" 85 | exit 1 86 | fi 87 | fi 88 | } 89 | development_tools_installation(){ 90 | if [[ ${ID} == "centos" ]]; then 91 | ${INS} groupinstall "Development Tools" -y 92 | if [[ $? -ne 0 ]]; then 93 | echo -e "${Error} ${RedBG} Development Tools installation FAIL ${Font}" 94 | exit 1 95 | fi 96 | else 97 | ${INS} install build-essential -y 98 | if [[ $? -ne 0 ]]; then 99 | echo -e "${Error} ${RedBG} build-essential installation FAIL ${Font}" 100 | exit 1 101 | fi 102 | fi 103 | 104 | } 105 | libsodium_installation(){ 106 | mkdir -p ${libsodium_folder} && cd ${libsodium_folder} 107 | wget https://github.com/jedisct1/libsodium/releases/download/1.0.16/libsodium-1.0.16.tar.gz 108 | if [[ ! -f ${libsodium_folder}/libsodium-1.0.16.tar.gz ]]; then 109 | echo -e "${Error} ${RedBG} libsodium download FAIL ${Font}" 110 | exit 1 111 | fi 112 | tar xf libsodium-1.0.16.tar.gz && cd libsodium-1.0.16 113 | ./configure && make -j2 && make install 114 | if [[ $? -ne 0 ]]; then 115 | echo -e "${Error} ${RedBG} libsodium install FAIL ${Font}" 116 | exit 1 117 | fi 118 | echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf 119 | ldconfig 120 | 121 | rm -rf ${libsodium_folder} 122 | 123 | } 124 | SSR_dependency_installation(){ 125 | if [[ ${ID} == "centos" ]]; then 126 | cd ${shadowsocks_folder} 127 | ${INS} install python-devel libffi-devel openssl-devel -y 128 | pip install -r requirements.txt 129 | pip install requests 130 | else 131 | pip install cymysql==0.8.4 132 | pip install requests 133 | fi 134 | } 135 | supervisor_installation(){ 136 | if [[ ! -d ${shadowsocks_folder} ]]; then 137 | read -p "请输入shadowsocks所在目录绝对路径(eg:/root/shadowsocks)" shadowsocks_folder 138 | fi 139 | if [[ ${ID} == "centos" ]];then 140 | yum -y install supervisor 141 | else 142 | apt-get install supervisor -y 143 | fi 144 | if [[ $? -ne 0 ]]; then 145 | echo -e "${Error} ${RedBG} supervisor 安装失败 ${Font}" 146 | exit 1 147 | else 148 | echo -e "${OK} ${GreenBG} supervisor 安装成功 ${Font}" 149 | sleep 1 150 | fi 151 | 152 | 153 | } 154 | supervisor_conf_modify_debian(){ 155 | cat>${suerpvisor_conf_dir}/shadowsocks.conf<${suerpvisor_conf_dir}/shadowsocks.conf<>/etc/supervisord.conf</dev/null 299 | systemctl disable iptables &>/dev/null 300 | chkconfig iptables off &>/dev/null 301 | iptables -F &>/dev/null 302 | } 303 | SSR_installation(){ 304 | #select api 305 | 306 | selectApi 307 | echo ${API} 308 | common_set 309 | 310 | if [[ ${API} == "modwebapi" ]]; then 311 | modwebapi_set 312 | else 313 | mysql_set 314 | fi 315 | 316 | #basic install 317 | basic_installation 318 | dependency_installation 319 | development_tools_installation 320 | libsodium_installation 321 | 322 | cd ${shadowsocks_install_folder} && git clone https://github.com/wulabing/shadowsocks.git 323 | cd shadowsocks && cp apiconfig.py userapiconfig.py && cp config.json user-config.json 324 | 325 | SSR_dependency_installation 326 | 327 | 328 | #final option 329 | modify_ALL 330 | iptables_OFF 331 | 332 | echo -e "${OK} ${GreenBG} SSR manyuser for glzjin 安装完成 ${Font}" 333 | sleep 1 334 | } 335 | 336 | if_install(){ 337 | [[ -d ${shadowsocks_folder} && -f ${config} ]] && { 338 | echo -e "${OK} ${GreenBG} ShadowsocksR glzjin 已安装 ${Font}" 339 | } || { 340 | echo -e "${Error} ${RedBG} ShadowsocksR glzjin 未安装,请在安装后执行相关操作 ${Font}" 341 | exit 1 342 | } 343 | } 344 | 345 | option(){ 346 | echo -e "${Red} 请选择安装内容 ${Font}" 347 | echo -e "1. SSR + supervisor" 348 | echo -e "2. SSR " 349 | echo -e "3. supervisor" 350 | read -p "input:" number 351 | case ${number} in 352 | 1) 353 | SSR_installation 354 | supervisor_installation 355 | supervisor_conf_modify_${ID} 356 | ;; 357 | 2) 358 | SSR_installation 359 | ;; 360 | 3) 361 | supervisor_installation 362 | supervisor_conf_modify_${ID} 363 | ;; 364 | *) 365 | echo -e "${Error} ${RedBG} 请输入正确的序号 ${Font}" 366 | exit 1 367 | ;; 368 | esac 369 | } 370 | modify_module(){ 371 | read -p "请输入 $1 修改内容: " $1 372 | modify_$1 373 | [[ $? -eq 0 ]] && { 374 | echo -e "${OK} ${GreenBG} $1 修改成功 请重新启动后端 ${Font}" 375 | } || { 376 | echo -e "${Error} ${RedBG} $1 修改失败 ${Font}" 377 | } 378 | } 379 | install_management(){ 380 | check_system 381 | echo -e "${Red} 请选择安装内容 ${Font}" 382 | echo -e "1. SSR + supervisor" 383 | echo -e "2. SSR " 384 | echo -e "3. supervisor" 385 | read -p "input:" number 386 | case ${number} in 387 | 1) 388 | SSR_installation 389 | supervisor_installation 390 | supervisor_conf_modify_${ID} 391 | ;; 392 | 2) 393 | SSR_installation 394 | ;; 395 | 3) 396 | supervisor_installation 397 | supervisor_conf_modify_${ID} 398 | ;; 399 | *) 400 | echo -e "${Error} ${RedBG} 请输入正确的序号 ${Font}" 401 | exit 1 402 | ;; 403 | esac 404 | } 405 | modify_management(){ 406 | if_install 407 | echo -e "${Red}请选择要修改的内容 ${Font}" 408 | echo -e "${GreenBG} 公共内容 ${Font}" 409 | echo -e "1. NODE_ID(节点编号)" 410 | echo -e "2. SPEEDTEST(测速周期)" 411 | echo -e "3. CLOUDSAFE(云安全,非常不建议开启)" 412 | echo -e "4. ANTISSATTACK(ss攻击抵抗,自动封禁连接方式或密码错误的IP)" 413 | echo -e "5. MU_SUFFIX" 414 | echo -e "6. MU_REGEX" 415 | echo -e "${GreenBG} webapi模式相关内容 ${Font}" 416 | echo -e "7. WEBAPI_URL" 417 | echo -e "8. WEBAPI_TOKEN" 418 | echo -e "${GreenBG} glzjinmod模式相关内容 ${Font}" 419 | echo -e "9. MYSQL_HOST(数据库主机)" 420 | echo -e "10.MYSQL_PORT(数据库端口)" 421 | echo -e "11.MYSQL_USER(数据库用户名)" 422 | echo -e "12.MYSQL_PASSWORD(数据库密码)" 423 | echo -e "13.MYSQL_DB(数据库名称)" 424 | read -p "input:" modify 425 | case ${modify} in 426 | 1) 427 | modify_module "NODE_ID" 428 | ;; 429 | 2) 430 | modify_module "SPEED_TEST" 431 | ;; 432 | 3) 433 | modify_module "CLOUDSAFE" 434 | ;; 435 | 4) 436 | modify_module "ANTISSATTACK" 437 | ;; 438 | 5) 439 | modify_module "MU_SUFFIX" 440 | ;; 441 | 6) 442 | modify_module "MU_REGEX" 443 | ;; 444 | 7) 445 | modify_module "WEBAPI_URL" 446 | ;; 447 | 8) 448 | modify_module "WEBAPI_TOKEN" 449 | ;; 450 | 9) 451 | modify_module "MYSQL_HOST" 452 | ;; 453 | 10) 454 | modify_module "MYSQL_PORT" 455 | ;; 456 | 11) 457 | modify_module "MYSQL_USER" 458 | ;; 459 | 12) 460 | modify_module "MYSQL_PASS" 461 | ;; 462 | 13) 463 | modify_module "MYSQL_DB" 464 | ;; 465 | *) 466 | echo -e "${RedBG} 请输入正确的序号 ${Font}" 467 | exit 1 468 | ;; 469 | esac 470 | } 471 | uninstall_management(){ 472 | if_install 473 | rm -rf ${shadowsocks_folder} 474 | echo -e "${OK$ {GreenBG} shadowsocks glzjin 卸载完成 ${Font}" 475 | exit 0 476 | } 477 | start_management(){ 478 | command -v supervisord >/dev/null 479 | if [[ $? -ne 0 ]];then 480 | echo -e "${Notification} 检测到未安装 supervisord" 481 | /root/shadowsocks/logrun.sh 482 | sleep 2 483 | echo -e "${OK} ${GreenBG} 后端已启动 ${Font}" 484 | else 485 | echo -e "${OK} 检测到已安装 supervisord" 486 | command -v systemctl >/dev/null 487 | if [[ $? -ne 0 ]];then 488 | service supervisord start 489 | sleep 2 490 | [[ `ps -ef | grep supervisor |grep -v grep | wc -l` -ge 1 ]] && { 491 | echo -e "${OK} ${GreenBG} 后端(supervisord)已启动 ${Font}" 492 | } || { 493 | echo -e "${Error} ${RedBG} 后端启动失败 ${Font}" 494 | exit 1 495 | } 496 | else 497 | systemctl start supervisor 498 | sleep 2 499 | [[ `ps -ef | grep supervisor |grep -v grep | wc -l` -ge 1 ]] && { 500 | echo -e "${OK} ${GreenBG} 后端(supervisord)已启动 ${Font}" 501 | } || { 502 | echo -e "${Error} ${RedBG} 后端启动失败 ${Font}" 503 | exit 1 504 | } 505 | fi 506 | fi 507 | 508 | } 509 | stop_management(){ 510 | command -v supervisord >/dev/null 511 | if [[ $? -ne 0 ]];then 512 | echo -e "${Notification} 检测到未安装 supervisord" 513 | /root/shadowsocks/stop.sh 514 | sleep 2 515 | echo -e "${OK} ${GreenBG} 后端已关闭 ${Font}" 516 | else 517 | echo -e "${OK} 检测到已安装 supervisord" 518 | command -v systemctl >/dev/null 519 | if [[ $? -ne 0 ]];then 520 | service supervisord stop 521 | sleep 2 522 | [[ `ps -ef | grep supervisor |grep -v grep | wc -l` -eq 0 ]] && { 523 | echo -e "${OK} ${GreenBG} 后端(supervisord)已关闭 ${Font}" 524 | } || { 525 | echo -e "${Error} ${RedBG} 后端关闭失败 ${Font}" 526 | exit 1 527 | } 528 | else 529 | systemctl stop supervisor 530 | sleep 2 531 | [[ `ps -ef | grep supervisor |grep -v grep | wc -l` -eq 0 ]] && { 532 | echo -e "${OK} ${GreenBG} 后端(supervisord)已关闭 ${Font}" 533 | } || { 534 | echo -e "${Error} ${RedBG} 后端关闭失败 ${Font}" 535 | exit 1 536 | } 537 | fi 538 | fi 539 | } 540 | force_stop(){ 541 | supervisor_pid=` ps -ef | grep supervisor |grep -v grep|awk '{print $2}'` 542 | ss_pid=` ps -ef | grep server.py |grep -v grep|awk '{print $2}' ` 543 | kill -9 ${supervisor_pid} ${ss_pid} 544 | echo -e "${OK} ${GreenBG} 后端(supervisord)已关闭 ${Font}" 545 | } 546 | management(){ 547 | case $1 in 548 | install) 549 | install_management 550 | ;; 551 | modify) 552 | modify_management 553 | ;; 554 | uninstall) 555 | uninstall_management 556 | ;; 557 | start) 558 | start_management 559 | ;; 560 | stop) 561 | stop_management 562 | ;; 563 | restart) 564 | stop_management 565 | start_management 566 | ;; 567 | fstop) 568 | force_stop 569 | ;; 570 | status) 571 | if [[ `ps -ef | grep server.py |grep -v grep | wc -l` -ge 1 ]];then 572 | echo -e "${OK} ${GreenBG} 后端已启动 ${Font}" 573 | else 574 | echo -e "${OK} ${RedBG} 后端未启动 ${Font}" 575 | exit 1 576 | fi 577 | ;; 578 | *) 579 | echo -e "${Notification} Usage:{start|stop|fstop|status|install|uninstall|modify}" 580 | exit 1 581 | ;; 582 | esac 583 | } 584 | management $1 585 | 586 | --------------------------------------------------------------------------------