diff options
Diffstat (limited to 'recipes-support/ntp/files/ntpd')
| -rwxr-xr-x | recipes-support/ntp/files/ntpd | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/recipes-support/ntp/files/ntpd b/recipes-support/ntp/files/ntpd new file mode 100755 index 0000000000..ae50f135d0 --- /dev/null +++ b/recipes-support/ntp/files/ntpd | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | # | ||
| 3 | # ntpd init.d script for ntpdc from ntp.isc.org | ||
| 4 | test -x /usr/bin/ntpd -a -r /etc/ntp.conf || exit 0 | ||
| 5 | # rcS contains TICKADJ | ||
| 6 | test -r /etc/default/rcS && . /etc/default/rcS | ||
| 7 | |||
| 8 | # Functions to do individual actions | ||
| 9 | settick(){ | ||
| 10 | # If TICKADJ is set we *must* adjust it before we start, because the | ||
| 11 | # driftfile relies on the correct setting | ||
| 12 | test -n "$TICKADJ" -a -x /usr/bin/tickadj && { | ||
| 13 | echo -n "Setting tick to $TICKADJ: " | ||
| 14 | /usr/bin/tickadj "$TICKADJ" | ||
| 15 | echo "done" | ||
| 16 | } | ||
| 17 | } | ||
| 18 | startdaemon(){ | ||
| 19 | # The -g option allows ntpd to step the time to correct it just | ||
| 20 | # once. The daemon will exit if the clock drifts too much after | ||
| 21 | # this. If ntpd seems to disappear after a while assume TICKADJ | ||
| 22 | # above is set to a totally incorrect value. | ||
| 23 | echo -n "Starting ntpd: " | ||
| 24 | start-stop-daemon --start -x /usr/bin/ntpd -- -p /var/run/ntp.pid "$@" | ||
| 25 | echo "done" | ||
| 26 | } | ||
| 27 | stopdaemon(){ | ||
| 28 | echo -n "Stopping ntpd: " | ||
| 29 | start-stop-daemon --stop -p /var/run/ntp.pid | ||
| 30 | echo "done" | ||
| 31 | } | ||
| 32 | |||
| 33 | case "$1" in | ||
| 34 | start) | ||
| 35 | settick | ||
| 36 | startdaemon -g | ||
| 37 | ;; | ||
| 38 | stop) | ||
| 39 | stopdaemon | ||
| 40 | ;; | ||
| 41 | force-reload) | ||
| 42 | stopdaemon | ||
| 43 | settick | ||
| 44 | startdaemon -g | ||
| 45 | ;; | ||
| 46 | restart) | ||
| 47 | # Don't reset the tick here | ||
| 48 | stopdaemon | ||
| 49 | startdaemon -g | ||
| 50 | ;; | ||
| 51 | reload) | ||
| 52 | # Must do this by hand, but don't do -g | ||
| 53 | stopdaemon | ||
| 54 | startdaemon | ||
| 55 | ;; | ||
| 56 | *) | ||
| 57 | echo "Usage: ntpd { start | stop | restart | reload }" >&2 | ||
| 58 | exit 1 | ||
| 59 | ;; | ||
| 60 | esac | ||
| 61 | |||
| 62 | exit 0 | ||
