Fix and upgrade the ahcpd package
[openwrt/svn-archive/archive.git] / ipv6 / ahcpd / files / ahcpd.init
1 #!/bin/sh /etc/rc.common
2
3 START=71
4
5 pidfile=/var/run/ahcpd.pid
6
7 ahcpd_config() {
8 local cfg="$1"
9 config_get interfaces "$cfg" interfaces
10 config_get_bool no_config "$cfg" no_config 0
11 config_get_bool ipv4_only "$cfg" ipv4_only 0
12 config_get_bool ipv6_only "$cfg" ipv6_only 0
13 config_get_bool no_dns "$cfg" no_dns 0
14 }
15
16 start() {
17 config_load ahcpd
18 config_foreach ahcpd_config ahcpd
19 mkdir -p /var/lib
20 if [ "$no_config" -eq 0 ]; then
21 unset no_config
22 fi
23 if [ "$ipv4_only" -eq 0 ]; then
24 unset ipv4_only
25 fi
26 if [ "$ipv6_only" -eq 0 ]; then
27 unset ipv6_only
28 fi
29 if [ "$no_dns" -eq 0 ]; then
30 unset no_dns
31 fi
32 if [ -e $pidfile ] ; then
33 echo "$pidfile exists -- not starting ahcpd." >&2
34 else
35 /usr/sbin/ahcpd -s /usr/lib/ahcp/ahcp-config.sh -D -I $pidfile \
36 ${ipv4_only:+-4} ${ipv6_only:+-6} ${no_dns:+-N} ${no_config:+-n} \
37 $interfaces
38 fi
39 }
40
41 stop() {
42 [ -e $pidfile ] && kill $(cat $pidfile)
43 [ -e $pidfile ] && sleep 2
44 [ -e $pidfile ] && sleep 4
45 [ -e $pidfile ] && echo "Failed to stop ahcpd ($pidfile still exists)."
46 }