1 #!/bin/sh /etc/rc.common
5 pidfile
='/var/run/babeld.pid'
6 EXTRA_COMMANDS
="status"
7 EXTRA_HELP
=" status Dump Babel's table to the log file."
10 local ifname
=$
(uci_get_state network
"$1" ifname
"$1")
12 append args
"$switch $ifname"
13 append interfaces
"$ifname"
21 config_get _name
"$section" "$option"
22 [ -z "$_name" ] && return 0
23 local ifname
=$
(uci_get_state network
"$_name" ifname
"$_name")
24 append args
"$switch $ifname"
32 config_get_bool _loctmp
"$section" "$option" 0
33 [ "$_loctmp" -gt 0 ] && append args
"$value"
39 append args
"$switch $value"
47 config_get _loctmp
"$section" "$option"
48 [ -z "$_loctmp" ] && return 0
49 append args
"$switch $_loctmp"
57 config_get_bool _ignored
"$cfg" 'ignore' 0
58 [ "$_ignored" -eq 1 ] && return 0
62 append_parm
"$cfg" 'type' ''
64 append_bool
"$cfg" 'local' 'local'
66 append_parm
"$cfg" 'ip' 'ip'
67 append_parm
"$cfg" 'eq' 'eq'
68 append_parm
"$cfg" 'le' 'le'
69 append_parm
"$cfg" 'ge' 'ge'
70 append_parm
"$cfg" 'neigh' 'neigh'
71 append_parm
"$cfg" 'id' 'id'
72 append_parm
"$cfg" 'proto' 'proto'
74 append_ifname
"$cfg" 'if' 'if'
76 append_parm
"$cfg" 'action' ''
85 config_get_bool _ignored
"$cfg" 'ignore' 0
86 [ "$_ignored" -eq 1 ] && return 0
88 listen_ifname
"$cfg" "-C 'interface"
90 append_parm
"$cfg" 'wired' 'wired'
91 append_parm
"$cfg" 'link_quality' 'link-quality'
92 append_parm
"$cfg" 'split_horizon' 'split-horizon'
93 append_parm
"$cfg" 'rxcost' 'rxcost'
94 append_parm
"$cfg" 'hello_interval' 'hello-interval'
95 append_parm
"$cfg" 'update_interval' 'update-interval'
103 append_bool
"$cfg" 'carrier_sense' '-l'
104 append_bool
"$cfg" 'assume_wireless' '-w'
105 append_bool
"$cfg" 'no_split_horizon' '-s'
106 append_bool
"$cfg" 'keep_unfeasible' '-u'
107 append_bool
"$cfg" 'random_router_id' '-r'
109 append_parm
"$cfg" 'multicast_address' '-m'
110 append_parm
"$cfg" 'port' '-p'
111 append_parm
"$cfg" 'state_file' '-S'
112 append_parm
"$cfg" 'hello_interval' '-h'
113 append_parm
"$cfg" 'wired_hello_interval' '-H'
114 append_parm
"$cfg" 'diversity' '-z'
115 append_parm
"$cfg" 'smoothing_half_time' '-M'
116 append_parm
"$cfg" 'kernel_priority' '-k'
117 append_parm
"$cfg" 'duplication_priority' '-A'
118 append_parm
"$cfg" 'debug' '-d'
119 append_parm
"$cfg" 'local_server' '-g'
120 append_parm
"$cfg" 'export_table' '-t'
121 config_list_foreach
"$cfg" 'import_table' append_switch
'-T'
122 append_parm
"$cfg" 'conf_file' '-c'
123 append_parm
"$cfg" 'log_file' '-L'
131 config_foreach babel_config general
132 config_foreach babel_addif interface
133 config_foreach babel_filter filter
134 [ -z "$interfaces" ] && return 0
135 eval "/usr/sbin/babeld -D -I $pidfile $args $interfaces"
139 [ -f "$pidfile" ] && kill $
(cat $pidfile)
140 # avoid race-condition on restart: wait for
141 # babeld to die for real.
142 [ -f "$pidfile" ] && sleep 1
143 [ -f "$pidfile" ] && sleep 1
144 [ -f "$pidfile" ] && sleep 1
145 [ -f "$pidfile" ] && exit 42
149 [ -f "$pidfile" ] && kill -USR1 $
(cat $pidfile)