summaryrefslogtreecommitdiff
blob: 455e4e21cfd21aecde16be4256d0e3200cb6c84a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/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-3.9_p1-r2,v 1.1 2009/10/14 08:04:19 bangert Exp $

depend() {
	need net
	after ntp-client
	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 $?

	#prepare chroot
	mkdir -p /var/lib/openntpd/chroot/etc/
	cp /etc/localtime /var/lib/openntpd/chroot/etc

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

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