fixed init script

This commit is contained in:
Simon Stürz 2015-02-24 09:38:04 +01:00 committed by Michael Zanetti
parent 082183fc2a
commit 18deb4e0c5

48
data/init/guhd Normal file → Executable file
View File

@ -1,5 +1,17 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: guhd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: guh daemon
# Description: guh is an open source home automation server, which allows to
# control a lot of different devices from many different manufacturers.
#
### END INIT INFO
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Copyright (C) 2015 guh #
@ -20,17 +32,6 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
### BEGIN INIT INFO
# Provides: guhd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: guh daemon
# Description: guh is an open source home automation server, which allows to
# control a lot of different devices from many different manufacturers.
#
### END INIT INFO
# Author: Simon Stuerz <simon.stuerz@guh.guru>
# Do NOT "set -e"
@ -40,16 +41,12 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="guh daemon"
NAME=guhd
DAEMON=/usr/bin/$NAME
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
@ -58,9 +55,8 @@ SCRIPTNAME=/etc/init.d/$NAME
# and status_of_proc is working.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
# Return
@ -70,16 +66,11 @@ do_start()
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
@ -87,18 +78,11 @@ do_stop()
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/5/KILL/5 --pidfile $PIDFILE --name $NAME
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$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/5/KILL/5 --exec $DAEMON
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.
rm -f $PIDFILE
return "$RETVAL"
}