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" 'src_ip' 'src-ip'
71 append_parm
"$cfg" 'src_eq' 'src-eq'
72 append_parm
"$cfg" 'src_le' 'src-le'
73 append_parm
"$cfg" 'src_ge' 'src-ge'
74 append_parm
"$cfg" 'neigh' 'neigh'
75 append_parm
"$cfg" 'id' 'id'
76 append_parm
"$cfg" 'proto' 'proto'
78 append_ifname
"$cfg" 'if' 'if'
80 append_parm
"$cfg" 'action' ''
89 config_get_bool _ignored
"$cfg" 'ignore' 0
90 [ "$_ignored" -eq 1 ] && return 0
92 listen_ifname
"$cfg" "-C 'interface"
94 append_parm
"$cfg" 'wired' 'wired'
95 append_parm
"$cfg" 'link_quality' 'link-quality'
96 append_parm
"$cfg" 'split_horizon' 'split-horizon'
97 append_parm
"$cfg" 'rxcost' 'rxcost'
98 append_parm
"$cfg" 'hello_interval' 'hello-interval'
99 append_parm
"$cfg" 'update_interval' 'update-interval'
107 append_bool
"$cfg" 'carrier_sense' '-l'
108 append_bool
"$cfg" 'assume_wireless' '-w'
109 append_bool
"$cfg" 'no_split_horizon' '-s'
110 append_bool
"$cfg" 'keep_unfeasible' '-u'
111 append_bool
"$cfg" 'random_router_id' '-r'
113 append_parm
"$cfg" 'multicast_address' '-m'
114 append_parm
"$cfg" 'port' '-p'
115 append_parm
"$cfg" 'state_file' '-S'
116 append_parm
"$cfg" 'hello_interval' '-h'
117 append_parm
"$cfg" 'wired_hello_interval' '-H'
118 append_parm
"$cfg" 'diversity' '-z'
119 append_parm
"$cfg" 'smoothing_half_time' '-M'
120 append_parm
"$cfg" 'kernel_priority' '-k'
121 append_parm
"$cfg" 'duplication_priority' '-A'
122 append_parm
"$cfg" 'debug' '-d'
123 append_parm
"$cfg" 'local_server' '-g'
124 append_parm
"$cfg" 'export_table' '-t'
125 config_list_foreach
"$cfg" 'import_table' append_switch
'-T'
126 append_parm
"$cfg" 'conf_file' '-c'
127 append_parm
"$cfg" 'log_file' '-L'
135 config_foreach babel_config general
136 config_foreach babel_addif interface
137 config_foreach babel_filter filter
138 [ -z "$interfaces" ] && return 0
139 eval "/usr/sbin/babeld -D -I $pidfile $args $interfaces"
143 [ -f "$pidfile" ] && kill $
(cat $pidfile)
144 # avoid race-condition on restart: wait for
145 # babeld to die for real.
146 [ -f "$pidfile" ] && sleep 1
147 [ -f "$pidfile" ] && sleep 1
148 [ -f "$pidfile" ] && sleep 1
149 [ -f "$pidfile" ] && exit 42
153 [ -f "$pidfile" ] && kill -USR1 $
(cat $pidfile)