5e08d92947
This patch adds the installation of a startup script if the sntp utility is selected as an option. The utility is design to do a one time step/slew adjustment of the system time (similar to the ntpdate tool http://support.ntp.org/bin/view/Dev/DeprecatingNtpdate). One nice benefit over ntpdate is that sntp can run while ntpd is still running. However, ntpd may still need to be restarted if the time step was large enough. The script provides the ability to override the arguments as part of a /etc/defaults/sntp file. On a local LAN, the initial large step adjustment took less then one second to be retrieved and system time updated. If a user already has a RTC maintaining the time and the system was powered off for a long period of time, the script assumes a slew adjustment when +/- 128ms, rather then a time step(jump). This could be further tuned by a user with the /etc/defaults/sntp configuration file. One NTP pool server is being set as sntp uses all of the servers provided when the DNS is resolved as servers to attempt to retrieve time from before timing out. It looks like currently that is 4 servers per *pool.ntp.org hostname. Cc: Oscar Gomez Fuente <oscargomezf@gmail.com> Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com> Tested-by: Oscar Gomez Fuente <oscargomezf@gmail.com> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
35 lines
581 B
Bash
35 lines
581 B
Bash
#! /bin/sh
|
|
|
|
NAME=ntpd
|
|
|
|
# Read config file if it is present.
|
|
if [ -r /etc/default/$NAME ]
|
|
then
|
|
. /etc/default/$NAME
|
|
fi
|
|
|
|
case "$1" in
|
|
start)
|
|
printf "Starting $NAME: "
|
|
start-stop-daemon -S -q -x /usr/sbin/ntpd -- -g
|
|
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
|
;;
|
|
stop)
|
|
printf "Stopping $NAME: "
|
|
start-stop-daemon -K -q -n $NAME
|
|
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
|
;;
|
|
restart|reload)
|
|
echo "Restarting $NAME: "
|
|
$0 stop
|
|
sleep 1
|
|
$0 start
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|reload}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0
|