2009-08-26 17:00:38 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# Start/stop/restart ntpd.
|
|
|
|
|
|
|
|
# Start ntpd:
|
|
|
|
ntpd_start() {
|
2018-05-28 21:12:29 +02:00
|
|
|
echo -n "Starting NTP daemon: /usr/sbin/ntpd -g -u ntp:ntp"
|
|
|
|
/usr/sbin/ntpd -g -u ntp:ntp
|
2009-08-26 17:00:38 +02:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
# Stop ntpd:
|
|
|
|
ntpd_stop() {
|
|
|
|
echo -n "Stopping NTP daemon..."
|
2010-05-19 10:58:23 +02:00
|
|
|
if [ -r /var/run/ntpd.pid ]; then
|
|
|
|
kill -HUP $(cat /var/run/ntpd.pid)
|
|
|
|
rm -f /var/run/ntpd.pid
|
|
|
|
else
|
|
|
|
killall -HUP -q ntpd
|
|
|
|
fi
|
2009-08-26 17:00:38 +02:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
# Restart ntpd:
|
|
|
|
ntpd_restart() {
|
|
|
|
ntpd_stop
|
|
|
|
sleep 1
|
|
|
|
ntpd_start
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check if ntpd is running
|
|
|
|
ntpd_status() {
|
|
|
|
if [ -e /var/run/ntpd.pid ]; then
|
2018-05-28 21:12:29 +02:00
|
|
|
echo "ntpd is running as pid $(cat /var/run/ntpd.pid)."
|
2009-08-26 17:00:38 +02:00
|
|
|
else
|
|
|
|
echo "ntpd is stopped."
|
2010-05-19 10:58:23 +02:00
|
|
|
exit 1
|
2009-08-26 17:00:38 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
'start')
|
|
|
|
ntpd_start
|
|
|
|
;;
|
|
|
|
'stop')
|
|
|
|
ntpd_stop
|
|
|
|
;;
|
|
|
|
'restart')
|
|
|
|
ntpd_restart
|
|
|
|
;;
|
|
|
|
'status')
|
|
|
|
ntpd_status
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "usage $0 start|stop|restart|status"
|
|
|
|
esac
|