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
45 uci
export ${DAEMON} >"/var/run/${DAEMON}_dev"
47 while section
="$( uci -q -c /etc/config get "${DAEMON}.@
[${i}]" )"; do {
48 echo "section: ${section}"
50 interface
="$( uci -q -c /etc/config get "${DAEMON}.@
[${i}].ifname
" )" ||
{
55 case "$( uci -q get "${DAEMON}.@
[${i}].ignore
" )" in
56 1|on|true|enabled|
yes)
57 oonf_log
"removing/ignore section '$section'"
58 uci
-q -c /var
/run delete
"${DAEMON}_dev.@[${j}]"
65 for single_interface
in ${interface}; do {
66 device_name
="$( oonf_get_layer3_device "${single_interface}" )"
68 echo "Interface: ${single_interface} = ${device_name}"
70 if [ ! -z "${device_name}" ]
72 # add option 'name' for 'ifname' (e.g. 'mywifi')
73 uci
-q -c /var
/run add_list
"${DAEMON}_dev.@[${i}].name=${device_name}"
79 uci
-q -c /var
/run commit
"${DAEMON}_dev"
81 oonf_log
"wrote '/var/run/${DAEMON}_dev'"
87 local pidfile
="/var/run/${DAEMON}.pid"
89 if [ -e "${pidfile}" ]; then
90 read pid
<"${pidfile}"
91 elif pidfile
="$( uci -q get "${DAEMON}.@global
[0].pidfile
" )"; then
92 read pid
<"${pidfile}"
95 # if empty, ask kernel
96 pid
="${pid:-$( pidof ${DAEMON} )}"
98 [ -n "${pid}" ] && kill -SIGHUP ${pid}
103 oonf_add_devices_to_configuration
108 service_start
/usr
/sbin
/${DAEMON} --set global.fork
=true
--load uci
:///var
/run
/${DAEMON}_dev
113 service_stop
/usr
/sbin
/${DAEMON}
118 oonf_add_devices_to_configuration
124 # check if we have a pidfile and then check if that pid still exists.
125 # since we don't use -e this has to be explicitly returned. exit would stop the process.
126 test -e "/tmp/run/olsrd2.pid" && test -e "/proc/$(cat "/tmp
/run
/olsrd2.pid
")" && return 0