diff options
author | Denys Vlasenko | 2018-07-03 17:02:50 +0200 |
---|---|---|
committer | Denys Vlasenko | 2018-07-03 17:02:50 +0200 |
commit | aa75a7da7f3b0bb50be82f535244137bae423fa8 (patch) | |
tree | 781df3664a0f5b29cb4a8b715c28ac75b4c1584c /examples/var_service/ntpd | |
parent | e5d5f5b9a770de5a48d1a3bd293d5d611d6624c4 (diff) | |
download | busybox-aa75a7da7f3b0bb50be82f535244137bae423fa8.zip busybox-aa75a7da7f3b0bb50be82f535244137bae423fa8.tar.gz |
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 6f2a681..5c90aad 100755 --- a/examples/var_service/ntpd/run +++ b/examples/var_service/ntpd/run @@ -6,12 +6,22 @@ exec 2>&1 exec </dev/null user=root +start_delay=15 +net_down_delay=5 pool="us.pool.ntp.org" # replace "us" with your country code service="${PWD##*/}" rundir="/var/run/service/$service" default_p_opt="-p 0.$pool -p 1.$pool -p 2.$pool -p 3.$pool" +echo "* Checking network" +test -f /var/run/service/fw/up || exec sleep $net_down_delay + +# With multiple interfaces (e.g. wired+wireless) going up, +# networking scripts may restart ntpd service several times +# in quick succession. Do not be too eager to start sending +# NTP requests: +sleep $start_delay # Make sure rundir/ exists mkdir -p "$rundir" 2>/dev/null @@ -20,30 +30,25 @@ chmod -R a=rX "$rundir" rm -rf rundir 2>/dev/null ln -s "$rundir" rundir - -echo "* Checking network" -test -f /var/run/service/fw/up || exec sleep 7 -sleep 5 # to let it settle - # Grab config from dhcp cfg=-1 for f in rundir/*.ntpconf; do - test -f "$f" || continue - . "$f" + test -f "$f" || continue + . "$f" done # Select peers p_opt="" cfg=0 while test x"${ntpip[$cfg]}" != x""; do - p_opt="$p_opt -p ${ntpip[$cfg]}" - let cfg=cfg+1 + p_opt="$p_opt -p ${ntpip[$cfg]}" + let cfg=cfg+1 done test x"$p_opt" == x"" && p_opt="$default_p_opt" if test x"$p_opt" == x""; then echo "* No NTP peers configured, stopping" - sv o . + svc -o . exec sleep 1 fi |