#!/sbin/openrc-run
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/dhcp/files/dhcrelay.init,v 1.2 2007/03/22 15:36:59 uberlord Exp $

depend() {
	need net
	use logger
	after firewall
}

start() {
	if [ -z "${DHCRELAY_SERVERS}" ]; then
		eerror "No DHCRELAY_SERVERS specified in /etc/conf.d/dhcrelay"
		return 1
	fi

	# If we are configured to run in a VRF, provide a hint for that
	RC_VRF_EXEC=""
	if [ -n "$vrf" ]; then
		RC_VRF_EXEC="/sbin/ip vrf exec $vrf"
	fi

	local IFACES= i=
	for i in ${IFACE} ; do
		IFACES="${IFACES} -i ${i}"
	done

	checkpath --directory --owner dhcp:dhcp /run/dhcp

	ebegin "Starting dhcrelay"
	${RC_VRF_EXEC} start-stop-daemon --start --exec /usr/sbin/dhcrelay \
		-- -q ${IFACES} ${DHCRELAY_OPTS} ${DHCRELAY_SERVERS}
	eend $?
}

stop() {
	ebegin "Stopping dhcrelay"
	start-stop-daemon --stop --pidfile /run/dhcp/dhcrelay.pid
	eend $?
}
