[packages_10.03.2] rarpd: merge r28921, r29215
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 5 Feb 2012 16:00:45 +0000 (16:00 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 5 Feb 2012 16:00:45 +0000 (16:00 +0000)
SVN-Revision: 30248

net/rarpd/Makefile
net/rarpd/files/rarpd.config [new file with mode: 0644]
net/rarpd/files/rarpd.default [deleted file]
net/rarpd/files/rarpd.init

index b763e62960bebc24a76d435f805f809eb1665b10..0d6acd2e8530e82ead32c9725028dbb496f8449a 100644 (file)
@@ -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 (file)
index 0000000..297a869
--- /dev/null
@@ -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 (file)
index 1dd41e9..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# /etc/default/rarpd
-#
-# Only listen on vlan0
-#OPTIONS="-i vlan0"
index f973cc8dcb4deb74a70ae9c033a4e5d3d4db2acd..8c6522c6d38669352234d4b788a751d108fb99bf 100644 (file)
@@ -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'
 }