[packages] ahcpd: update to v0.2, add config and initscript

git-svn-id: svn://svn.openwrt.org/openwrt/packages@9236 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nico 2007-10-10 12:52:10 +00:00
parent 3ceae0daa0
commit 4017036f74
3 changed files with 156 additions and 3 deletions

View File

@ -9,12 +9,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ahcpd
PKG_VERSION:=0.1
PKG_VERSION:=0.2
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.pps.jussieu.fr/~jch/software/files/
PKG_MD5SUM:=10779877e69605ab22675b36fbe3b8a4
PKG_MD5SUM:=f75253b74bc54e117ba030c97c75c224
include $(INCLUDE_DIR)/package.mk
@ -47,13 +47,21 @@ define Build/Compile
all
endef
define Package/ahcpd/conffiles
/etc/config/ahcpd
endef
define Package/ahcpd/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ahcp-generate{,-address} $(1)/usr/bin/
$(INSTALL_DIR) $(1)/usr/lib/ahcp
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ahcp-config.sh $(1)/usr/lib/ahcp/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/{ahcp,dummy}-config.sh $(1)/usr/lib/ahcp/
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ahcpd $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/ahcpd.config $(1)/etc/config/ahcpd
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/ahcpd.init $(1)/etc/init.d/ahcpd
endef
$(eval $(call BuildPackage,ahcpd))

View File

@ -0,0 +1,16 @@
config ahcpd
option enabled 0
option interface 'lo'
#option address 'MULTICAST-LINK-LOCAL-ADDRESS'
#option port 'UDP-PORT'
#option config_script '/usr/lib/ahcp/dummy-config.sh'
#option pid_file '/var/run/ahcpd-INTERFACE.pid'
#option authoritative 0
#option authority_file '/var/run/ahcpd-INTERFACE.dat'
#option expire 'SECONDS'
#option prefix 'fde6:20f5:c9ac:358::'
#option protocol 'static|Babel|OLSR'
#option gateway 'fde6:20f5:c9ac:358::1'
#option dns_server 'fde6:20f5:c9ac:358::2'
#option ntp_server 'fde6:20f5:c9ac:358::3'

129
ipv6/ahcpd/files/ahcpd.init Executable file
View File

@ -0,0 +1,129 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2007 OpenWrt.org
START=99
NAME=ahcpd
BIN_F=/usr/sbin/$NAME
SSD=start-stop-daemon
is_enabled() {
local cfg="$1"
config_get_bool enabled "$cfg" enabled '1'
[ $enabled -ne 0 ] || {
echo "$initscript: not enabled"
return 1
}
}
get_interface() {
local cfg="$1"
config_get interface "$cfg" interface
[ -n "$interface" ] || {
echo "$initscript: not 'interface' option specified"
return 1
}
}
get_pid_file() {
local cfg="$1"
config_get pid_file "$cfg" pid_file
[ -n "$pid_file" ] || pid_file="/var/run/$NAME-$interface.pid"
}
get_options() {
local cfg="$1"
local address
local port
local authoritative
config_get options "$cfg" options
config_get config_script "$cfg" config_script
[ -n "$config_script" ] && append options "-c $config_script"
config_get address "$cfg" address
[ -n "$adress" ] && append options "-m $address"
config_get port "$cfg" port
[ -n "$port" ] && append options "-p $port"
config_get_bool authoritative "$cfg" authoritative '0'
[ $authoritative -ne 0 ] && {
local dat_file
local gen_options
config_get dat_file "$cfg" authority_file
[ -n "$dat_file" ] || dat_file="/var/run/$NAME-$interface.dat"
[ -f "$dat_file" ] || {
local expire
local prefix
local prototocol
local dns_server
local ntp_server
config_get prefix "$cfg" prefix
[ -n "$prefix" ] || prefix=`ahcp-generate-address -p -s -r`
append gen_options "-p $prefix"
config_get expire "$cfg" expire
[ -n "$expire" ] && append gen_options "-e $expire"
config_get protocol "$cfg" protocol
[ -n "$protocol" ] && append gen_options "-P $protocol"
[ "$protocol" = "static" ] && {
local gateway
config_get gateway "$cfg" gateway
[ -n "$gateway" ] && append gen_options "-g $gateway"
}
config_get dns_server "$cfg" dns_server
[ -n "$dns_server" ] && append gen_options "-n $dns_server"
config_get ntp_server "$cfg" ntp_server
[ -n "$ntp_server" ] && append gen_options "-N $ntp_server"
ahcp-generate $gen_options > $dat_file
}
append options "-a $dat_file"
}
append options "$interface"
}
start_service() {
local cfg="$1"
is_enabled "$cfg" || return
get_interface "$cfg" || return
get_pid_file $cfg
get_options $cfg
$SSD -S -p $pid_file -b -m -x $BIN_F -- $options &>/dev/null
}
stop_service() {
local cfg="$1"
is_enabled "$cfg" || return
get_interface "$cfg" || return
get_pid_file $cfg
$SSD -K -p $pid_file &>/dev/null
}
start() {
config_load $NAME
config_foreach start_service $NAME
}
stop() {
config_load $NAME
config_foreach stop_service $NAME
}