add hotplug stuff to trunk/
[openwrt/svn-archive/archive.git] / openwrt / package / ntpclient / files / ntpclient.init
index 923022bfccbcf332467e83119be06930521577cb..2ad4beb77397228cbdb87a9fd91f6c6262c4157a 100644 (file)
@@ -1,2 +1,11 @@
 #!/bin/sh
-/usr/sbin/ntpclient -c 1 -s -h pool.ntp.org &
+server=$(nvram get ntp_server)
+case "$ACTION" in
+       ifup)
+               ps x | grep '[n]tpclient' >&- || {
+                       route -n 2>&- | grep '0.0.0.0' >&- && /usr/sbin/ntpclient -c 1 -s -h ${server:-pool.ntp.org} &
+               }
+               ;;
+       ifdown)
+               route -n 2>&- | grep '0.0.0.0' >&- || killall ntpclient 2>&- >&- ;;
+esac