Add shadowsocks-libev-debian
This commit is contained in:
parent
fc26dd616f
commit
93cf22a700
115
shadowsocks-libev-debian
Normal file
115
shadowsocks-libev-debian
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Script to run Shadowsocks in daemon mode at boot time.
|
||||||
|
# Revision 1.0
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: shadowsocks
|
||||||
|
# Required-Start:
|
||||||
|
# Required-Stop:
|
||||||
|
# Should-Start:
|
||||||
|
# Should-Stop:
|
||||||
|
# Default-Start: 2 3 4 5
|
||||||
|
# Default-Stop: 0 1 6
|
||||||
|
# Short-Description: shadowsocks is a lightweight tunneling proxy
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
# Daemon
|
||||||
|
NAME=shadowsocks-server
|
||||||
|
DAEMON=/usr/local/bin/ss-server
|
||||||
|
|
||||||
|
# Path to the configuration file.
|
||||||
|
#
|
||||||
|
CONF=/etc/shadowsocks-libev/config.json
|
||||||
|
|
||||||
|
#USER="nobody"
|
||||||
|
#GROUP="nobody"
|
||||||
|
|
||||||
|
# Take care of pidfile permissions
|
||||||
|
mkdir /var/run/$NAME 2>/dev/null || true
|
||||||
|
#chown "$USER:$GROUP" /var/run/$NAME
|
||||||
|
|
||||||
|
# Check the configuration file exists.
|
||||||
|
#
|
||||||
|
if [ ! -f $CONF ] ; then
|
||||||
|
echo "The configuration file cannot be found!"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Path to the lock file.
|
||||||
|
#
|
||||||
|
LOCK_FILE=/var/lock/subsys/shadowsocks
|
||||||
|
|
||||||
|
# Path to the pid file.
|
||||||
|
#
|
||||||
|
PID=/var/run/$NAME/pid
|
||||||
|
|
||||||
|
|
||||||
|
#====================================================================
|
||||||
|
|
||||||
|
#====================================================================
|
||||||
|
# Run controls:
|
||||||
|
|
||||||
|
RETVAL=0
|
||||||
|
|
||||||
|
# Start shadowsocks as daemon.
|
||||||
|
#
|
||||||
|
start() {
|
||||||
|
if [ -f $LOCK_FILE ]; then
|
||||||
|
echo "$NAME is already running!"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo -n $"Starting ${NAME}: "
|
||||||
|
#daemon --check $DAEMON --user $USER "$DAEMON -f $PID -c $CONF > /dev/null"
|
||||||
|
daemon $DAEMON -u -c $CONF -f $PID
|
||||||
|
fi
|
||||||
|
|
||||||
|
RETVAL=$?
|
||||||
|
[ $RETVAL -eq 0 ] && success
|
||||||
|
echo
|
||||||
|
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
|
||||||
|
return $RETVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Stop shadowsocks.
|
||||||
|
#
|
||||||
|
stop() {
|
||||||
|
echo -n $"Shutting down ${NAME}: "
|
||||||
|
killproc -p ${PID}
|
||||||
|
RETVAL=$?
|
||||||
|
[ $RETVAL -eq 0 ]
|
||||||
|
rm -f $LOCK_FILE
|
||||||
|
rm -f ${PID}
|
||||||
|
echo
|
||||||
|
return $RETVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
# See how we were called.
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
condrestart)
|
||||||
|
if [ -f $LOCK_FILE ]; then
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
RETVAL=$?
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
status $DAEMON
|
||||||
|
RETVAL=$?
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
|
||||||
|
RETVAL=1
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit $RETVAL
|
||||||
Loading…
Reference in New Issue
Block a user