Home | History | Annotate | Line # | Download | only in rc.d
ntpdate revision 1.10
      1   1.1  lukem #!/bin/sh
      2   1.1  lukem #
      3  1.10  lukem # $NetBSD: ntpdate,v 1.10 2003/06/27 07:22:36 lukem 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.1  lukem . /etc/rc.subr
     10   1.1  lukem 
     11   1.1  lukem name="ntpdate"
     12   1.6  lukem rcvar=$name
     13   1.1  lukem start_cmd="ntpdate_start"
     14   1.1  lukem stop_cmd=":"
     15   1.1  lukem 
     16   1.1  lukem ntpdate_start()
     17   1.1  lukem {
     18   1.1  lukem 	if [ -z "$ntpdate_hosts" ]; then
     19   1.1  lukem 		ntpdate_hosts=`awk '
     20  1.10  lukem 			/^#/				{ next }
     21  1.10  lukem 			/^(server|peer)[ \t]*127.127/	{ next }
     22  1.10  lukem 			/^(server|peer)/		{ print $2 }
     23  1.10  lukem 			/^multicastclient$/		{ print "224.0.1.1" }
     24  1.10  lukem 			/^multicastclient/		{ print $2 }
     25   1.1  lukem 		' </etc/ntp.conf`
     26   1.1  lukem 	fi
     27   1.1  lukem 	if [ -n "$ntpdate_hosts"  ]; then
     28   1.1  lukem 		echo "Setting date via ntp."
     29   1.8  lukem 		ntpdate $rc_flags $ntpdate_hosts
     30   1.1  lukem 	fi
     31   1.1  lukem }
     32   1.1  lukem 
     33   1.3  lukem load_rc_config $name
     34   1.1  lukem run_rc_command "$1"
     35