summaryrefslogtreecommitdiffstats
path: root/source.local/n/ntp/rc.ntpd
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2013-03-22 16:47:17 -0700
committer Eric Hameleers <alien@slackware.com>2013-03-22 16:47:17 -0700
commit69dd99f961988fa15da8d7f0d63b62f3385419c3 (patch)
treed57eb3e85e1d08e7815787de26946ee42c398b66 /source.local/n/ntp/rc.ntpd
downloadalienarm-69dd99f961988fa15da8d7f0d63b62f3385419c3.tar.gz
alienarm-69dd99f961988fa15da8d7f0d63b62f3385419c3.tar.xz
Initial commit of a Slackware cross-arch bootstrap framework.
Diffstat (limited to 'source.local/n/ntp/rc.ntpd')
-rw-r--r--source.local/n/ntp/rc.ntpd56
1 files changed, 56 insertions, 0 deletions
diff --git a/source.local/n/ntp/rc.ntpd b/source.local/n/ntp/rc.ntpd
new file mode 100644
index 0000000..7cf3d50
--- /dev/null
+++ b/source.local/n/ntp/rc.ntpd
@@ -0,0 +1,56 @@
+#!/bin/sh
+# Start/stop/restart ntpd.
+
+# Start ntpd:
+ntpd_start() {
+ CMDLINE="/usr/sbin/ntpd -g"
+ echo -n "Starting NTP daemon: $CMDLINE"
+ $CMDLINE -p /var/run/ntpd.pid
+ 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."
+ 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