ahcpd: rework init script (based on a patch by alx)
authorFelix Fietkau <nbd@openwrt.org>
Sun, 20 Dec 2009 18:23:24 +0000 (18:23 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 20 Dec 2009 18:23:24 +0000 (18:23 +0000)
 - use uci network interface names instead of direct interface names
 - start multiple instances if configured to do so

SVN-Revision: 18862

ipv6/ahcpd/files/ahcpd.config [changed mode: 0755->0644]
ipv6/ahcpd/files/ahcpd.init

old mode 100755 (executable)
new mode 100644 (file)
index dc9186c..c70b71d
@@ -1,6 +1,6 @@
-config ahcpd
-       option interfaces "wl0"
-       option no_config true
-       option no_dns false
-       option ipv4_only false
-       option ipv6_only false
+config 'ahcpd'
+       option 'no_dns' 'false'
+       option 'ipv4_only' 'false'
+       option 'ipv6_only' 'false'
+       option 'no_config' 'false'
+       #list 'interface' 'wlan'
index 5b0fe19658bdee38174dd88277a09db33c5e5e4b..12a84521673d4d6bf2fa0a1d12880fcce3fcc376 100644 (file)
@@ -3,20 +3,20 @@
 START=71
 
 pidfile=/var/run/ahcpd.pid
+addif() {
+       config_get ifname $1 ifname
+       append interfaces "$ifname"
+}
 
 ahcpd_config() {
        local cfg="$1"
-       config_get interfaces "$cfg" interfaces
+       interfaces=
+       config_list_foreach $cfg interface addif
+       [ -z "$interfaces" ] && return 0
        config_get_bool no_config "$cfg" no_config 0
        config_get_bool ipv4_only "$cfg" ipv4_only 0
        config_get_bool ipv6_only "$cfg" ipv6_only 0
        config_get_bool no_dns "$cfg" no_dns 0
-}
-
-start() {
-       config_load ahcpd
-       config_foreach ahcpd_config ahcpd
-       mkdir -p /var/lib
        if [ "$no_config" -eq 0 ]; then
                unset no_config
        fi
@@ -38,6 +38,14 @@ start() {
        fi
 }
 
+start() {
+       include /lib/network
+       scan_interfaces
+       config_load ahcpd
+       mkdir -p /var/lib
+       config_foreach ahcpd_config ahcpd
+}
+
 stop() {
        [ -e $pidfile ] && kill $(cat $pidfile)
        [ -e $pidfile ] && sleep 2