Upgrade ahcpd to 0.5 (#3480)
[packages.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 no_ipv4 "$cfg" no_ipv4
11         config_get no_dns "$cfg" no_dns
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 [ -e $pidfile ] ; then
20                 echo "$pidfile exists -- not starting ahcpd." >&2
21         else
22                 /usr/bin/ahcpd -D -I $pidfile ${no_ipv4:+-s} ${no_dns:+-N} $authority $interfaces
23         fi
24 }
25
26 stop() {
27         [ -e $pidfile ] && kill $(cat $pidfile)
28         [ -e $pidfile ] && sleep 2
29         [ -e $pidfile ] && sleep 4
30         [ -e $pidfile ] && echo "Failed to stop ahcpd ($pidfile still exists)."
31 }