aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-07-03 17:02:50 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-07-03 17:02:50 +0200
commitaa75a7da7f3b0bb50be82f535244137bae423fa8 (patch)
tree781df3664a0f5b29cb4a8b715c28ac75b4c1584c
parente5d5f5b9a770de5a48d1a3bd293d5d611d6624c4 (diff)
downloadbusybox-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>
-rwxr-xr-xexamples/var_service/dhcp_if/dhcp_handler10
-rwxr-xr-xexamples/var_service/dhcp_if/finish2
-rwxr-xr-xexamples/var_service/dhcp_if_pinger/run16
-rw-r--r--examples/var_service/fw/etc/dnsmasq_servers.conf2
-rwxr-xr-xexamples/var_service/fw/run2
-rwxr-xr-xexamples/var_service/ntpd/run25
-rwxr-xr-xexamples/var_service/zcip_if/finish4
-rwxr-xr-xexamples/var_service/zcip_if/zcip_handler4
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
57fi 57fi
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
71fi 71fi
72 72
73if test -d /var/service/ntpd; then 73if 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
84fi 84fi
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"
14rm "$file_ntpconf" 14rm "$file_ntpconf"
15rm "$dir_ipconf/$file_ipconf" 15rm "$dir_ipconf/$file_ipconf"
16rm "$dir_ntpconf/$file_ntpconf" 16rm "$dir_ntpconf/$file_ntpconf"
17sv u /var/service/fw 17svc -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"
22fi 22fi
23 23
24test -f "/var/service/dhcp_$if/env.out" || exec env - sleep "$ping_time" 24test -f "../dhcp_$if/env.out" || exec env - sleep "$ping_time"
25 25
26. "/var/service/dhcp_$if/env.out" 26. "../dhcp_$if/env.out"
27test x"$router" != x"" || exec env - sleep "$ping_time" 27test 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"
37done 37done
38 38
39test -d "/var/service/dhcp_$if" && { 39test -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}
43test -d "/var/service/supplicant_$if" && { 43test -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}
47exec env - sleep "$ping_time" 47exec 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
38sv h dnsmasq 38svc -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"
8ext_open_tcp="22 80 88" # space-separated 8ext_open_tcp="22 80 88" # space-separated
9 9
10# Make ourself one-shot 10# Make ourself one-shot
11sv o . 11svc -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
6exec </dev/null 6exec </dev/null
7 7
8user=root 8user=root
9start_delay=15
10net_down_delay=5
9pool="us.pool.ntp.org" # replace "us" with your country code 11pool="us.pool.ntp.org" # replace "us" with your country code
10 12
11service="${PWD##*/}" 13service="${PWD##*/}"
12rundir="/var/run/service/$service" 14rundir="/var/run/service/$service"
13default_p_opt="-p 0.$pool -p 1.$pool -p 2.$pool -p 3.$pool" 15default_p_opt="-p 0.$pool -p 1.$pool -p 2.$pool -p 3.$pool"
14 16
17echo "* Checking network"
18test -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:
24sleep $start_delay
15 25
16# Make sure rundir/ exists 26# Make sure rundir/ exists
17mkdir -p "$rundir" 2>/dev/null 27mkdir -p "$rundir" 2>/dev/null
@@ -20,30 +30,25 @@ chmod -R a=rX "$rundir"
20rm -rf rundir 2>/dev/null 30rm -rf rundir 2>/dev/null
21ln -s "$rundir" rundir 31ln -s "$rundir" rundir
22 32
23
24echo "* Checking network"
25test -f /var/run/service/fw/up || exec sleep 7
26sleep 5 # to let it settle
27
28# Grab config from dhcp 33# Grab config from dhcp
29cfg=-1 34cfg=-1
30for f in rundir/*.ntpconf; do 35for f in rundir/*.ntpconf; do
31 test -f "$f" || continue 36 test -f "$f" || continue
32 . "$f" 37 . "$f"
33done 38done
34 39
35# Select peers 40# Select peers
36p_opt="" 41p_opt=""
37cfg=0 42cfg=0
38while test x"${ntpip[$cfg]}" != x""; do 43while 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
41done 46done
42test x"$p_opt" == x"" && p_opt="$default_p_opt" 47test x"$p_opt" == x"" && p_opt="$default_p_opt"
43 48
44if test x"$p_opt" == x""; then 49if 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
48fi 53fi
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
4service=${PWD##*/} 4service=${PWD##*/}
5file_ipconf="$service.ipconf" 5file_ipconf="$service.ipconf"
@@ -10,4 +10,4 @@ echo "Finish: deconfiguring"
10rm "env.out" 10rm "env.out"
11rm "$file_ipconf" 11rm "$file_ipconf"
12rm "$dir_ipconf/$file_ipconf" 12rm "$dir_ipconf/$file_ipconf"
13sv u /var/service/fw 13svc -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
33fi 33fi
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
47fi 47fi