This is a fix to an issue in Slitaz 4.0 with the /etc/init.d/ntp script.
The problem is essentially cosmetic but still nice to have fixed.
It is possible to start the ntp daemon (/usr/bin/ntpd) using the script from /etc/init.d/ when used during boot or manually to start ntpd the very first time.
However, when using the script with either stop or restart, it fails:
# /etc/init.d/ntp restart ntp is not running. #
Successive starts will result in multiple instances of the daemon being started. (not good)
When investigating the root cause of this problem it turned out that the start sequence omits to write the pid file to /var/run/. Once the process is started for the first time, everything else fails because this file is what all sections of the script are checking for.
The fix is to add a line writing the PID file to both the start and restart sections. I did this using pgrep. Presumably this task was supposed to be handled by a redundant line in the beginning of the script:
[ -n "$OPTIONS" ] || OPTIONS="-p $PIDFILE -c /etc/ntp.conf"
This line seems to have been disfunctional; my version works correctly without it.
I have also changed
$NAME to ntpd instead of ntp and the description
$DESC to ntp daemon instead of ntp server.
To install this fix, you should replace the existing /etc/init.d/ntp with the below version.
(Tried to create an attachment but failed)
#!/bin/sh # /etc/init.d/ntp : Start, stop and restart ntp server on SliTaz, at # boot time or with the command line. # # To start ntp server at boot time, just put ntp in the $RUN_DAEMONS # variable of /etc/rcS.conf and configure options with /etc/daemons.conf # version 1.1 jun 2013 # . /etc/init.d/rc.functions . /etc/daemons.conf NAME=ntpd DESC="ntp daemon" DAEMON=/usr/bin/ntpd OPTIONS=$NTP_OPTIONS PIDFILE=/var/run/ntpd.pid case "$1" in start) if active_pidfile $PIDFILE ntpd ; then echo "$NAME already running." exit 1 fi echo -n "Starting $DESC: $NAME... " $DAEMON $OPTIONS pgrep $DAEMON > $PIDFILE status ;; stop) if ! active_pidfile $PIDFILE ntpd ; then echo "$NAME is not running." exit 1 fi echo -n "Stopping $DESC: $NAME... " kill $(cat $PIDFILE) rm $PIDFILE status ;; restart) if ! active_pidfile $PIDFILE ntpd ; then echo "$NAME is not running." exit 1 fi echo -n "Restarting $DESC: $NAME... " kill $(cat $PIDFILE) $DAEMON $OPTIONS pgrep $DAEMON > $PIDFILE status ;; *) echo "" echo -e "33[1mUsage:33[0m /etc/init.d/$(basename $0) [start|stop|restart]" echo "" exit 1 ;; esac exit 0