add ntpclient count option and exit after a successful sync closes #1835 Thanks Carlo...
authorTravis Kemen <thepeople@openwrt.org>
Thu, 28 Jun 2007 21:04:47 +0000 (21:04 +0000)
committerTravis Kemen <thepeople@openwrt.org>
Thu, 28 Jun 2007 21:04:47 +0000 (21:04 +0000)
SVN-Revision: 7763

net/ntpclient/files/ntpclient.init

index 0689a75001b4628f78befc2af88f9ab206917445..306c2816fb93a61ffb533365224d08837382e356 100644 (file)
@@ -3,6 +3,7 @@
 
 . /etc/functions.sh
 
+DONE=0
 config_cb() {
        local cfg="$CONFIG_SECTION"
        local cfgtype
@@ -12,10 +13,12 @@ config_cb() {
                ntp_client)
                        config_get hostname     $cfg hostname
                        config_get port         $cfg port
-                       
+                       config_get count        $cfg count                      
+
+                       [ "$DONE" = "1" ] && exit 0
                        ps x | grep 'bin/[n]tpclient' >&- || {
                                route -n 2>&- | grep '^0.0.0.0' >&- && {
-                                       /usr/sbin/ntpclient -h $hostname -p ${port:-123} 2>&- >&-
+                                       /usr/sbin/ntpclient -c ${count:-1} -s -h $hostname -p ${port:-123} 2>&- >&- && DONE=1
                                }
                        }
                ;;