Home | History | Annotate | Line # | Download | only in rc.d
ntpdate revision 1.16
      1   1.1    lukem #!/bin/sh
      2   1.1    lukem #
      3  1.16  mycroft # $NetBSD: ntpdate,v 1.16 2004/08/13 18:08:03 mycroft Exp $
      4   1.1    lukem #
      5   1.1    lukem 
      6   1.1    lukem # PROVIDE: ntpdate
      7   1.7    lukem # REQUIRE: NETWORKING syslogd
      8   1.1    lukem 
      9  1.16  mycroft $_rc_subr_loaded . /etc/rc.subr
     10   1.1    lukem 
     11   1.1    lukem name="ntpdate"
     12   1.6    lukem rcvar=$name
     13  1.13    fredb command="/usr/sbin/${name}"
     14   1.1    lukem start_cmd="ntpdate_start"
     15   1.1    lukem stop_cmd=":"
     16   1.1    lukem 
     17   1.1    lukem ntpdate_start()
     18   1.1    lukem {
     19   1.1    lukem 	if [ -z "$ntpdate_hosts" ]; then
     20   1.1    lukem 		ntpdate_hosts=`awk '
     21  1.10    lukem 			/^#/				{ next }
     22  1.10    lukem 			/^(server|peer)[ \t]*127.127/	{ next }
     23  1.14    fredb 			/^(server|peer)/		{ if ($2 ~ /^-[46]/)
     24  1.12    fredb 							    print $3
     25  1.12    fredb 							  else
     26  1.12    fredb 							    print $2 }
     27   1.1    lukem 		' </etc/ntp.conf`
     28   1.1    lukem 	fi
     29   1.1    lukem 	if [ -n "$ntpdate_hosts"  ]; then
     30   1.1    lukem 		echo "Setting date via ntp."
     31  1.11    fredb 		$command $rc_flags $ntpdate_hosts
     32   1.1    lukem 	fi
     33   1.1    lukem }
     34   1.1    lukem 
     35   1.3    lukem load_rc_config $name
     36   1.1    lukem run_rc_command "$1"
     37