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