From 00e329503c30f3bcbdf257f75d35d699c433aa9b Mon Sep 17 00:00:00 2001 From: jow Date: Sun, 5 Feb 2012 16:00:45 +0000 Subject: [PATCH] [packages_10.03.2] rarpd: merge r28921, r29215 git-svn-id: svn://svn.openwrt.org/openwrt/branches/packages_10.03.2@30248 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- net/rarpd/Makefile | 30 ++++++++-------- net/rarpd/files/rarpd.config | 13 +++++++ net/rarpd/files/rarpd.default | 4 --- net/rarpd/files/rarpd.init | 84 +++++++++++++++++++++++++++++++++++++++---- 4 files changed, 107 insertions(+), 24 deletions(-) create mode 100644 net/rarpd/files/rarpd.config delete mode 100644 net/rarpd/files/rarpd.default diff --git a/net/rarpd/Makefile b/net/rarpd/Makefile index b763e62..0d6acd2 100644 --- a/net/rarpd/Makefile +++ b/net/rarpd/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2006-2011 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=rarpd PKG_VERSION:=1.1 -PKG_RELEASE:=1 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=ftp://ftp.dementia.org/pub/net-tools @@ -36,22 +36,24 @@ define Package/rarpd/description database. endef -define Build/Configure - $(call Build/Configure/Default, \ - --with-libnet="$(STAGING_DIR)/usr/lib/libnet-1.0.x" \ - --with-pcap="$(STAGING_DIR)/usr" \ - , \ - CFLAGS="$$$$CFLAGS -DNEW_LIBNET_INTERFACE" \ - ) -endef +CONFIGURE_ARGS+= \ + --with-libnet="$(STAGING_DIR)/usr/lib/libnet-1.0.x" \ + --with-pcap="$(STAGING_DIR)/usr" \ + +CONFIGURE_VARS+= \ + CFLAGS="$$$$CFLAGS -DNEW_LIBNET_INTERFACE" \ define Package/rarpd/install $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/rarpd $(1)/usr/sbin/ - $(INSTALL_DIR) $(1)/etc/default - install -m644 ./files/rarpd.default $(1)/etc/default/rarpd + $(CP) $(PKG_INSTALL_DIR)/usr/sbin/rarpd $(1)/usr/sbin/ + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/rarpd.config $(1)/etc/config/rarpd $(INSTALL_DIR) $(1)/etc/init.d - install -m755 ./files/rarpd.init $(1)/etc/init.d/rarpd + $(INSTALL_BIN) ./files/rarpd.init $(1)/etc/init.d/rarpd +endef + +define Package/rarpd/conffiles +/etc/config/rarpd endef $(eval $(call BuildPackage,rarpd)) diff --git a/net/rarpd/files/rarpd.config b/net/rarpd/files/rarpd.config new file mode 100644 index 0000000..297a869 --- /dev/null +++ b/net/rarpd/files/rarpd.config @@ -0,0 +1,13 @@ +package 'rarpd' + +config 'rarpd' + option enabled 0 + + # listen on the specified interface (default: lan) +# option interface 'lan' + + # use the specified 'ethers' file (default: /etc/ethers) +# option ethers '/etc/ethers' + + # be verbose (default: false) +# option verbose 0 diff --git a/net/rarpd/files/rarpd.default b/net/rarpd/files/rarpd.default deleted file mode 100644 index 1dd41e9..0000000 --- a/net/rarpd/files/rarpd.default +++ /dev/null @@ -1,4 +0,0 @@ -# /etc/default/rarpd -# -# Only listen on vlan0 -#OPTIONS="-i vlan0" diff --git a/net/rarpd/files/rarpd.init b/net/rarpd/files/rarpd.init index f973cc8..8c6522c 100644 --- a/net/rarpd/files/rarpd.init +++ b/net/rarpd/files/rarpd.init @@ -1,14 +1,86 @@ #!/bin/sh /etc/rc.common -# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2006-2011 OpenWrt.org + START=50 -RARPD=/usr/sbin/rarpd -DEFAULT=/etc/default/rarpd +SERVICE_DAEMONIZE=1 +SERVICE_WRITE_PID=1 + +append_bool() { + local var="$1" + local section="$2" + local option="$3" + local value="$4" + local _val + config_get_bool _val "$section" "$option" 0 + [ $_val -gt 0 ] && append "$var" "$value" +} + +append_string() { + local var="$1" + local section="$2" + local option="$3" + local val="$4" + local _val + config_get _val "$section" "$option" + [ -n "$_val" ] && append "$var" "$val $_val" +} + +config_get_ifname() { + local var="$1" + local section="$2" + local option="$3" + local val="$4" + local _val + config_get _val "$section" "$option" "$val" + [ -n "$_val" ] && config_get "$var" "$_val" 'ifname' "$_val" +} + +section_enabled() { + local enabled + config_get_bool enabled "$1" 'enabled' 0 + [ $enabled -gt 0 ] +} + +start_instance() { + local section="$1" + local if + local args + + section_enabled "$section" || return 1 + + config_get_ifname if "$section" 'interface' 'lan' + args="-n -i $if" + append_string args "$section" 'ethers' '-e' + append_bool args "$section" 'verbose' '-v' + + SERVICE_PID_FILE="/var/run/rarpd-${if}.pid" + service_start /usr/sbin/rarpd $args +} + +stop_instance() { + local section="$1" + local id + local if + + section_enabled "$section" || return 1 + + config_get_ifname if "$section" 'interface' 'lan' + + SERVICE_PID_FILE="/var/run/rarpd-${if}.pid" + service_stop /usr/sbin/rarpd +} start() { - [ -f $DEFAULT ] && . $DEFAULT - $RARPD $OPTIONS + include /lib/network + scan_interfaces + config_load 'rarpd' + config_foreach start_instance 'rarpd' } + stop() { - killall rarpd + include /lib/network + scan_interfaces + config_load 'rarpd' + config_foreach stop_instance 'rarpd' } -- 2.11.0