Update command line arguments

This commit is contained in:
Teddysun 2015-01-21 17:34:13 +08:00
parent babff1da07
commit 500687357b

View File

@ -12,15 +12,13 @@
### END INIT INFO ### END INIT INFO
conf=/etc/shadowsocks.json conf=/etc/shadowsocks.json
pid=/var/run/shadowsocks.pid #pid=/var/run/shadowsocks.pid
name='shadowsocks' name='shadowsocks'
start(){ start(){
nohup /usr/bin/python /usr/bin/ssserver -c $conf > /dev/null 2>&1 & /usr/bin/ssserver -c $conf -d start
RETVAL=$? RETVAL=$?
REPID=$!
if [ "$RETVAL" = "0" ]; then if [ "$RETVAL" = "0" ]; then
echo $REPID > $pid 2>&1
echo "$name start success" echo "$name start success"
else else
echo "$name start failed" echo "$name start failed"
@ -28,11 +26,11 @@ start(){
} }
stop(){ stop(){
if [ -s $pid ]; then pid=`ps -ef | grep -v grep | grep -v ps | grep -i '/usr/bin/python /usr/bin/ssserver' | awk '{print $2}'`
kill `cat $pid` if [ ! -z $pid ]; then
/usr/bin/ssserver -c $conf -d stop
RETVAL=$? RETVAL=$?
if [ "$RETVAL" = "0" ]; then if [ "$RETVAL" = "0" ]; then
rm -f $pid
echo "$name stop success" echo "$name stop success"
else else
echo "$name stop failed" echo "$name stop failed"
@ -44,19 +42,13 @@ stop(){
} }
status(){ status(){
if [ -s $pid ]; then pid=`ps -ef | grep -v grep | grep -v ps | grep -i '/usr/bin/python /usr/bin/ssserver' | awk '{print $2}'`
pidno=`cat $pid` if [ -z $pid ]; then
kill -0 $pidno >/dev/null 2>&1 echo "$name is not running"
if [ "$?" = "0" ]; then
echo "$name (pid $pidno) is running"
RETVAL=0
else
echo "$name is stopped"
RETVAL=1
fi
else
echo "$name is stopped"
RETVAL=1 RETVAL=1
else
echo "$name is running with PID $pid"
RETVAL=0
fi fi
} }