summaryrefslogtreecommitdiff
path: root/net/ntpd
diff options
context:
space:
mode:
authorJeffery To <jeffery.to@gmail.com>2019-02-03 16:34:36 +0800
committertripolar <tripolar@users.noreply.github.com>2019-02-26 20:46:30 +0100
commita214ce9f5b520a3cb479250b351f2eaead4ed0bc (patch)
tree9f3edb79225e39ef5c7b5c9f42c81569d4cef71a /net/ntpd
parent9754ee1dcc8d99a21fc10924c21dd763b95bcf35 (diff)
ntpd: Update init script
This replaces the use of uci_validate_section() with uci_load_validate(), which removes the need to declare local variables for every config option. This also moves the generated config file to /var/etc and adds a service_triggers() function. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Diffstat (limited to 'net/ntpd')
-rw-r--r--net/ntpd/Makefile2
-rw-r--r--net/ntpd/files/ntpd.init19
2 files changed, 15 insertions, 6 deletions
diff --git a/net/ntpd/Makefile b/net/ntpd/Makefile
index 8c16d7b28..386d37d36 100644
--- a/net/ntpd/Makefile
+++ b/net/ntpd/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=ntp
PKG_VERSION:=4.2.8p12
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/
diff --git a/net/ntpd/files/ntpd.init b/net/ntpd/files/ntpd.init
index 0aaf132a4..6e73489d4 100644
--- a/net/ntpd/files/ntpd.init
+++ b/net/ntpd/files/ntpd.init
@@ -8,7 +8,7 @@ USE_PROCD=1
PROG=/sbin/ntpd
HOTPLUG_HELPER=/usr/sbin/ntpd.hotplug-helper
-config_file=/var/run/ntpd.conf
+config_file=/var/etc/ntpd.conf
trunc() {
echo -n "" > $config_file
@@ -19,15 +19,15 @@ emit() {
}
validate_ntp_section() {
- uci_validate_section system timeserver "${1}" \
+ uci_load_validate system timeserver "$1" "$2" \
'server:list(host)' 'enabled:bool:1' 'enable_server:bool:0' \
'interface:list(string)'
}
-start_service() {
- local server enabled enable_server interface intf
+start_ntpd_instance() {
+ local intf i
- validate_ntp_section ntp || {
+ [ "$2" = 0 ] || {
echo "validation failed"
return 1
}
@@ -85,3 +85,12 @@ start_service() {
procd_set_param command $HOTPLUG_HELPER
procd_close_instance
}
+
+start_service() {
+ validate_ntp_section ntp start_ntpd_instance
+}
+
+service_triggers() {
+ procd_add_reload_trigger "system"
+ procd_add_validation validate_ntp_section
+}