packages/rarpd: use uci config, cleanup

git-svn-id: svn://svn.openwrt.org/openwrt/packages@29215 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nico 2011-11-17 10:47:23 +00:00
parent e82916f0a1
commit 412e6f60f9
4 changed files with 101 additions and 23 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=rarpd
PKG_VERSION:=1.1
PKG_RELEASE:=2
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))

View File

@ -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

View File

@ -1,4 +0,0 @@
# /etc/default/rarpd
#
# Only listen on vlan0
#OPTIONS="-i vlan0"

View File

@ -4,16 +4,83 @@
START=50
SERVICE_DAEMONIZE=1
SERVICE_WRITE_PID=1
PROG="rarpd"
COMMAND="/usr/sbin/$PROG"
DEFAULT="/etc/default/$PROG"
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
service_start $COMMAND -n $OPTIONS
include /lib/network
scan_interfaces
config_load 'rarpd'
config_foreach start_instance 'rarpd'
}
stop() {
service_stop $COMMAND
include /lib/network
scan_interfaces
config_load 'rarpd'
config_foreach stop_instance 'rarpd'
}