Trace: Init Fixes

Init Fixes

Init Fixes

Some initialisation files in /etc/init.d/ are occasionally broken. Below are fixes for those.

BIND (named)

For me, the BIND (a.k.a. named/name daemon) init script has not been creating a PID file for quite some time (years). When it shuts down it assumes the existence of the PID file rather than validating it, and since it does not exist the stop process pauses for 60 seconds (waiting for an event that will never happen) and then fails.

The PID file is properly constructed and passed to the start-stop-daemon around line 177 of the script. I added this line to the script to verify this:

166    einfo "PID directory $piddir -- PID file $PIDFILE"

The output when starting shows this:

 * PID directory /chroot/dns/run/named -- PID file /chroot/dns/run/named/named.pid        [ ok ]

The run directory exists and I can touch the PID file and see that it is created, but for some reason the start-stop-daemon does not create the file.

To fix the problem I changed the script to validate the PIDFILE around like 204, just after the _get_pidfile call, and to skip using it if not present. For me, shutting down without the PID file works every time, but in case there might be a condition where this were not true and the PID file problem ever gets fixed I leave the PID file usage in there rather than simply removing it altogether.

204    _get_pidfile
205    einfo "Using PIDFILE $PIDFILE"
206    if [[ -n "$PIDFILE" && -s "$PIDFILE" ]]
207    then
208       start-stop-daemon --stop --retry 10 --pidfile $PIDFILE --exec /usr/sbin/named
209    else
210       einfo "No PIDFILE found, so stopping without PID."
211       start-stop-daemon --stop --retry 10 --exec /usr/sbin/named
212    fi