Created
July 27, 2019 10:48
-
-
Save caesar0301/d200ba2b8f5334b414911ecb24eb0923 to your computer and use it in GitHub Desktop.
Init.d script for shadowsocks with local python client
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
#!/bin/bash | |
# Author: lynnyq <lynnyq@gmail.com> | |
name=sslocal | |
BIN=/usr/local/bin/sslocal | |
conf=/etc/shadowsocks-libev/local.json | |
start(){ | |
$BIN -c $conf -d start | |
RETVAL=$? | |
if [ "$RETVAL" = "0" ]; then | |
echo "$name start success" | |
else | |
echo "$name start failed" | |
fi | |
} | |
stop(){ | |
pid=`ps -ef | grep -v grep | grep -i "${BIN}" | awk '{print $2}'` | |
if [[ ! -z $pid ]]; then | |
$BIN -c $conf -d stop | |
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 -i "${BIN}" | 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