ntpclient: add init script launching ntpclient as bg process
authorFelix Fietkau <nbd@openwrt.org>
Sat, 2 Feb 2008 02:14:00 +0000 (02:14 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sat, 2 Feb 2008 02:14:00 +0000 (02:14 +0000)
This is to introduce a new init script that can launch ntpclient
again after the hotplug invocation running with -l option to
adjust local time and clock shift continuously.
Please check, if this closes ticket 2292.
 (see https://dev.openwrt.org/ticket/2292)

Signed-off-by: Steffen Hoffmann <hoff.st@shaas.net>
SVN-Revision: 10356

net/ntpclient/files/ntpclient.init [new file with mode: 0644]

diff --git a/net/ntpclient/files/ntpclient.init b/net/ntpclient/files/ntpclient.init
new file mode 100644 (file)
index 0000000..b9c71c5
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008 OpenWrt.org
+
+START=80 
+
+config_cb() {
+       local cfg="$CONFIG_SECTION"
+       local cfgtype
+       config_get cfgtype "$cfg" TYPE
+
+       case "$cfgtype" in
+               ntpclient)
+                       config_get hostname     $cfg hostname
+                       config_get port         $cfg port
+
+                       # prepare for continuos operation
+                       count=0 # unlimited
+                       ps | grep 'bin/[n]tpclient' >&- || {
+                               while true; do
+                                       ping -c 1 $hostname 2>&- >&- && {
+                                       /usr/sbin/ntpclient -c ${count:-1} -l -h $hostname -p ${port:-123} 2>&- >&- &
+                                       } && return
+                                       sleep 3
+                               done
+                       }
+               ;;
+       esac
+}
+
+start() {
+       config_load ntpclient&
+}
+
+stop() {
+       killall ntpclient 2>&- >&-
+}