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