fixed init script

This commit is contained in:
Simon Stürz 2015-02-12 22:07:58 +01:00 committed by Michael Zanetti
parent 5ae113ab3e
commit 1aa8e0a92f

View File

@ -1,13 +1,14 @@
#! /bin/sh #! /bin/sh
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: skeleton # Provides: guhd
# Required-Start: $remote_fs $syslog # Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog # Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5 # Default-Start: 2 3 4 5
# Default-Stop: 0 1 6 # Default-Stop: 0 1 6
# Short-Description: Example initscript # Short-Description: guh daemon
# Description: This file should be used to construct scripts to be # Description: guh is an open source home automation server, which allows to
# placed in /etc/init.d. # control a lot of different devices from many different manufacturers.
#
### END INIT INFO ### END INIT INFO
# Author: Simon Stuerz <simon.stuerz@guh.guru> # Author: Simon Stuerz <simon.stuerz@guh.guru>
@ -21,11 +22,11 @@ NAME=guhd
DAEMON=/usr/bin/$NAME DAEMON=/usr/bin/$NAME
DAEMON_ARGS="" DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed # Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0 [ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present # Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME [ -r /etc/default/$NAME ] && . /etc/default/$NAME
@ -66,7 +67,7 @@ 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/5/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?" RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2 [ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks # Wait for children to finish too if this is a daemon that forks
@ -75,7 +76,7 @@ do_stop()
# that waits for the process to drop all resources that could be # that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to # needed by services started subsequently. A last resort is to
# sleep for some time. # sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON start-stop-daemon --stop --quiet --oknodo --retry=0/5/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2 [ "$?" = 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