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/var_service/ntpd | |
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/var_service/ntpd')
-rwxr-xr-x | examples/var_service/ntpd/run | 25 |
1 files changed, 15 insertions, 10 deletions
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 | ||