[packages] ahcpd: update to v0.2, add config and initscript
authorNicolas Thill <nico@openwrt.org>
Wed, 10 Oct 2007 12:52:10 +0000 (12:52 +0000)
committerNicolas Thill <nico@openwrt.org>
Wed, 10 Oct 2007 12:52:10 +0000 (12:52 +0000)
SVN-Revision: 9236

ipv6/ahcpd/Makefile
ipv6/ahcpd/files/ahcpd.config [new file with mode: 0644]
ipv6/ahcpd/files/ahcpd.init [new file with mode: 0755]

index 510062b45f6ee7ee1f8dff07b6f620787ee987eb..0595e5498911534c73d3962e95a4601c6e35f16f 100644 (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))
diff --git a/ipv6/ahcpd/files/ahcpd.config b/ipv6/ahcpd/files/ahcpd.config
new file mode 100644 (file)
index 0000000..a66cc52
--- /dev/null
@@ -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'
+
diff --git a/ipv6/ahcpd/files/ahcpd.init b/ipv6/ahcpd/files/ahcpd.init
new file mode 100755 (executable)
index 0000000..1d92871
--- /dev/null
@@ -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
+}
+