port batman package to batman 0.3
[openwrt/svn-archive/archive.git] / net / batman / files / etc / init.d / batmand
1 #!/bin/sh /etc/rc.common
2 START=100
3 . /lib/config/uci.sh
4 uci_load batman
5 start () {
6 interface=$(uci get batman.general.interface)
7 if [ "$interface" = "" ]; then
8 echo $1 Error, you must specify at least a network interface
9 exit
10 fi
11 announce=$(uci get batman.general.announce)
12 gateway_class=$(uci get batman.general.gateway_class)
13 originator_interval=$(uci get batman.general.originator_interval)
14 preferred_gateway=$(uci get batman.general.preferred_gateway)
15 routing_class=$(uci get batman.general.routing_class)
16 visualisation_srv=$(uci get batman.general.visualisation_srv)
17 batman_args=""
18
19 if [ $announce ]; then
20 batman_args=${batman_args}'-a '$announce' '
21 fi
22
23 if [ $gateway_class ]; then
24 batman_args=${batman_args}'-g '$gateway_class' '
25 fi
26
27 if [ $originator_interval ]; then
28 batman_args=${batman_args}'-o '$originator_interval' '
29 fi
30
31 if [ $preferred_gateway ]; then
32 batman_args=${batman_args}'-p '$preferred_gateway' '
33 fi
34
35 if [ $routing_class ]; then
36 batman_args=${batman_args}'-r '$routing_class' '
37 fi
38
39 if [ $visualisation_srv ]; then
40 batman_args=${batman_args}'-s '$visualisation_srv' '
41 fi
42
43 batman_args=${batman_args}$interface
44 batmand $batman_args >/dev/null 2>&1
45 }
46
47 restart () {
48 $0 stop
49 sleep 3
50 $0 start
51 }
52
53 stop () {
54 killall batmand
55 }