aboutsummaryrefslogtreecommitdiff
path: root/examples/var_service/ntpd
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 /examples/var_service/ntpd
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>
Diffstat (limited to 'examples/var_service/ntpd')
-rwxr-xr-xexamples/var_service/ntpd/run25
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
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