summaryrefslogtreecommitdiff
blob: 4e3c1bc4c6035cb0d000f59f721b5f84a77905ed (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
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/dhcp/files/dhcp.rc6,v 1.11 2004/03/06 03:30:53 vapier Exp $

depend() {
	need net
	use logger dns
}

checkconfig() {
	if [ ! -f "${CHROOT}/etc/dhcp/dhcpd.conf" ] ; then
		eerror "No ${CHROOT}/etc/dhcp/dhcpd.conf file exists!"
		return 1
	fi

	if [ ! -f "${CHROOT}/var/lib/dhcp/dhcpd.leases" ] ; then
		ebegin "Creating dhcpd.leases"
		touch "${CHROOT}/var/lib/dhcp/dhcpd.leases" || return 1
		eend $?
	fi

	ebegin "Setting ownership on dhcpd.leases"
	chown dhcp:dhcp "${CHROOT}/var/lib/dhcp/dhcpd.leases" || return 1
	eend $?
}

start() {
	checkconfig || return 1

	ebegin "Starting ${CHROOT:+chrooted }dhcpd"
	start-stop-daemon --start --quiet --exec /usr/sbin/dhcpd \
		-- -pf /var/run/dhcp/dhcpd.pid -q \
		-user dhcp -group dhcp ${DHCPD_OPTS} \
		${CHROOT:+-chroot ${CHROOT}} ${IFACE}
	eend $?
}

stop() {
	ebegin "Stopping dhcpd"
	start-stop-daemon --stop --quiet --pidfile \
		"${CHROOT}/var/run/dhcp/dhcpd.pid"
	eend $?
}