packages/ipv6/ahcpd/files/ahcpd.init
nbd 87340f10d9 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
2009-12-20 18:23:24 +00:00

55 lines
1.2 KiB
Bash

#!/bin/sh /etc/rc.common
START=71
pidfile=/var/run/ahcpd.pid
addif() {
config_get ifname $1 ifname
append interfaces "$ifname"
}
ahcpd_config() {
local cfg="$1"
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
if [ "$no_config" -eq 0 ]; then
unset no_config
fi
if [ "$ipv4_only" -eq 0 ]; then
unset ipv4_only
fi
if [ "$ipv6_only" -eq 0 ]; then
unset ipv6_only
fi
if [ "$no_dns" -eq 0 ]; then
unset no_dns
fi
if [ -e $pidfile ] ; then
echo "$pidfile exists -- not starting ahcpd." >&2
else
/usr/sbin/ahcpd -s /usr/lib/ahcp/ahcp-config.sh -D -I $pidfile \
${ipv4_only:+-4} ${ipv6_only:+-6} ${no_dns:+-N} ${no_config:+-n} \
$interfaces
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
[ -e $pidfile ] && sleep 4
[ -e $pidfile ] && echo "Failed to stop ahcpd ($pidfile still exists)."
}