You are not logged in.
Pages: 1
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.
Problem description:
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.
Syntax: [c]/etc/init.d/ntp start[/c]
However, when using the script with either stop or restart, it fails:
[c]# /etc/init.d/ntp restart
ntp is not running.
#[/c]
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.
Solution:
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: [c][ -n "$OPTIONS" ] || OPTIONS="-p $PIDFILE -c /etc/ntp.conf"[/c]
This line seems to have been disfunctional; my version works correctly without it.
I have also changed [c]$NAME[/c] to ntpd instead of ntp and the description [c]$DESC[/c] 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)
/emgi
[c]#!/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[/c]
Offline
Just noticed a problem with the pasted file above.
Characters got lost while pasting. :-(
cat $PIDFILE should be surrounded by [c]like this: kill[/c]cat $PIDFILE`
Sorry for the inconvenience.
/emgi
Offline
Still no good, the message is not displayed exactly as I typed it; the quotes go missing...
Anyway, another finding is that the problem also has been fixed in the cooking version of ntp, which is ntp-4.2.6p5.tazpkg. The version in 4.0 is ntp-4.2.6p3.tazpkg.
You can download & install the cooking version in 4.0.
Next time I will check this first, before suggesting any changes.
/emgi
Offline
emgi,
Next time I will check this first, before suggesting any changes.

Pascal Bellard tells you "Thanks!" in commits that fixed ntp: http://hg.slitaz.org/wok/rev/e1f16de14d6e http://hg.slitaz.org/wok-stable/rev/66108539473c
Thank you for being paid attention and offered a solution!
I edited your very first post in this topic. Please, look at bottom of this page:

Backticks have special meaning on this forum.
In the shell scripts here is equivalents:
[c]1) variable=‘some code‘ # imagine here backticks 
2) variable=$(some code)[/c]
Please, use the second variant in your scripts. It is more obvious, admits an embedding, and does not conflict with forum markup.
Offline
Hi Aleksej,
I understand it now that the backticks have a special meaning. Quick solutions tend to be dirty ones. ;-) I wasn't intending to post the file as text in the first place. This became necessary because I was unable to create an attachment. I guess you need special authorization for that? You seem to be able to do it but when I try I get a 'denied' message.
So now I understand Pascal immediately implemented my proposed fix. (Do you guys ever need to sleep?)
This kind of thing is one of the few I can contribute to and its good to know this is appreciated.
BTW: I have also updated the System Adminstration section of the Handbook regarding ntp.
/emgi
Offline
Pages: 1
[ Generated in 0.016 seconds, 7 queries executed - Memory usage: 1.54 MiB (Peak: 1.77 MiB) ]