2000-03-10 14:53:23 +03:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2005-03-15 15:06:12 +03:00
|
|
|
# $NetBSD: ntpdate,v 1.18 2005/03/15 12:06:12 lukem Exp $
|
2000-03-10 14:53:23 +03:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: ntpdate
|
2005-03-15 15:06:12 +03:00
|
|
|
# REQUIRE: NETWORKING mountcritremote syslogd
|
2000-03-10 14:53:23 +03:00
|
|
|
|
2004-08-13 22:08:03 +04:00
|
|
|
$_rc_subr_loaded . /etc/rc.subr
|
2000-03-10 14:53:23 +03:00
|
|
|
|
|
|
|
name="ntpdate"
|
2000-09-19 17:04:38 +04:00
|
|
|
rcvar=$name
|
2003-10-20 20:09:15 +04:00
|
|
|
command="/usr/sbin/${name}"
|
2000-03-10 14:53:23 +03:00
|
|
|
start_cmd="ntpdate_start"
|
|
|
|
stop_cmd=":"
|
|
|
|
|
|
|
|
ntpdate_start()
|
|
|
|
{
|
|
|
|
if [ -z "$ntpdate_hosts" ]; then
|
2004-10-11 19:00:51 +04:00
|
|
|
ntpdate_hosts=$(awk '
|
2003-06-27 11:22:36 +04:00
|
|
|
/^#/ { next }
|
|
|
|
/^(server|peer)[ \t]*127.127/ { next }
|
2003-10-29 22:00:14 +03:00
|
|
|
/^(server|peer)/ { if ($2 ~ /^-[46]/)
|
2003-10-19 17:31:28 +04:00
|
|
|
print $3
|
|
|
|
else
|
|
|
|
print $2 }
|
2004-10-11 19:00:51 +04:00
|
|
|
' </etc/ntp.conf)
|
2000-03-10 14:53:23 +03:00
|
|
|
fi
|
|
|
|
if [ -n "$ntpdate_hosts" ]; then
|
|
|
|
echo "Setting date via ntp."
|
2003-10-19 17:23:57 +04:00
|
|
|
$command $rc_flags $ntpdate_hosts
|
2000-03-10 14:53:23 +03:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2000-05-13 12:45:06 +04:00
|
|
|
load_rc_config $name
|
2000-03-10 14:53:23 +03:00
|
|
|
run_rc_command "$1"
|