forked from ToyoDAdoubi/doubi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Toyo
authored
Nov 7, 2018
1 parent
7fc0993
commit c96918b
Showing
2 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/bin/bash | ||
# chkconfig: 2345 90 10 | ||
# description: Shadowsocks Golang | ||
|
||
### BEGIN INIT INFO | ||
# Provides: Shadowsocks Golang | ||
# Required-Start: $network $syslog | ||
# Required-Stop: $network | ||
# Default-Start: 2 3 4 5 | ||
# Default-Stop: 0 1 6 | ||
# Short-Description: Lightweight SOCKS5 proxy tool Shadowsocks | ||
# Description: Start or stop the Shadowsocks-go | ||
### END INIT INFO | ||
|
||
NAME="Shadowsocks" | ||
NAME_BIN="./shadowsocks-go " | ||
FOLDER="/usr/local/shadowsocks-go" | ||
CONF="/usr/local/shadowsocks-go/shadowsocks-go.conf" | ||
LOG="/usr/local/shadowsocks-go/shadowsocks-go.log" | ||
|
||
Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m" | ||
Info="${Green_font_prefix}[信息]${Font_color_suffix}" | ||
Error="${Red_font_prefix}[错误]${Font_color_suffix}" | ||
RETVAL=0 | ||
|
||
check_running(){ | ||
PID=$(ps -ef |grep "${NAME_BIN}" |grep -v "grep" |grep -v "init.d" |grep -v "service" |awk '{print $2}') | ||
if [[ ! -z ${PID} ]]; then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
} | ||
read_config(){ | ||
[[ ! -e ${CONF} ]] && echo -e "${Error} $NAME 配置文件不存在 !" && exit 1 | ||
port=$(cat ${CONF}|grep 'PORT = '|awk -F 'PORT = ' '{print $NF}') | ||
password=$(cat ${CONF}|grep 'PASSWORD = '|awk -F 'PASSWORD = ' '{print $NF}') | ||
cipher=$(cat ${CONF}|grep 'CIPHER = '|awk -F 'CIPHER = ' '{print $NF}') | ||
verbose=$(cat ${CONF}|grep 'VERBOSE = '|awk -F 'VERBOSE = ' '{print $NF}') | ||
if [[ "${verbose}" == "YES" ]]; then | ||
verbose="-verbose" | ||
else | ||
verbose="" | ||
fi | ||
} | ||
do_start(){ | ||
check_running | ||
if [[ $? -eq 0 ]]; then | ||
echo -e "${Info} $NAME (PID ${PID}) 正在运行..." && exit 0 | ||
else | ||
read_config | ||
cd ${FOLDER} | ||
echo -e "${Info} $NAME 启动中..." | ||
ulimit -n 51200 | ||
nohup ./ss-go -s ":${port}" -cipher "${cipher}" -password "${password}" "${verbose}" >> "${LOG}" 2>&1 & | ||
sleep 2s | ||
check_running | ||
if [[ $? -eq 0 ]]; then | ||
echo -e "${Info} $NAME 启动成功 !" | ||
else | ||
echo -e "${Error} $NAME 启动失败 !请查看日志文件检查问题所在。" | ||
fi | ||
fi | ||
} | ||
do_stop(){ | ||
check_running | ||
if [[ $? -eq 0 ]]; then | ||
kill -9 ${PID} | ||
RETVAL=$? | ||
if [[ $RETVAL -eq 0 ]]; then | ||
echo -e "${Info} $NAME 停止成功 !" | ||
else | ||
echo -e "${Error} $NAME 停止失败 !" | ||
fi | ||
else | ||
echo -e "${Info} $NAME 未运行" | ||
RETVAL=1 | ||
fi | ||
} | ||
do_status(){ | ||
check_running | ||
if [[ $? -eq 0 ]]; then | ||
echo -e "${Info} $NAME (PID ${PID}) 正在运行..." | ||
else | ||
echo -e "${Info} $NAME 未运行 !" | ||
RETVAL=1 | ||
fi | ||
} | ||
do_restart(){ | ||
do_stop | ||
do_start | ||
} | ||
case "$1" in | ||
start|stop|restart|status) | ||
do_$1 | ||
;; | ||
*) | ||
echo -e "使用方法: $0 { start | stop | restart | status }" | ||
RETVAL=1 | ||
;; | ||
esac | ||
exit $RETVAL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/bin/bash | ||
|
||
### BEGIN INIT INFO | ||
# Provides: Shadowsocks Golang | ||
# 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: Lightweight SOCKS5 proxy tool Shadowsocks | ||
# Description: Start or stop the Shadowsocks-go | ||
### END INIT INFO | ||
|
||
NAME="Shadowsocks" | ||
NAME_BIN="./shadowsocks-go " | ||
FOLDER="/usr/local/shadowsocks-go" | ||
CONF="/usr/local/shadowsocks-go/shadowsocks-go.conf" | ||
LOG="/usr/local/shadowsocks-go/shadowsocks-go.log" | ||
|
||
Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m" | ||
Info="${Green_font_prefix}[信息]${Font_color_suffix}" | ||
Error="${Red_font_prefix}[错误]${Font_color_suffix}" | ||
RETVAL=0 | ||
|
||
check_running(){ | ||
PID=$(ps -ef |grep "${NAME_BIN}" |grep -v "grep" |grep -v "init.d" |grep -v "service" |awk '{print $2}') | ||
if [[ ! -z ${PID} ]]; then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
} | ||
read_config(){ | ||
[[ ! -e ${CONF} ]] && echo -e "${Error} $NAME 配置文件不存在 !" && exit 1 | ||
port=$(cat ${CONF}|grep 'PORT = '|awk -F 'PORT = ' '{print $NF}') | ||
password=$(cat ${CONF}|grep 'PASSWORD = '|awk -F 'PASSWORD = ' '{print $NF}') | ||
cipher=$(cat ${CONF}|grep 'CIPHER = '|awk -F 'CIPHER = ' '{print $NF}') | ||
verbose=$(cat ${CONF}|grep 'VERBOSE = '|awk -F 'VERBOSE = ' '{print $NF}') | ||
if [[ "${verbose}" == "YES" ]]; then | ||
verbose="-verbose" | ||
else | ||
verbose="" | ||
fi | ||
} | ||
do_start(){ | ||
check_running | ||
if [[ $? -eq 0 ]]; then | ||
echo -e "${Info} $NAME (PID ${PID}) 正在运行..." && exit 0 | ||
else | ||
read_config | ||
cd ${FOLDER} | ||
echo -e "${Info} $NAME 启动中..." | ||
ulimit -n 51200 | ||
nohup ./ss-go -s ":${port}" -cipher "${cipher}" -password "${password}" "${verbose}" >> "${LOG}" 2>&1 & | ||
sleep 2s | ||
check_running | ||
if [[ $? -eq 0 ]]; then | ||
echo -e "${Info} $NAME 启动成功 !" | ||
else | ||
echo -e "${Error} $NAME 启动失败 !请查看日志文件检查问题所在。" | ||
fi | ||
fi | ||
} | ||
do_stop(){ | ||
check_running | ||
if [[ $? -eq 0 ]]; then | ||
kill -9 ${PID} | ||
RETVAL=$? | ||
if [[ $RETVAL -eq 0 ]]; then | ||
echo -e "${Info} $NAME 停止成功 !" | ||
else | ||
echo -e "${Error} $NAME 停止失败 !" | ||
fi | ||
else | ||
echo -e "${Info} $NAME 未运行" | ||
RETVAL=1 | ||
fi | ||
} | ||
do_status(){ | ||
check_running | ||
if [[ $? -eq 0 ]]; then | ||
echo -e "${Info} $NAME (PID ${PID}) 正在运行..." | ||
else | ||
echo -e "${Info} $NAME 未运行 !" | ||
RETVAL=1 | ||
fi | ||
} | ||
do_restart(){ | ||
do_stop | ||
do_start | ||
} | ||
case "$1" in | ||
start|stop|restart|status) | ||
do_$1 | ||
;; | ||
*) | ||
echo "使用方法: $0 { start | stop | restart | status }" | ||
RETVAL=1 | ||
;; | ||
esac | ||
exit $RETVAL |