3 .
/usr
/share
/libubox
/jshn.sh
7 logger
-s -t ${DAEMON} -p daemon.info
"${1}"
10 oonf_get_layer3_device
()
12 local interface
="${1}" # e.g. 'mywifi'
13 local status dev proto
14 local query
="{ \"interface\" : \"${interface}\" }"
16 status
="$( ubus -S call network.interface status "${query}" )" && {
18 json_get_var
'dev' l3_device
19 json_get_var
'proto' proto
22 # TODO: otherwise it segfaults
23 oonf_log
"refusing to add '$interface', because of proto '${proto}'"
26 echo "${dev}" # e.g. 'wlan0-1'
32 oonf_add_devices_to_configuration
()
35 local device_name
= section
= interface
= single_interface
=
37 # make a copy of configuration and
38 # add a 'name' (physical name) for all
39 # 'interface-names' (e.g. mywifi)
41 # olsrd2.@interface[2]=interface
42 # olsrd2.@interface[2].ifname='wan lan wlanadhoc wlanadhocRADIO1'
44 # /var is in ramdisc/tmpfs
46 uci
export ${DAEMON} >"/var/etc/${DAEMON}_dev"
48 while section
="$( uci -q -c /etc/config get "${DAEMON}.@
[${i}]" )"; do {
49 echo "section: ${section}"
51 interface
="$( uci -q -c /etc/config get "${DAEMON}.@
[${i}].ifname
" )" ||
{
56 case "$( uci -q get "${DAEMON}.@
[${i}].ignore
" )" in
57 1|on|true|enabled|
yes)
58 oonf_log
"removing/ignore section '$section'"
59 uci
-q -c /var
/etc delete
"${DAEMON}_dev.@[${j}]"
66 for single_interface
in ${interface}; do {
67 device_name
="$( oonf_get_layer3_device "${single_interface}" )"
69 echo "Interface: ${single_interface} = ${device_name}"
71 if [ ! -z "${device_name}" ]
73 # add option 'name' for 'ifname' (e.g. 'mywifi')
74 uci
-q -c /var
/etc add_list
"${DAEMON}_dev.@[${i}].name=${device_name}"
80 uci
-q -c /var
/etc commit
"${DAEMON}_dev"
82 oonf_log
"wrote '/var/etc/${DAEMON}_dev'"
88 local pidfile
="/var/run/${DAEMON}.pid"
90 if [ -e "${pidfile}" ]; then
91 read pid
<"${pidfile}"
92 elif pidfile
="$( uci -q get "${DAEMON}.@global
[0].pidfile
" )"; then
93 read pid
<"${pidfile}"
96 # if empty, ask kernel
97 pid
="${pid:-$( pidof ${DAEMON} )}"
99 [ -n "${pid}" ] && kill -SIGHUP ${pid}
104 oonf_add_devices_to_configuration
109 service_start
/usr
/sbin
/${DAEMON} --set global.fork
=true
--load uci
:///var
/etc
/${DAEMON}_dev
114 service_stop
/usr
/sbin
/${DAEMON}
119 oonf_add_devices_to_configuration