diff options
-rw-r--r-- | package/base-files/files/etc/config/system | 1 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/sysntpd | 18 |
2 files changed, 11 insertions, 8 deletions
diff --git a/package/base-files/files/etc/config/system b/package/base-files/files/etc/config/system index 314f291..d2124e4 100644 --- a/package/base-files/files/etc/config/system +++ b/package/base-files/files/etc/config/system @@ -7,3 +7,4 @@ config timeserver ntp list server 1.openwrt.pool.ntp.org list server 2.openwrt.pool.ntp.org list server 3.openwrt.pool.ntp.org + option enable_server 0 diff --git a/package/base-files/files/etc/init.d/sysntpd b/package/base-files/files/etc/init.d/sysntpd index aa35da8..bb42ef7 100755 --- a/package/base-files/files/etc/init.d/sysntpd +++ b/package/base-files/files/etc/init.d/sysntpd @@ -8,24 +8,26 @@ SERVICE_WRITE_PID=1 SERVICE_PID_FILE=/var/run/sysntpd.pid start() { - [ -x $PROG ] || return 1 - local peers - - getpeers() { - config_get peers "$1" server - } + local args="-n" + local enable_server config_load system - config_foreach getpeers timeserver + config_get peers ntp server + config_get_bool enable_server ntp enable_server 0 + + if [ $enable_server -ne 0 ]; then + append args "-l" + fi if [ -n "$peers" ]; then local peer - local args="-n" for peer in $peers; do append args "-p $peer" done + fi + if [ "$args" != "-n" ]; then service_start /usr/sbin/ntpd $args fi } |