Created
December 19, 2019 14:08
-
-
Save implicit-invocation/44a23a7777af0bfe81fac146abf9c4b3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/sh | |
# chkconfig: 2345 90 10 | |
# description: Start or stop the Shadowsocks R server | |
# | |
### BEGIN INIT INFO | |
# Provides: Shadowsocks-R | |
# Required-Start: $network $syslog | |
# Required-Stop: $network | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Description: Start or stop the Shadowsocks R server | |
### END INIT INFO | |
# Author: Yvonne Lu(Min) <[email protected]> | |
name=shadowsocks | |
PY=/usr/bin/python | |
SS=/usr/local/shadowsocksr/server.py | |
start(){ | |
/usr/local/shadowsocksr/logrun.sh | |
RETVAL=$? | |
if [ "$RETVAL" = "0" ]; then | |
echo "$name start success" | |
else | |
echo "$name start failed" | |
fi | |
} | |
stop(){ | |
pid=`ps -ef | grep -v grep | grep -v ps | grep -i "${SSPY}" | awk '{print $2}'` | |
if [ ! -z "$pid" ]; then | |
/usr/local/shadowsocksr/stop.sh | |
RETVAL=$? | |
if [ "$RETVAL" = "0" ]; then | |
echo "$name stop success" | |
else | |
echo "$name stop failed" | |
fi | |
else | |
echo "$name is not running" | |
RETVAL=1 | |
fi | |
} | |
status(){ | |
pid=`ps -ef | grep -v grep | grep -v ps | grep -i "${SSPY}" | awk '{print $2}'` | |
if [ -z "$pid" ]; then | |
echo "$name is not running" | |
RETVAL=1 | |
else | |
echo "$name is running with PID $pid" | |
RETVAL=0 | |
fi | |
} | |
case "$1" in | |
'start') | |
start | |
;; | |
'stop') | |
stop | |
;; | |
'status') | |
status | |
;; | |
'restart') | |
stop | |
start | |
RETVAL=$? | |
;; | |
*) | |
echo "Usage: $0 { start | stop | restart | status }" | |
RETVAL=1 | |
;; | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment