diff options
author | James <> | 2015-11-04 11:49:21 +0000 |
---|---|---|
committer | James <> | 2015-11-04 11:49:21 +0000 |
commit | 716ca530e1c4515d8683c9d5be3d56b301758b66 (patch) | |
tree | 700eb5bcc1a462a5f21dcec15ce7c97ecfefa772 /package/utils/busybox/files/sysntpd | |
download | trunk-47381-master.tar.gz trunk-47381-master.tar.bz2 trunk-47381-master.zip |
Diffstat (limited to 'package/utils/busybox/files/sysntpd')
-rwxr-xr-x | package/utils/busybox/files/sysntpd | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/package/utils/busybox/files/sysntpd b/package/utils/busybox/files/sysntpd new file mode 100755 index 0000000..f73bb83 --- /dev/null +++ b/package/utils/busybox/files/sysntpd @@ -0,0 +1,42 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2011 OpenWrt.org + +START=98 + +USE_PROCD=1 +PROG=/usr/sbin/ntpd +HOTPLUG_SCRIPT=/usr/sbin/ntpd-hotplug + +validate_ntp_section() { + uci_validate_section system timeserver "${1}" \ + 'server:list(host)' 'enabled:bool:1' 'enable_server:bool:0' +} + +start_service() { + local server enabled enable_server peer + + validate_ntp_section ntp || { + echo "validation failed" + return 1 + } + + [ $enabled = 0 ] && return + + [ -z "$server" ] && return + + procd_open_instance + procd_set_param command "$PROG" -n + [ "$enable_server" = "1" ] && procd_append_param command -l + [ -x "$HOTPLUG_SCRIPT" ] && procd_append_param command -S "$HOTPLUG_SCRIPT" + for peer in $server; do + procd_append_param command -p $peer + done + procd_set_param respawn + procd_close_instance +} + +service_triggers() +{ + procd_add_reload_trigger "system" + procd_add_validation validate_ntp_section +} |