From: Felix Fietkau Date: Sun, 20 Dec 2009 18:23:24 +0000 (+0000) Subject: ahcpd: rework init script (based on a patch by alx) X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fsvn-archive%2Farchive.git;a=commitdiff_plain;hb=c57a8f0cd4c7ecdd6ff16dad4cc73c642244d598 ahcpd: rework init script (based on a patch by alx) - use uci network interface names instead of direct interface names - start multiple instances if configured to do so SVN-Revision: 18862 --- diff --git a/ipv6/ahcpd/files/ahcpd.config b/ipv6/ahcpd/files/ahcpd.config old mode 100755 new mode 100644 index dc9186c6fc..c70b71d833 --- a/ipv6/ahcpd/files/ahcpd.config +++ b/ipv6/ahcpd/files/ahcpd.config @@ -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' diff --git a/ipv6/ahcpd/files/ahcpd.init b/ipv6/ahcpd/files/ahcpd.init index 5b0fe19658..12a8452167 100644 --- a/ipv6/ahcpd/files/ahcpd.init +++ b/ipv6/ahcpd/files/ahcpd.init @@ -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