2 # (using bashism (arrays) in dhcp config)
9 pool="us.pool.ntp.org" # replace "us" with your country code
12 rundir="/var/run/service/$service"
13 default_p_opt="-p 0.$pool -p 1.$pool -p 2.$pool -p 3.$pool"
16 # Make sure rundir/ exists
17 mkdir -p "$rundir" 2>/dev/null
18 chown -R "$user": "$rundir"
19 chmod -R a=rX "$rundir"
20 rm -rf rundir 2>/dev/null
21 ln -s "$rundir" rundir
24 echo "* Checking network"
25 test -f /var/run/service/fw/up || exec sleep 7
26 sleep 5 # to let it settle
28 # Grab config from dhcp
30 for f in rundir/*.ntpconf; do
31 test -f "$f" || continue
38 while test x"${ntpip[$cfg]}" != x""; do
39 p_opt="$p_opt -p ${ntpip[$cfg]}"
42 test x"$p_opt" == x"" && p_opt="$default_p_opt"
44 if test x"$p_opt" == x""; then
45 echo "* No NTP peers configured, stopping"
51 # Let others know that we are up
52 date '+%Y-%m-%d %H:%M:%S %Z' >rundir/up
55 echo "* Starting ntpd[$$]"
60 ntpd -ddnNl -S ./ntp.script $p_opt