1135252Sseanc#!/bin/sh
2135252Sseanc#
3135252Sseanc# $FreeBSD: stable/11/etc/rc.d/ntpdate 314531 2017-03-02 01:23:17Z ian $
4135252Sseanc#
5135252Sseanc
6135252Sseanc# PROVIDE: ntpdate
7257694Sglebius# REQUIRE: NETWORKING syslogd
8136224Smtm# KEYWORD: nojail
9135252Sseanc
10135252Sseanc. /etc/rc.subr
11135252Sseanc
12135252Sseancname="ntpdate"
13298514Slmedesc="Set the date and time via NTP"
14230099Sdougbrcvar="ntpdate_enable"
15135252Sseancstop_cmd=":"
16135252Sseancstart_cmd="ntpdate_start"
17135252Sseanc
18135252Sseancntpdate_start()
19135252Sseanc{
20251885Sdteske	if [ -z "$ntpdate_hosts" -a -f "$ntpdate_config" ]; then
21135252Sseanc		ntpdate_hosts=`awk '
22135252Sseanc			/^server[ \t]*127.127/      {next}
23314531Sian			/^(server|peer|pool)/       {
24203200Sume			    if ($2 ~/^-/)           {print $3}
25203200Sume			    else                    {print $2}}
26251885Sdteske		' < "$ntpdate_config"`
27135252Sseanc	fi
28135252Sseanc	if [ -n "$ntpdate_hosts" -o -n "$rc_flags" ]; then
29135252Sseanc		echo "Setting date via ntp."
30140391Sceri		${ntpdate_program:-ntpdate} $rc_flags $ntpdate_hosts
31135252Sseanc	fi
32135252Sseanc}
33135252Sseanc
34135252Sseancload_rc_config $name
35135252Sseancrun_rc_command "$1"
36