2009-08-26 17:00:38 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# Start/stop/restart ntpd.
|
|
|
|
|
2024-06-01 21:52:37 +02:00
|
|
|
# Load options from /etc/default/ntp:
|
|
|
|
. /etc/default/ntp
|
|
|
|
|
2009-08-26 17:00:38 +02:00
|
|
|
# Start ntpd:
|
|
|
|
ntpd_start() {
|
2024-06-01 21:52:37 +02:00
|
|
|
echo -n "Starting NTP daemon: /usr/sbin/ntpd $NTPD_OPTS"
|
|
|
|
/usr/sbin/ntpd $NTPD_OPTS
|
2009-08-26 17:00:38 +02:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
# Stop ntpd:
|
|
|
|
ntpd_stop() {
|
2024-06-01 21:52:37 +02:00
|
|
|
echo -n "Stopping NTP daemon... "
|
2021-02-16 21:57:36 +01:00
|
|
|
if [ -r /run/ntpd.pid ]; then
|
2024-06-01 21:52:37 +02:00
|
|
|
echo -n "(PID $(cat /run/ntpd.pid))"
|
2021-02-16 21:57:36 +01:00
|
|
|
kill -HUP $(cat /run/ntpd.pid)
|
|
|
|
rm -f /run/ntpd.pid
|
2010-05-19 10:58:23 +02:00
|
|
|
else
|
2024-06-01 21:52:37 +02:00
|
|
|
killall --ns $$ -HUP -q ntpd
|
2010-05-19 10:58:23 +02:00
|
|
|
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() {
|
2021-02-16 21:57:36 +01:00
|
|
|
if [ -e /run/ntpd.pid ]; then
|
2024-06-01 21:52:37 +02:00
|
|
|
echo "ntpd is running as PID $(cat /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
|