#!/bin/bash # (using bashism (arrays) in dhcp config) #exec >/dev/null exec 2>&1 exec /dev/null chown -R "$user:" "$rundir" 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" 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 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 . exec sleep 1 fi # Let others know that we are up date '+%Y-%m-%d %H:%M:%S %Z' >rundir/up # Go go go echo "* Starting ntpd[$$]" exec \ env - PATH="$PATH" \ softlimit \ setuidgid "$user" \ ntpd -ddnNl -S ./ntp.script $p_opt