bird2: bump to version 2.15.1
[feed/routing.git] / batmand / files / etc / init.d / batmand
1 #!/bin/sh /etc/rc.common
2 START=90
3 USE_PROCD=1
4
5 batmand_start() {
6 local config="$1"
7 local batman_args
8 local interface
9 local hnas
10 local gateway_class
11 local originator_interval
12 local preferred_gateway
13 local routing_class
14 local visualisation_srv
15 local local policy_routing_script
16 local disable_client_nat
17 local disable_aggregation
18
19 [ "$config" = "general" ] || return 1
20
21 config_get interface "$config" interface
22 if [ "$interface" = "" ]; then
23 echo $1 Error, you must specify at least a network interface
24 return 1
25 fi
26
27 config_get hnas "$config" hna
28 config_get gateway_class "$config" gateway_class
29 config_get originator_interval "$config" originator_interval
30 config_get preferred_gateway "$config" preferred_gateway
31 config_get routing_class "$config" routing_class
32 config_get visualisation_srv "$config" visualisation_srv
33 config_get policy_routing_script "$config" policy_routing_script
34 config_get disable_client_nat "$config" disable_client_nat
35 config_get disable_aggregation "$config" disable_aggregation
36
37 batman_args=""
38
39 for hna in $hnas; do
40 batman_args=${batman_args}'-a '$hna' '
41 done
42
43 if [ $gateway_class ]; then
44 batman_args=${batman_args}'-g '$gateway_class' '
45 fi
46
47 if [ $originator_interval ]; then
48 batman_args=${batman_args}'-o '$originator_interval' '
49 fi
50
51 if [ $preferred_gateway ]; then
52 batman_args=${batman_args}'-p '$preferred_gateway' '
53 fi
54
55 if [ $routing_class ]; then
56 batman_args=${batman_args}'-r '$routing_class' '
57 fi
58
59 if [ $visualisation_srv ]; then
60 batman_args=${batman_args}'-s '$visualisation_srv' '
61 fi
62
63 if [ $policy_routing_script ]; then
64 batman_args=${batman_args}'--policy-routing-script '$policy_routing_script' '
65 fi
66
67 if [ $disable_client_nat ]; then
68 batman_args=${batman_args}'--disable-client-nat '
69 fi
70
71 if [ $disable_aggregation ]; then
72 batman_args=${batman_args}'--disable-aggregation '
73 fi
74
75 procd_open_instance "${config}"
76 procd_set_param command /usr/sbin/batmand
77 procd_append_param command --no-detach
78 procd_append_param command ${batman_args}
79 procd_append_param command ${interface}
80 procd_set_param netdev ${interface}
81 procd_close_instance
82 }
83
84 start_service() {
85 config_load "batmand"
86 config_foreach batmand_start batmand
87 }
88
89 service_triggers() {
90 procd_add_reload_trigger "batmand"
91 }