summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-04-20 15:05:38 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-04-20 15:05:38 +0000
commit3c4165a305715c9980c8e4f5348edd7984fed62a (patch)
treeea35e26cb2d09f2433b30b63b170bfe1a1946fea /package
parent5c33f4e3053e3ab9ea2862015ed1dc20a085ab4b (diff)
downloadmtk-20170518-3c4165a305715c9980c8e4f5348edd7984fed62a.zip
mtk-20170518-3c4165a305715c9980c8e4f5348edd7984fed62a.tar.gz
mtk-20170518-3c4165a305715c9980c8e4f5348edd7984fed62a.tar.bz2
enable ntpd server for busybox
hi Another version, in this one the enable_server option is in the timeserver ntp part of the "system" config file You can patch trunk and bacfire (tested both) You can put busybox ntpd in client mode (if you put server), in client & server (by putting enable_server to 1, ntpd listen to udp 123), and also in server mode only (if you didn't put any servers in the config and still put enable_server 1, ntpd will answer with the time of the router) I've replaced "config_foreach getpeers timeserver" with "config_get peers ntp server" because we want ntp timeserver, not random ones (to pre-answer if someone want to say that it's intrusive ...) Signed-off-by: Etienne CHAMPETIER <etienne.champetier@free.fr> Le 27/03/2012 20:41, Etienne Champetier a écrit : > I've now tested my trunk patch and it works fine > But I still can't find were $PROG is defined (is this a mistake, or some sort of built in variable???) > (I've made some grep and nothing) > > Le 23/03/2012 02:19, Philip Prindeville a écrit : >> Maybe: >> >> [ -n "$PROG" -a -x "$PROG" ] || return 1 >> >> instead? >> >> >> On 3/22/12 4:34 PM, Etienne Champetier wrote: >>> Hi >>> >>> The 2 attached patchs (trunk & bacfire) add busybox ntpd enable_server option, as busybox ntpd server is compiled by default. >>> We only need 1 client/server daemon (olipro patch was launching 2 daemons) >>> I've fully tested the bacfire patch, and as i don't have a running openwrt trunk i'm not sure for the trunk patch (i'm sure about my modifications, but i'm not sure about "[ -x $PROG ] || return 1", as "$PROG" isn't defined ?!) >>> >>> Signed-off-by: Etienne CHAMPETIER <etienne.champetier@free.fr> >>> >>> >>> Le 16/01/2012 01:57, Philip Prindeville a écrit : >>>> On 1/14/12 11:37 AM, Olipro wrote: >>>>> On Saturday 14 Jan 2012 02:45:59 Philip Prindeville wrote: >>>>>> Don't we already have a 'disabled' option? Now we're adding an >>>>>> 'enable_server' option? >>>>>> >>>>>> That seems confusing for no useful reason. >>>>>> >>>>> have you bothered to read what I originally wrote? your response would make >>>>> me inclined to believe that you didn't. >>>>> >>>>> currently the ntpd initscript only runs it as a CLIENT - this patch enables >>>>> you to have one instance running as a client and another as a SERVER that >>>>> other hosts can synchronise with. >>>>> >>>>> Or perhaps I'm misunderstanding, what would you propose for allowing the >>>>> built-in busybox ntpd to be utilised as a server? a separate init script >>>>> entirely perhaps? >>>> Or separate config sections... instead of 'config ntp' have 'config ntp-server' and 'config ntp-client'. >>>> >>>> -Philip >>>> >>>> >>>> _______________________________________________ >>>> openwrt-devel mailing list >>>> openwrt-devel@lists.openwrt.org >>>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel >> _______________________________________________ >> openwrt-devel mailing list >> openwrt-devel@lists.openwrt.org >> https://lists.openwrt.org/mailman/listinfo/openwrt-devel > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/mailman/listinfo/openwrt-devel SVN-Revision: 31374
Diffstat (limited to 'package')
-rw-r--r--package/base-files/files/etc/config/system1
-rwxr-xr-xpackage/base-files/files/etc/init.d/sysntpd18
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
}