slackware-current/source/n/ntp/rc.ntpd

56 lines
825 B
Text
Raw Normal View History

#!/bin/sh
# Start/stop/restart ntpd.
# Start ntpd:
ntpd_start() {
echo -n "Starting NTP daemon: /usr/sbin/ntpd -g -u ntp:ntp"
/usr/sbin/ntpd -g -u ntp:ntp
echo
}
# Stop ntpd:
ntpd_stop() {
echo -n "Stopping NTP daemon..."
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
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
echo "ntpd is running as pid $(cat /var/run/ntpd.pid)."
else
echo "ntpd is stopped."
exit 1
fi
}
case "$1" in
'start')
ntpd_start
;;
'stop')
ntpd_stop
;;
'restart')
ntpd_restart
;;
'status')
ntpd_status
;;
*)
echo "usage $0 start|stop|restart|status"
esac