#!/sbin/runscript # Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/net-misc/dhcp/files/dhcp.init,v 1.6 2006/02/23 16:21:24 uberlord Exp $ depend() { need net use logger dns } get_var() { sed -n 's/^[[:blank:]]\?'"$1"' "*\([^#";]\+\).*/\1/p' \ "${CHROOT}/etc/dhcp/dhcpd.conf" } start() { if [[ ! -f "${CHROOT}/etc/dhcp/dhcpd.conf" ]] ; then eerror "${CHROOT}/etc/dhcp/dhcpd.conf does not exist" return 1 fi local leasefile="$(get_var lease-file-name)" leasefile="${CHROOT}/${leasefile:-/var/lib/dhcp/dhcpd.leases}" if [[ ! -f ${leasefile} ]] ; then ebegin "Creating ${leasefile}" touch "${leasefile}" chown dhcp:dhcp "${leasefile}" eend $? || return 1 fi # Ensure that LD_PRELOAD is really exported [[ -n ${LD_PRELOAD} ]] && export LD_PRELOAD="${LD_PRELOAD}" local pidfile="$(get_var pid-file-name)" pidfile="${pidfile:-/var/run/dhcp/dhcpd.pid}" ebegin "Starting ${CHROOT:+chrooted }dhcpd" start-stop-daemon --start --exec /usr/sbin/dhcpd \ --pidfile "${CHROOT}/${pidfile}" \ -- -q -pf "${pidfile}" \ -user dhcp -group dhcp ${DHCPD_OPTS} \ ${CHROOT:+-chroot} ${CHROOT} ${IFACE} eend $? && save_options pidfile "${CHROOT}/${pidfile}" } stop() { local pidfile="$(get_options pidfile)" chrooted="" [[ ${pidfile} != //var/run/dhcp/dhcpd.pid ]] && chrooted="chrooted " ebegin "Stopping ${chrooted}dhcpd" start-stop-daemon --stop --exec /usr/sbin/dhcpd \ --pidfile "${pidfile}" eend $? }