efd80d3c4270d4d76bdb0256b59623aa93d72d45
[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_ipv4 "$cfg" no_ipv4 0
11 config_get_bool no_dns "$cfg" no_dns 0
12 }
13
14 start() {
15 config_load ahcpd
16 config_foreach ahcpd_config ahcpd
17 mkdir -p /var/lib
18 [ -r /usr/lib/ahcp/ahcp.dat ] && authority="-a /usr/lib/ahcp/ahcp.dat"
19 if [ "$no_ipv4" -eq 0 ]; then
20 unset no_ipv4
21 fi
22 if [ "$no_dns" -eq 0 ]; then
23 unset no_dns
24 fi
25 if [ -e $pidfile ] ; then
26 echo "$pidfile exists -- not starting ahcpd." >&2
27 else
28 /usr/sbin/ahcpd -D -I $pidfile ${no_ipv4:+-s} ${no_dns:+-N} $authority $interfaces
29 fi
30 }
31
32 stop() {
33 [ -e $pidfile ] && kill $(cat $pidfile)
34 [ -e $pidfile ] && sleep 2
35 [ -e $pidfile ] && sleep 4
36 [ -e $pidfile ] && echo "Failed to stop ahcpd ($pidfile still exists)."
37 }