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.champet...@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
Index: package/base-files/files/etc/config/system
===================================================================
--- package/base-files/files/etc/config/system  (revision 31055)
+++ package/base-files/files/etc/config/system  (working copy)
@@ -7,3 +7,6 @@
        list server     1.openwrt.pool.ntp.org
        list server     2.openwrt.pool.ntp.org
        list server     3.openwrt.pool.ntp.org
+
+config busybox ntpd
+       option enable_server 0
\ No newline at end of file
Index: package/base-files/files/etc/init.d/sysntpd
===================================================================
--- package/base-files/files/etc/init.d/sysntpd (revision 31055)
+++ package/base-files/files/etc/init.d/sysntpd (working copy)
@@ -10,6 +10,8 @@
        [ -x $BIN ] || exit 0
 
        local peers
+       local args="-n"
+       local enable_server
 
        getpeers() {
                config_get peers "$1" server
@@ -17,14 +19,20 @@
 
        config_load system
        config_foreach getpeers timeserver
+       config_get_bool enable_server ntpd 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
                start-stop-daemon -x $BIN -m -p $PID -b -S -- $args
        fi
 }
Index: package/base-files/files/etc/config/system
===================================================================
--- package/base-files/files/etc/config/system  (revision 31054)
+++ package/base-files/files/etc/config/system  (working copy)
@@ -7,3 +7,6 @@
        list server     1.openwrt.pool.ntp.org
        list server     2.openwrt.pool.ntp.org
        list server     3.openwrt.pool.ntp.org
+
+config busybox ntpd
+       option enable_server 0
\ No newline at end of file
Index: package/base-files/files/etc/init.d/sysntpd
===================================================================
--- package/base-files/files/etc/init.d/sysntpd (revision 31054)
+++ package/base-files/files/etc/init.d/sysntpd (working copy)
@@ -11,6 +11,8 @@
        [ -x $PROG ] || return 1
 
        local peers
+       local args="-n"
+       local enable_server
 
        getpeers() {
                config_get peers "$1" server
@@ -18,14 +20,20 @@
 
        config_load system
        config_foreach getpeers timeserver
+       config_get_bool enable_server ntpd 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
 }
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to