From: Florian Fainelli Date: Tue, 4 Dec 2012 16:20:51 +0000 (+0000) Subject: isc-dhcp-relay: Add init scripts for ipv4 and ipv6 as well as config X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fsvn-archive%2Farchive.git;a=commitdiff_plain;hb=2e3eed466cad851cc979e547a9553f66175bae99 isc-dhcp-relay: Add init scripts for ipv4 and ipv6 as well as config file I cleaned up the patch so line do not overflow and removed some white space in hope to get it accepted or revised. As isc-dhcp-relay does not come with an init script, I made one based on sysntpd init.d file for both ipv4 and ipv6. If you need more arguments from isc-dhcp-relay to be included in the config file, I'll be able to add them. This patch has been applied to trunk and compiles/install on my side. The script for ipv4 and ipv6 have been tested with the isc-dhcp-relay-ipv6 binary and work well (start/stop with the right settings). Signed-off-by: Jérôme Poulin Signed-off-by: Florian Fainelli SVN-Revision: 34485 --- diff --git a/net/isc-dhcp/Makefile b/net/isc-dhcp/Makefile index 798ee322cc..aa27aca0a0 100644 --- a/net/isc-dhcp/Makefile +++ b/net/isc-dhcp/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=isc-dhcp UPSTREAM_NAME:=dhcp PKG_VERSION:=4.2.4 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(UPSTREAM_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=ftp://ftp.isc.org/isc/dhcp/$(PKG_VERSION) @@ -173,6 +173,13 @@ endef define Package/isc-dhcp-relay-$(BUILD_VARIANT)/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/dhcrelay $(1)/usr/sbin + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/etc/config/dhcrelay $(1)/etc/config + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/dhcrelay4.init $(1)/etc/init.d/dhcrelay4 +ifeq ($(BUILD_VARIANT),ipv6) + $(INSTALL_BIN) ./files/dhcrelay6.init $(1)/etc/init.d/dhcrelay6 +endif endef define Package/isc-dhcp-server-$(BUILD_VARIANT)/install diff --git a/net/isc-dhcp/files/dhcrelay4.init b/net/isc-dhcp/files/dhcrelay4.init new file mode 100644 index 0000000000..70905cfa4a --- /dev/null +++ b/net/isc-dhcp/files/dhcrelay4.init @@ -0,0 +1,22 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2012 OpenWrt.org + +START=91 + +SERVICE_SIG="KILL" +SERVICE_PID_FILE="/var/run/dhcrelay4.pid" +SERVICE_USE_PID=1 + +start() { + local relay_dhcpserver + + config_load dhcrelay + config_get relay_dhcpserver ipv4 dhcpserver + + service_start /usr/sbin/dhcrelay -4 -q \ + -pf $SERVICE_PID_FILE $relay_dhcpserver +} + +stop() { + service_stop /usr/sbin/dhcrelay +} diff --git a/net/isc-dhcp/files/dhcrelay6.init b/net/isc-dhcp/files/dhcrelay6.init new file mode 100644 index 0000000000..0c6f7563fe --- /dev/null +++ b/net/isc-dhcp/files/dhcrelay6.init @@ -0,0 +1,42 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2012 OpenWrt.org + +START=91 + +SERVICE_SIG="KILL" +SERVICE_PID_FILE="/var/run/dhcrelay6.pid" +SERVICE_USE_PID=1 + +start() { + local relay_dhcpserver + local relay_upper + local relay_lowers + local relay_lower_args + + config_load dhcrelay + config_get relay_dhcpserver ipv6 dhcpserver + config_get relay_upper ipv6 upper + config_get relay_lowers ipv6 lower + + # If a specific DHCP server is specified, + # add it to the upper interface. + if [ -n "$relay_dhcpserver" ]; then + relay_upper="${relay_dhcpserver}%$relay_upper" + fi + + # Add all lower interfaces at the end. + if [ -n "$relay_lowers" ]; then + local relay_lower + for relay_lower in $relay_lowers; do + append relay_lower_args "-l $relay_lower" + done + fi + + service_start /usr/sbin/dhcrelay -6 -q \ + -pf $SERVICE_PID_FILE \ + -u $relay_upper $relay_lower_args +} + +stop() { + service_stop /usr/sbin/dhcrelay +} diff --git a/net/isc-dhcp/files/etc/config/dhcrelay b/net/isc-dhcp/files/etc/config/dhcrelay new file mode 100644 index 0000000000..5fde2399e9 --- /dev/null +++ b/net/isc-dhcp/files/etc/config/dhcrelay @@ -0,0 +1,10 @@ + +config dhcrelay ipv4 + option dhcpserver '192.0.2.10' + +config dhcrelay ipv6 +# option dhcpserver '2001:db8:1::1' + option upper 'eth1' + list lower 'eth0.2' + list lower 'eth0.3' +