ntpclient: initial frequency offset configuration and adjtimex invocation
[openwrt/svn-archive/archive.git] / net / ntpclient / files / ntpclient.hotplug
index a3ce8b859ab2e36282ffa99247fe60455cab899e..403be9d6125428ed84f4a839f0f9f8b50004f63b 100644 (file)
@@ -9,14 +9,25 @@ config_cb() {
        local cfgtype
        config_get cfgtype "$cfg" TYPE
 
+       # initial frequency offset, if configured
+       case "$cfgtype" in
+               ntpdrift)
+                       config_get freq         $cfg freq
+
+                       if [ ! "$freq" = "" ]; then
+                               adjtimex -f $freq
+                       fi
+               ;;
+       esac
+
        case "$cfgtype" in
                ntpclient)
                        config_get hostname     $cfg hostname
                        config_get port         $cfg port
-                       config_get count        $cfg count                      
+                       config_get count        $cfg count
 
                        [ "$DONE" = "1" ] && exit 0
-                       ps | grep 'bin/[n]tpclient' >&- || {
+                       ps | grep 'bin/[n]tpclient' >&- || {
                                route -n 2>&- | grep '^0.0.0.0' >&- && {
                                        /usr/sbin/ntpclient -c ${count:-1} -s -h $hostname -p ${port:-123} 2>&- >&- && DONE=1
                                }