2004-09-15 01:08:33 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: ntpdate
|
2006-01-16 06:03:42 +00:00
|
|
|
# REQUIRE: NETWORKING syslogd named
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2004-09-15 01:08:33 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="ntpdate"
|
|
|
|
rcvar=`set_rcvar`
|
|
|
|
stop_cmd=":"
|
|
|
|
start_cmd="ntpdate_start"
|
|
|
|
|
|
|
|
ntpdate_start()
|
|
|
|
{
|
2006-07-20 10:07:34 +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}
|
2010-01-30 16:34:52 +00:00
|
|
|
/^(server|peer)/ {
|
|
|
|
if ($2 ~/^-/) {print $3}
|
|
|
|
else {print $2}}
|
2006-07-20 10:07:34 +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"
|