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

git-svn-id: svn://svn.openwrt.org/openwrt/packages@18862 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nbd 2009-12-20 18:23:24 +00:00
parent 7c937f507d
commit 87340f10d9
2 changed files with 21 additions and 13 deletions

12
ipv6/ahcpd/files/ahcpd.config Executable file → Normal file
View File

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

View 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