1 #!/bin/sh /etc/rc.common
7 .
/usr
/share
/libubox
/jshn.sh
11 logger
-s -t ${daemon} -p daemon.info
"$1"
14 oonf_get_layer3_device
()
16 local interface
="$1" # e.g. 'mywifi'
17 local status dev proto
18 local query
="{ \"interface\" : \"$interface\" }"
20 status
="$( ubus -S call network.interface status "$query" )" && {
22 json_get_var
'dev' l3_device
23 json_get_var
'proto' proto
26 # TODO: otherwise it segfaults
27 oonf_log
"refusing to add '$interface', because of proto '$proto'"
30 echo "$dev" # e.g. 'wlan0-1'
36 oonf_add_devices_to_configuration
()
39 local device_name
= section
= interface
= single_interface
=
41 # make a copy of configuration and
42 # add a 'name' (physical name) for all
43 # 'interface-names' (e.g. mywifi)
45 # olsrd2.@interface[2]=interface
46 # olsrd2.@interface[2].ifname='wan lan wlanadhoc wlanadhocRADIO1'
48 # /var is in ramdisc/tmpfs
49 cp /etc
/config
/${daemon} /var
/etc
/${daemon}_dev
51 while section
="$( uci -q -c /etc/config get "${daemon}.@
[$i]" )"; do {
52 echo "section: $section"
54 interface
="$( uci -q -c /etc/config get "${daemon}.@
[$i].ifname
" )" ||
{
59 case "$( uci -q get "${daemon}.@
[$i].ignore
" )" in
60 1|on|true|enabled|
yes)
61 oonf_log
"removing/ignore section '$section'"
62 uci
-q -c /var
/etc delete
"${daemon}_dev.@[$j]"
69 for single_interface
in $interface; do {
70 device_name
="$( oonf_get_layer3_device "$single_interface" )"
72 echo "Interface: $single_interface = $device_name"
74 if [ ! -z "$device_name" ]
76 # add option 'name' for 'ifname' (e.g. 'mywifi')
77 uci
-q -c /var
/etc add_list
"${daemon}_dev.@[$i].name=$device_name"
83 uci
-q -c /var
/etc commit
${daemon}_dev
85 oonf_log
"wrote '/var/etc/${daemon}_dev'"
91 local pidfile
='/var/run/${daemon}.pid'
93 if [ -e "$pidfile" ]; then
95 elif pidfile
="$( uci -q get '${daemon}.@global[0].pidfile' )"; then
99 # if empty, ask kernel
100 pid
="${pid:-$( pidof ${daemon} )}"
102 [ -n "$pid" ] && kill -SIGHUP $pid
107 oonf_add_devices_to_configuration
112 service_start
/usr
/sbin
/${daemon} --set global.fork
=true
--load uci
:///var
/etc
/${daemon}_dev
117 service_stop
/usr
/sbin
/${daemon}
122 oonf_add_devices_to_configuration