diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-07-03 17:02:50 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-07-03 17:02:50 +0200 |
| commit | aa75a7da7f3b0bb50be82f535244137bae423fa8 (patch) | |
| tree | 781df3664a0f5b29cb4a8b715c28ac75b4c1584c /examples | |
| parent | e5d5f5b9a770de5a48d1a3bd293d5d611d6624c4 (diff) | |
| download | busybox-w32-aa75a7da7f3b0bb50be82f535244137bae423fa8.tar.gz busybox-w32-aa75a7da7f3b0bb50be82f535244137bae423fa8.tar.bz2 busybox-w32-aa75a7da7f3b0bb50be82f535244137bae423fa8.zip | |
examples/var_service/: use "svc" for service commands, other tweaks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'examples')
| -rwxr-xr-x | examples/var_service/dhcp_if/dhcp_handler | 10 | ||||
| -rwxr-xr-x | examples/var_service/dhcp_if/finish | 2 | ||||
| -rwxr-xr-x | examples/var_service/dhcp_if_pinger/run | 16 | ||||
| -rw-r--r-- | examples/var_service/fw/etc/dnsmasq_servers.conf | 2 | ||||
| -rwxr-xr-x | examples/var_service/fw/run | 2 | ||||
| -rwxr-xr-x | examples/var_service/ntpd/run | 25 | ||||
| -rwxr-xr-x | examples/var_service/zcip_if/finish | 4 | ||||
| -rwxr-xr-x | examples/var_service/zcip_if/zcip_handler | 4 |
8 files changed, 35 insertions, 30 deletions
diff --git a/examples/var_service/dhcp_if/dhcp_handler b/examples/var_service/dhcp_if/dhcp_handler index 3d44a6022..6a97e8543 100755 --- a/examples/var_service/dhcp_if/dhcp_handler +++ b/examples/var_service/dhcp_if/dhcp_handler | |||
| @@ -52,7 +52,7 @@ if test x"$1" != x"bound" && test x"$1" != x"renew" ; then | |||
| 52 | rm "$file_ntpconf" | 52 | rm "$file_ntpconf" |
| 53 | rm "$dir_ipconf/$file_ipconf" | 53 | rm "$dir_ipconf/$file_ipconf" |
| 54 | rm "$dir_ntpconf/$file_ntpconf" | 54 | rm "$dir_ntpconf/$file_ntpconf" |
| 55 | sv u /var/service/fw | 55 | svc -u fw |
| 56 | exit | 56 | exit |
| 57 | fi | 57 | fi |
| 58 | 58 | ||
| @@ -67,10 +67,10 @@ if test $? != 0; then | |||
| 67 | echo "Reconfiguring fw" | 67 | echo "Reconfiguring fw" |
| 68 | mkdir -p "$dir_ipconf" 2>/dev/null | 68 | mkdir -p "$dir_ipconf" 2>/dev/null |
| 69 | cp "$file_ipconf" "$dir_ipconf/$file_ipconf" | 69 | cp "$file_ipconf" "$dir_ipconf/$file_ipconf" |
| 70 | sv u /var/service/fw | 70 | svc -u fw |
| 71 | fi | 71 | fi |
| 72 | 72 | ||
| 73 | if test -d /var/service/ntpd; then | 73 | if test -d ../ntpd; then |
| 74 | ./convert2ntpconf "$file_ntpconf" | 74 | ./convert2ntpconf "$file_ntpconf" |
| 75 | # Reconfigure ntp server addresses if needed | 75 | # Reconfigure ntp server addresses if needed |
| 76 | diff --brief "$file_ntpconf" "$dir_ntpconf/$file_ntpconf" >/dev/null 2>&1 | 76 | diff --brief "$file_ntpconf" "$dir_ntpconf/$file_ntpconf" >/dev/null 2>&1 |
| @@ -78,7 +78,7 @@ if test -d /var/service/ntpd; then | |||
| 78 | echo "Reconfiguring ntp" | 78 | echo "Reconfiguring ntp" |
| 79 | mkdir -p "$dir_ntpconf" 2>/dev/null | 79 | mkdir -p "$dir_ntpconf" 2>/dev/null |
| 80 | cp "$file_ntpconf" "$dir_ntpconf/$file_ntpconf" | 80 | cp "$file_ntpconf" "$dir_ntpconf/$file_ntpconf" |
| 81 | sv t /var/service/ntpd | 81 | svc -t ntpd |
| 82 | sv u /var/service/ntpd | 82 | svc -u ntpd |
| 83 | fi | 83 | fi |
| 84 | fi | 84 | fi |
diff --git a/examples/var_service/dhcp_if/finish b/examples/var_service/dhcp_if/finish index 5e7667a2d..8ce188336 100755 --- a/examples/var_service/dhcp_if/finish +++ b/examples/var_service/dhcp_if/finish | |||
| @@ -14,4 +14,4 @@ rm "$file_ipconf" | |||
| 14 | rm "$file_ntpconf" | 14 | rm "$file_ntpconf" |
| 15 | rm "$dir_ipconf/$file_ipconf" | 15 | rm "$dir_ipconf/$file_ipconf" |
| 16 | rm "$dir_ntpconf/$file_ntpconf" | 16 | rm "$dir_ntpconf/$file_ntpconf" |
| 17 | sv u /var/service/fw | 17 | svc -u fw |
diff --git a/examples/var_service/dhcp_if_pinger/run b/examples/var_service/dhcp_if_pinger/run index 8aca90c1a..25341243f 100755 --- a/examples/var_service/dhcp_if_pinger/run +++ b/examples/var_service/dhcp_if_pinger/run | |||
| @@ -21,9 +21,9 @@ if test -f "$0.log"; then | |||
| 21 | mv "$0.log.new" "$0.log" | 21 | mv "$0.log.new" "$0.log" |
| 22 | fi | 22 | fi |
| 23 | 23 | ||
| 24 | test -f "/var/service/dhcp_$if/env.out" || exec env - sleep "$ping_time" | 24 | test -f "../dhcp_$if/env.out" || exec env - sleep "$ping_time" |
| 25 | 25 | ||
| 26 | . "/var/service/dhcp_$if/env.out" | 26 | . "../dhcp_$if/env.out" |
| 27 | test x"$router" != x"" || exec env - sleep "$ping_time" | 27 | test x"$router" != x"" || exec env - sleep "$ping_time" |
| 28 | 28 | ||
| 29 | #msg "Pinging $router" | 29 | #msg "Pinging $router" |
| @@ -36,12 +36,12 @@ while true; do | |||
| 36 | env - sleep "$retry_time" | 36 | env - sleep "$retry_time" |
| 37 | done | 37 | done |
| 38 | 38 | ||
| 39 | test -d "/var/service/dhcp_$if" && { | 39 | test -d "../dhcp_$if" && { |
| 40 | msg "Restarting /var/service/dhcp_$if" | 40 | msg "Restarting dhcp_$if" |
| 41 | sv t "/var/service/dhcp_$if" | 41 | svc -t "dhcp_$if" |
| 42 | } | 42 | } |
| 43 | test -d "/var/service/supplicant_$if" && { | 43 | test -d "../supplicant_$if" && { |
| 44 | msg "Restarting /var/service/supplicant_$if" | 44 | msg "Restarting supplicant_$if" |
| 45 | sv t "/var/service/supplicant_$if" | 45 | svc -t "supplicant_$if" |
| 46 | } | 46 | } |
| 47 | exec env - sleep "$ping_time" | 47 | exec env - sleep "$ping_time" |
diff --git a/examples/var_service/fw/etc/dnsmasq_servers.conf b/examples/var_service/fw/etc/dnsmasq_servers.conf index 68313605f..c39fe6e43 100644 --- a/examples/var_service/fw/etc/dnsmasq_servers.conf +++ b/examples/var_service/fw/etc/dnsmasq_servers.conf | |||
| @@ -35,4 +35,4 @@ $empty && echo "server=8.8.8.8" | |||
| 35 | $empty && echo "server=8.8.4.4" | 35 | $empty && echo "server=8.8.4.4" |
| 36 | 36 | ||
| 37 | # SIGHUP: make dnsmasq reload config | 37 | # SIGHUP: make dnsmasq reload config |
| 38 | sv h dnsmasq | 38 | svc -h dnsmasq |
diff --git a/examples/var_service/fw/run b/examples/var_service/fw/run index 1fd71cc01..41078d0ab 100755 --- a/examples/var_service/fw/run +++ b/examples/var_service/fw/run | |||
| @@ -8,7 +8,7 @@ extif="if" | |||
| 8 | ext_open_tcp="22 80 88" # space-separated | 8 | ext_open_tcp="22 80 88" # space-separated |
| 9 | 9 | ||
| 10 | # Make ourself one-shot | 10 | # Make ourself one-shot |
| 11 | sv o . | 11 | svc -o . |
| 12 | # Debug | 12 | # Debug |
| 13 | #date '+%Y-%m-%d %H:%M:%S' >>"$0.log" | 13 | #date '+%Y-%m-%d %H:%M:%S' >>"$0.log" |
| 14 | 14 | ||
diff --git a/examples/var_service/ntpd/run b/examples/var_service/ntpd/run index 6f2a68188..5c90aad41 100755 --- a/examples/var_service/ntpd/run +++ b/examples/var_service/ntpd/run | |||
| @@ -6,12 +6,22 @@ exec 2>&1 | |||
| 6 | exec </dev/null | 6 | exec </dev/null |
| 7 | 7 | ||
| 8 | user=root | 8 | user=root |
| 9 | start_delay=15 | ||
| 10 | net_down_delay=5 | ||
| 9 | pool="us.pool.ntp.org" # replace "us" with your country code | 11 | pool="us.pool.ntp.org" # replace "us" with your country code |
| 10 | 12 | ||
| 11 | service="${PWD##*/}" | 13 | service="${PWD##*/}" |
| 12 | rundir="/var/run/service/$service" | 14 | rundir="/var/run/service/$service" |
| 13 | default_p_opt="-p 0.$pool -p 1.$pool -p 2.$pool -p 3.$pool" | 15 | default_p_opt="-p 0.$pool -p 1.$pool -p 2.$pool -p 3.$pool" |
| 14 | 16 | ||
| 17 | echo "* Checking network" | ||
| 18 | test -f /var/run/service/fw/up || exec sleep $net_down_delay | ||
| 19 | |||
| 20 | # With multiple interfaces (e.g. wired+wireless) going up, | ||
| 21 | # networking scripts may restart ntpd service several times | ||
| 22 | # in quick succession. Do not be too eager to start sending | ||
| 23 | # NTP requests: | ||
| 24 | sleep $start_delay | ||
| 15 | 25 | ||
| 16 | # Make sure rundir/ exists | 26 | # Make sure rundir/ exists |
| 17 | mkdir -p "$rundir" 2>/dev/null | 27 | mkdir -p "$rundir" 2>/dev/null |
| @@ -20,30 +30,25 @@ chmod -R a=rX "$rundir" | |||
| 20 | rm -rf rundir 2>/dev/null | 30 | rm -rf rundir 2>/dev/null |
| 21 | ln -s "$rundir" rundir | 31 | ln -s "$rundir" rundir |
| 22 | 32 | ||
| 23 | |||
| 24 | echo "* Checking network" | ||
| 25 | test -f /var/run/service/fw/up || exec sleep 7 | ||
| 26 | sleep 5 # to let it settle | ||
| 27 | |||
| 28 | # Grab config from dhcp | 33 | # Grab config from dhcp |
| 29 | cfg=-1 | 34 | cfg=-1 |
| 30 | for f in rundir/*.ntpconf; do | 35 | for f in rundir/*.ntpconf; do |
| 31 | test -f "$f" || continue | 36 | test -f "$f" || continue |
| 32 | . "$f" | 37 | . "$f" |
| 33 | done | 38 | done |
| 34 | 39 | ||
| 35 | # Select peers | 40 | # Select peers |
| 36 | p_opt="" | 41 | p_opt="" |
| 37 | cfg=0 | 42 | cfg=0 |
| 38 | while test x"${ntpip[$cfg]}" != x""; do | 43 | while test x"${ntpip[$cfg]}" != x""; do |
| 39 | p_opt="$p_opt -p ${ntpip[$cfg]}" | 44 | p_opt="$p_opt -p ${ntpip[$cfg]}" |
| 40 | let cfg=cfg+1 | 45 | let cfg=cfg+1 |
| 41 | done | 46 | done |
| 42 | test x"$p_opt" == x"" && p_opt="$default_p_opt" | 47 | test x"$p_opt" == x"" && p_opt="$default_p_opt" |
| 43 | 48 | ||
| 44 | if test x"$p_opt" == x""; then | 49 | if test x"$p_opt" == x""; then |
| 45 | echo "* No NTP peers configured, stopping" | 50 | echo "* No NTP peers configured, stopping" |
| 46 | sv o . | 51 | svc -o . |
| 47 | exec sleep 1 | 52 | exec sleep 1 |
| 48 | fi | 53 | fi |
| 49 | 54 | ||
diff --git a/examples/var_service/zcip_if/finish b/examples/var_service/zcip_if/finish index 95995cf5f..7955cf3b8 100755 --- a/examples/var_service/zcip_if/finish +++ b/examples/var_service/zcip_if/finish | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | # executed when service is taken down ("sv d .") | 2 | # executed when service is taken down |
| 3 | 3 | ||
| 4 | service=${PWD##*/} | 4 | service=${PWD##*/} |
| 5 | file_ipconf="$service.ipconf" | 5 | file_ipconf="$service.ipconf" |
| @@ -10,4 +10,4 @@ echo "Finish: deconfiguring" | |||
| 10 | rm "env.out" | 10 | rm "env.out" |
| 11 | rm "$file_ipconf" | 11 | rm "$file_ipconf" |
| 12 | rm "$dir_ipconf/$file_ipconf" | 12 | rm "$dir_ipconf/$file_ipconf" |
| 13 | sv u /var/service/fw | 13 | svc -u fw |
diff --git a/examples/var_service/zcip_if/zcip_handler b/examples/var_service/zcip_if/zcip_handler index 3c6ca788b..625450f7b 100755 --- a/examples/var_service/zcip_if/zcip_handler +++ b/examples/var_service/zcip_if/zcip_handler | |||
| @@ -28,7 +28,7 @@ if test x"$1" != x"config"; then | |||
| 28 | echo "Deconfiguring" | 28 | echo "Deconfiguring" |
| 29 | rm "$file_ipconf" | 29 | rm "$file_ipconf" |
| 30 | rm "$dir_ipconf/$file_ipconf" | 30 | rm "$dir_ipconf/$file_ipconf" |
| 31 | sv u /var/service/fw | 31 | svc -u fw |
| 32 | exit | 32 | exit |
| 33 | fi | 33 | fi |
| 34 | 34 | ||
| @@ -43,5 +43,5 @@ if test $? != 0; then | |||
| 43 | echo "Reconfiguring fw" | 43 | echo "Reconfiguring fw" |
| 44 | mkdir -p "$dir_ipconf" 2>/dev/null | 44 | mkdir -p "$dir_ipconf" 2>/dev/null |
| 45 | cp "$file_ipconf" "$dir_ipconf/$file_ipconf" | 45 | cp "$file_ipconf" "$dir_ipconf/$file_ipconf" |
| 46 | sv u /var/service/fw | 46 | svc -u fw |
| 47 | fi | 47 | fi |
