ntpdate revision 1.12
1#!/bin/sh
2#
3# $NetBSD: ntpdate,v 1.12 2003/10/19 13:31:28 fredb Exp $
4#
5
6# PROVIDE: ntpdate
7# REQUIRE: NETWORKING syslogd
8
9. /etc/rc.subr
10
11name="ntpdate"
12rcvar=$name
13start_cmd="ntpdate_start"
14stop_cmd=":"
15
16ntpdate_start()
17{
18	if [ -z "$ntpdate_hosts" ]; then
19		ntpdate_hosts=`awk '
20			/^#/				{ next }
21			/^(server|peer)[ \t]*127.127/	{ next }
22			/^(server|peer)/		{ if ($2 ~ /[-]/)
23							    print $3
24							  else
25							    print $2 }
26			/^multicastclient$/		{ print "224.0.1.1" }
27			/^multicastclient/		{ print $2 }
28		' </etc/ntp.conf`
29	fi
30	if [ -n "$ntpdate_hosts"  ]; then
31		echo "Setting date via ntp."
32		$command $rc_flags $ntpdate_hosts
33	fi
34}
35
36load_rc_config $name
37run_rc_command "$1"
38