#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/openntpd/files/openntpd.rc,v 1.4 2004/12/12 21:26:24 vapier Exp $

depend() {
	need net
	use dns logger
}

checkconfig() {
	if [ ! -f /etc/ntpd.conf ] ; then
		eerror "Could not find /etc/ntpd.conf!"
		return 1
	fi

	if [ -x /usr/bin/getent ] ; then
		if [ "`getent passwd ntp | cut -d: -f 6`" != "${NTPD_HOME}" ] ; then
			eerror "Home directory of ntp needs to be ${NTPD_HOME}"
			eerror "Please run 'usermod -d ${NTPD_HOME} ntp'"
			return 1
		fi
	fi

	return 0
}

start() {
	checkconfig || return $?

	ebegin "Starting ntpd"
	start-stop-daemon --start --exec /usr/sbin/ntpd -- ${NTPD_OPTS}
	eend $? "Failed to start ntpd"
}

stop() {
	ebegin "Stopping ntpd"
	start-stop-daemon --stop --name ntpd --user root
	eend $? "Failed to stop openntpd"
}
