Skip to content

Commit

Permalink
Create shadowsocks-debian
Browse files Browse the repository at this point in the history
  • Loading branch information
iMeiji committed Sep 18, 2015
1 parent 94e786e commit f1fc660
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions shadowsocks-debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: shadowsocks
# 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: Fast tunnel proxy that helps you bypass firewalls
# Description: A secure socks5 proxy, designed to protect your Internet traffic.
### END INIT INFO

# Author: Teddysun <[email protected]>

name=shadowsocks
BIN=/usr/local/bin/ssserver
conf=/etc/shadowsocks.json
#pid=/var/run/shadowsocks.pid

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 -v ps | grep -i "/usr/bin/python ${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 -v ps | grep -i "/usr/bin/python ${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

0 comments on commit f1fc660

Please sign in to comment.