2004-09-14 21:08:33 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
#
|
|
|
|
|
# $FreeBSD$
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# PROVIDE: ntpdate
|
2013-11-05 04:30:06 -05:00
|
|
|
# REQUIRE: NETWORKING syslogd
|
2004-10-07 09:55:26 -04:00
|
|
|
# KEYWORD: nojail
|
2004-09-14 21:08:33 -04:00
|
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
|
|
name="ntpdate"
|
2016-04-23 12:10:54 -04:00
|
|
|
desc="Set the date and time via NTP"
|
2012-01-13 21:18:41 -05:00
|
|
|
rcvar="ntpdate_enable"
|
2004-09-14 21:08:33 -04:00
|
|
|
stop_cmd=":"
|
|
|
|
|
start_cmd="ntpdate_start"
|
|
|
|
|
|
|
|
|
|
ntpdate_start()
|
|
|
|
|
{
|
2013-06-17 22:37:15 -04:00
|
|
|
if [ -z "$ntpdate_hosts" -a -f "$ntpdate_config" ]; then
|
2004-09-14 21:08:33 -04:00
|
|
|
ntpdate_hosts=`awk '
|
|
|
|
|
/^server[ \t]*127.127/ {next}
|
2017-01-10 19:14:47 -05:00
|
|
|
/^(server|peer|pool)/ {
|
2010-01-30 11:34:52 -05:00
|
|
|
if ($2 ~/^-/) {print $3}
|
|
|
|
|
else {print $2}}
|
2013-06-17 22:37:15 -04:00
|
|
|
' < "$ntpdate_config"`
|
2004-09-14 21:08:33 -04:00
|
|
|
fi
|
|
|
|
|
if [ -n "$ntpdate_hosts" -o -n "$rc_flags" ]; then
|
|
|
|
|
echo "Setting date via ntp."
|
2005-01-17 13:28:09 -05:00
|
|
|
${ntpdate_program:-ntpdate} $rc_flags $ntpdate_hosts
|
2004-09-14 21:08:33 -04:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
|
run_rc_command "$1"
|