Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/examples/var_service/dhcp_if_pinger/run

    r2725 r3621  
    11#!/bin/sh
    22
    3 delay=67
    4 
     3# How often to test, seconds
     4ping_time=67
     5# "One ping, must have reply in 1 sec"
     6ping_opts="-c1 -W1 -w1"
     7# If ping failed, how soon to retry
     8retry_time=5
     9# Reinit after this many consecutive ping error
     10max_fail=5
     11# Interface whose DHCP data to use
    512if=${PWD##*/dhcp_}
    613if=${if%%_pinger}
     14
     15msg() {
     16    echo "`date '+%Y-%m-%d %H:%M:%S'` $*" >>"$0.log"
     17}
    718
    819if test -f "$0.log"; then
     
    1122fi
    1223
    13 test -f "/var/service/dhcp_$if/dhcp_$if.out" || exec env - sleep "$delay"
    14 . "/var/service/dhcp_$if/dhcp_$if.out"
    15 test x"$router" != x"" || exec env - sleep "$delay"
     24test -f "/var/service/dhcp_$if/env.out" || exec env - sleep "$ping_time"
    1625
    17 #echo "`date '+%Y-%m-%d %H:%M:%S'` Testing ping -c3 $router" >>"$0.log"
    18 ping -c3 "$router" && exec env - sleep "$delay"
     26. "/var/service/dhcp_$if/env.out"
     27test x"$router" != x"" || exec env - sleep "$ping_time"
    1928
    20 echo "`date '+%Y-%m-%d %H:%M:%S'` Restarting /var/service/dhcp_$if" >>"$0.log"
    21 sv t "/var/service/dhcp_$if"
     29#msg "Pinging $router"
     30failcnt=0
     31while true; do
     32    ping $ping_opts "$router" && exec env - sleep "$ping_time"
     33    : $((failcnt++))
     34    msg "Failed to ping $router, fail count:$failcnt"
     35    test $failcnt -ge $max_fail && break
     36    env - sleep "$retry_time"
     37done
    2238
    23 exec env - sleep "$delay"
     39test -d "/var/service/dhcp_$if" && {
     40    msg "Restarting /var/service/dhcp_$if"
     41    sv t "/var/service/dhcp_$if"
     42}
     43test -d "/var/service/supplicant_$if" && {
     44    msg "Restarting /var/service/supplicant_$if"
     45    sv t "/var/service/supplicant_$if"
     46}
     47exec env - sleep "$ping_time"
Note: See TracChangeset for help on using the changeset viewer.