summaryrefslogtreecommitdiff
path: root/examples/var_service/dhcp_if_pinger
diff options
context:
space:
mode:
authorDenys Vlasenko2009-11-06 04:04:19 +0100
committerDenys Vlasenko2009-11-06 04:04:19 +0100
commit6cf7f01256c39677a0a5561ebca60e8def9d6d7e (patch)
tree9751616a6653806d6703da369616d74e38f8b785 /examples/var_service/dhcp_if_pinger
parent85bb843f47342b19c4f0814331c1f4c78b0011ad (diff)
downloadbusybox-6cf7f01256c39677a0a5561ebca60e8def9d6d7e.zip
busybox-6cf7f01256c39677a0a5561ebca60e8def9d6d7e.tar.gz
adding example runit-style service directory
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'examples/var_service/dhcp_if_pinger')
-rwxr-xr-xexamples/var_service/dhcp_if_pinger/run23
1 files changed, 23 insertions, 0 deletions
diff --git a/examples/var_service/dhcp_if_pinger/run b/examples/var_service/dhcp_if_pinger/run
new file mode 100755
index 0000000..20b2fc5
--- /dev/null
+++ b/examples/var_service/dhcp_if_pinger/run
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+delay=67
+
+if=${PWD##*/dhcp_}
+if=${if%%_pinger}
+
+if test -f "$0.log"; then
+ tail -999 "$0.log" >"$0.log.new"
+ mv "$0.log.new" "$0.log"
+fi
+
+test -f "/var/service/dhcp_$if/dhcp_$if.out" || exec env - sleep "$delay"
+. "/var/service/dhcp_$if/dhcp_$if.out"
+test x"$router" != x"" || exec env - sleep "$delay"
+
+#echo "`date '+%Y-%m-%d %H:%M:%S'` Testing ping -c3 $router" >>"$0.log"
+ping -c3 "$router" && exec env - sleep "$delay"
+
+echo "`date '+%Y-%m-%d %H:%M:%S'` Restarting /var/service/dhcp_$if" >>"$0.log"
+sv t "/var/service/dhcp_$if"
+
+exec env - sleep "$delay"