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'
96 append_bool
"$cfg" 'enable_timestamps' 'enable-timestamps'
97 append_parm
"$cfg" 'max_rtt_penalty' 'max-rtt-penalty'
98 append_parm
"$cfg" 'rtt_decay' 'rtt-decay'
99 append_parm
"$cfg" 'rtt_min' 'rtt-min'
100 append_parm
"$cfg" 'rtt_max' 'rtt-max'
108 append_bool
"$cfg" 'carrier_sense' '-l'
109 append_bool
"$cfg" 'assume_wireless' '-w'
110 append_bool
"$cfg" 'no_split_horizon' '-s'
111 append_bool
"$cfg" 'keep_unfeasible' '-u'
112 append_bool
"$cfg" 'random_router_id' '-r'
114 append_parm
"$cfg" 'multicast_address' '-m'
115 append_parm
"$cfg" 'port' '-p'
116 append_parm
"$cfg" 'state_file' '-S'
117 append_parm
"$cfg" 'hello_interval' '-h'
118 append_parm
"$cfg" 'wired_hello_interval' '-H'
119 append_parm
"$cfg" 'diversity' '-z'
120 append_parm
"$cfg" 'smoothing_half_time' '-M'
121 append_parm
"$cfg" 'kernel_priority' '-k'
122 append_parm
"$cfg" 'duplication_priority' '-A'
123 append_parm
"$cfg" 'debug' '-d'
124 append_parm
"$cfg" 'local_server' '-g'
125 append_parm
"$cfg" 'export_table' '-t'
126 config_list_foreach
"$cfg" 'import_table' append_switch
'-T'
127 append_parm
"$cfg" 'conf_file' '-c'
128 append_parm
"$cfg" 'log_file' '-L'
136 config_foreach babel_config general
137 config_foreach babel_addif interface
138 config_foreach babel_filter filter
139 [ -z "$interfaces" ] && return 0
140 eval "/usr/sbin/babeld -D -I $pidfile $args $interfaces"
144 [ -f "$pidfile" ] && kill $
(cat $pidfile)
145 # avoid race-condition on restart: wait for
146 # babeld to die for real.
147 [ -f "$pidfile" ] && sleep 1
148 [ -f "$pidfile" ] && sleep 1
149 [ -f "$pidfile" ] && sleep 1
150 [ -f "$pidfile" ] && exit 42
154 [ -f "$pidfile" ] && kill -USR1 $
(cat $pidfile)