2 # (using bashism (arrays) in dhcp config)
11 pool="us.pool.ntp.org" # replace "us" with your country code
14 rundir="/var/run/service/$service"
15 default_p_opt="-p 0.$pool -p 1.$pool -p 2.$pool -p 3.$pool"
17 echo "* Checking network"
18 test -f /var/run/service/fw/up || exec sleep $net_down_delay
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
26 # Make sure rundir/ exists
27 mkdir -p "$rundir" 2>/dev/null
28 chown -R "$user": "$rundir"
29 chmod -R a=rX "$rundir"
30 rm -rf rundir 2>/dev/null
31 ln -s "$rundir" rundir
33 # Grab config from dhcp
35 for f in rundir/*.ntpconf; do
36 test -f "$f" || continue
43 while test x"${ntpip[$cfg]}" != x""; do
44 p_opt="$p_opt -p ${ntpip[$cfg]}"
47 test x"$p_opt" == x"" && p_opt="$default_p_opt"
49 if test x"$p_opt" == x""; then
50 echo "* No NTP peers configured, stopping"
56 # Let others know that we are up
57 date '+%Y-%m-%d %H:%M:%S %Z' >rundir/up
60 echo "* Starting ntpd[$$]"
65 ntpd -ddnNl -S ./ntp.script $p_opt