Menu

[r4703]: / trunk / etc / rc.d / ntpdate  Maximize  Restore  History

Download this file

50 lines (41 with data), 1.0 kB

#!/bin/sh
#
# $FreeBSD: src/etc/rc.d/ntpdate,v 1.16.8.1 2009/04/15 03:14:26 kensmith Exp $
#
# Modified by Volker Theile (votdev@gmx.de)
# Changes:
# - Remove requirement 'named'
# - Add mkconf command
#

# PROVIDE: ntpdate
# REQUIRE: NETWORKING syslogd
# KEYWORD: nojail
# XQUERY: -i "count(//system/ntp/enable) > 0" -o "0" -b
# RCVAR: ntpdate

. /etc/rc.subr
. /etc/configxml.subr

name="ntpdate"
rcvar=`set_rcvar`

load_rc_config "$name"

# Custom commands
stop_cmd=":"
start_cmd="ntpdate_start"

# Set timeservers
_timeservers=`configxml_get "//system/ntp/timeservers"`
if [ -n "${_timeservers}" ]; then
	ntpdate_flags="${ntpdate_flags} ${_timeservers}"
fi

ntpdate_start()
{
	if [ -z "$ntpdate_hosts" -a -f ${ntpdate_config} ]; then
		ntpdate_hosts=`awk '
			/^server[ \t]*127.127/      {next}
			/^(server|peer)/            {print $2}
		' < ${ntpdate_config}`
	fi
	if [ -n "$ntpdate_hosts" -o -n "$rc_flags" ]; then
		echo "Setting date via ntp."
		${ntpdate_program:-ntpdate} $rc_flags $ntpdate_hosts
	fi
}

run_rc_command "$1"
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.