|
@ -21,6 +21,7 @@ DAEMON=/usr/bin/ssserver # Introduce the server's location here |
|
|
DAEMON_ARGS="" # Arguments to run the daemon with |
|
|
DAEMON_ARGS="" # Arguments to run the daemon with |
|
|
PIDFILE=/var/run/$NAME.pid |
|
|
PIDFILE=/var/run/$NAME.pid |
|
|
SCRIPTNAME=/etc/init.d/$NAME |
|
|
SCRIPTNAME=/etc/init.d/$NAME |
|
|
|
|
|
LOGFILE=/var/log/$NAME.log |
|
|
|
|
|
|
|
|
# Exit if the package is not installed |
|
|
# Exit if the package is not installed |
|
|
[ -x $DAEMON ] || exit 0 |
|
|
[ -x $DAEMON ] || exit 0 |
|
@ -44,10 +45,12 @@ do_start() |
|
|
# 0 if daemon has been started |
|
|
# 0 if daemon has been started |
|
|
# 1 if daemon was already running |
|
|
# 1 if daemon was already running |
|
|
# 2 if daemon could not be started |
|
|
# 2 if daemon could not be started |
|
|
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ |
|
|
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \ |
|
|
|
|
|
--background --make-pidfile --chdir / --chuid $USERID --no-close --test > /dev/null \ |
|
|
|| return 1 |
|
|
|| return 1 |
|
|
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ |
|
|
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \ |
|
|
$DAEMON_ARGS \ |
|
|
--background --make-pidfile --chdir / --chuid $USERID --no-close -- \ |
|
|
|
|
|
$DAEMON_ARGS $DAEMON_OPTS >> $LOGFILE 2>&1 \ |
|
|
|| return 2 |
|
|
|| return 2 |
|
|
# Add code here, if necessary, that waits for the process to be ready |
|
|
# Add code here, if necessary, that waits for the process to be ready |
|
|
# to handle requests from services started subsequently which depend |
|
|
# to handle requests from services started subsequently which depend |
|
@ -64,17 +67,9 @@ do_stop() |
|
|
# 1 if daemon was already stopped |
|
|
# 1 if daemon was already stopped |
|
|
# 2 if daemon could not be stopped |
|
|
# 2 if daemon could not be stopped |
|
|
# other if a failure occurred |
|
|
# other if a failure occurred |
|
|
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME |
|
|
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE |
|
|
RETVAL="$?" |
|
|
RETVAL="$?" |
|
|
[ "$RETVAL" = 2 ] && return 2 |
|
|
[ "$RETVAL" = 2 ] && return 2 |
|
|
# Wait for children to finish too if this is a daemon that forks |
|
|
|
|
|
# and if the daemon is only ever run from this initscript. |
|
|
|
|
|
# If the above conditions are not satisfied then add some other code |
|
|
|
|
|
# that waits for the process to drop all resources that could be |
|
|
|
|
|
# needed by services started subsequently. A last resort is to |
|
|
|
|
|
# sleep for some time. |
|
|
|
|
|
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON |
|
|
|
|
|
[ "$?" = 2 ] && return 2 |
|
|
|
|
|
# Many daemons don't delete their pidfiles when they exit. |
|
|
# Many daemons don't delete their pidfiles when they exit. |
|
|
rm -f $PIDFILE |
|
|
rm -f $PIDFILE |
|
|
return "$RETVAL" |
|
|
return "$RETVAL" |
|
|