aboutsummaryrefslogtreecommitdiffstats
path: root/package/utils/busybox/files/sysntpd
diff options
context:
space:
mode:
authorJames <>2015-11-04 11:49:21 +0000
committerJames <>2015-11-04 11:49:21 +0000
commit716ca530e1c4515d8683c9d5be3d56b301758b66 (patch)
tree700eb5bcc1a462a5f21dcec15ce7c97ecfefa772 /package/utils/busybox/files/sysntpd
downloadtrunk-47381-716ca530e1c4515d8683c9d5be3d56b301758b66.tar.gz
trunk-47381-716ca530e1c4515d8683c9d5be3d56b301758b66.tar.bz2
trunk-47381-716ca530e1c4515d8683c9d5be3d56b301758b66.zip
trunk-47381HEADmaster
Diffstat (limited to 'package/utils/busybox/files/sysntpd')
-rwxr-xr-xpackage/utils/busybox/files/sysntpd42
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
+}