fixed init script
This commit is contained in:
parent
082183fc2a
commit
18deb4e0c5
48
data/init/guhd
Normal file → Executable file
48
data/init/guhd
Normal file → Executable file
@ -1,5 +1,17 @@
|
|||||||
#! /bin/sh
|
#! /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 #
|
# 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>
|
# Author: Simon Stuerz <simon.stuerz@guh.guru>
|
||||||
# Do NOT "set -e"
|
# Do NOT "set -e"
|
||||||
@ -40,16 +41,12 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
|||||||
DESC="guh daemon"
|
DESC="guh daemon"
|
||||||
NAME=guhd
|
NAME=guhd
|
||||||
DAEMON=/usr/bin/$NAME
|
DAEMON=/usr/bin/$NAME
|
||||||
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
|
|
||||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
|
||||||
|
|
||||||
# Load the VERBOSE setting and other rcS variables
|
# Load the VERBOSE setting and other rcS variables
|
||||||
. /lib/init/vars.sh
|
. /lib/init/vars.sh
|
||||||
|
|
||||||
@ -58,9 +55,8 @@ SCRIPTNAME=/etc/init.d/$NAME
|
|||||||
# and status_of_proc is working.
|
# and status_of_proc is working.
|
||||||
. /lib/lsb/init-functions
|
. /lib/lsb/init-functions
|
||||||
|
|
||||||
#
|
|
||||||
# Function that starts the daemon/service
|
# Function that starts the daemon/service
|
||||||
#
|
|
||||||
do_start()
|
do_start()
|
||||||
{
|
{
|
||||||
# Return
|
# Return
|
||||||
@ -70,16 +66,11 @@ do_start()
|
|||||||
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --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 \
|
|
||||||
|| return 2
|
|| 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
|
# Function that stops the daemon/service
|
||||||
#
|
|
||||||
do_stop()
|
do_stop()
|
||||||
{
|
{
|
||||||
# Return
|
# Return
|
||||||
@ -87,18 +78,11 @@ 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/5/KILL/5 --pidfile $PIDFILE --name $NAME
|
start-stop-daemon --stop --quiet --retry=TERM/30/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
|
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
|
||||||
# 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
|
|
||||||
[ "$?" = 2 ] && return 2
|
[ "$?" = 2 ] && return 2
|
||||||
# Many daemons don't delete their pidfiles when they exit.
|
|
||||||
rm -f $PIDFILE
|
rm -f $PIDFILE
|
||||||
return "$RETVAL"
|
return "$RETVAL"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user