summaryrefslogtreecommitdiffstats
path: root/patches/source/ntp/rc.ntpd
diff options
context:
space:
mode:
Diffstat (limited to 'patches/source/ntp/rc.ntpd')
-rw-r--r--patches/source/ntp/rc.ntpd55
1 files changed, 55 insertions, 0 deletions
diff --git a/patches/source/ntp/rc.ntpd b/patches/source/ntp/rc.ntpd
new file mode 100644
index 000000000..9d1e3e88f
--- /dev/null
+++ b/patches/source/ntp/rc.ntpd
@@ -0,0 +1,55 @@
+#!/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 /run/ntpd.pid ]; then
+ kill -HUP $(cat /run/ntpd.pid)
+ rm -f /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 /run/ntpd.pid ]; then
+ echo "ntpd is running as pid $(cat /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