trousers: make initscript more reliable

The combination of using start-stop-daemon and pidof is
not working reliably in all cases. Sometimes, the
tcsd daemon isn't running yet at the time pidof is being
invoked.

This results in an empty /var/run/tcsd.pid, making it
impossible to stop tcsd using the init script.

To solve this, one could either add a delay before calling
pidof, or alternatively use start-stop-daemon's built-in
functionality to achieve the same.

Let's do the latter.

Signed-off-by: André Draszik <adraszik@tycoint.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
This commit is contained in:
André Draszik
2017-11-01 11:16:32 +00:00
committed by Armin Kuster
parent de48d57a7f
commit fc75466e0b
@@ -33,10 +33,12 @@ case "${1}" in
exit 0 exit 0
fi fi
start-stop-daemon --start --quiet --oknodo --pidfile /var/run/${NAME}.pid --user ${USER} --chuid ${USER} --exec ${DAEMON} -- ${DAEMON_OPTS} start-stop-daemon --start --quiet --oknodo \
--pidfile /var/run/${NAME}.pid --make-pidfile --background \
--user ${USER} --chuid ${USER} \
--exec ${DAEMON} -- ${DAEMON_OPTS} --foreground
RETVAL="$?" RETVAL="$?"
echo "$NAME." echo "$NAME."
[ "$RETVAL" = 0 ] && pidof $DAEMON > /var/run/${NAME}.pid
exit $RETVAL exit $RETVAL
;; ;;