12fa90e2e87b30d08cd2fcc3dd8617c1f03b3aa8
[openwrt/svn-archive/archive.git] / net / babel / files / babeld.init
1 #!/bin/sh /etc/rc.common
2
3 START=70
4
5 babel_addif() {
6 config_get ifname $1 ifname
7 append interfaces "$ifname"
8 }
9
10 babel_config() {
11 local cfg="$1"
12 interfaces=
13 config_list_foreach "$cfg" interface babel_addif
14 pidfile=/var/run/babeld-"$cfg".pid
15 [ -z "$interfaces" ] && return 0
16 if [ -e $pidfile ] ; then
17 echo "$pidfile exists -- not starting babel." >&2
18 else
19 /usr/sbin/babeld -D -I $pidfile $interfaces
20 fi
21 }
22
23 start() {
24 if [ -x /etc/init.d/ahcpd ] && /etc/init.d/ahcpd enabled; then
25 echo 'Not starting babel -- will be started by ahcpd.'
26 exit 0
27 fi
28 include /lib/network
29 scan_interfaces
30 config_load babel
31 mkdir -p /var/lib
32 config_foreach babel_config babel
33 }
34
35 stop() {
36 kill $(cat /var/run/babeld-*.pid)
37 rm -f /var/run/babeld-*.pid
38 }