|
@ -10,7 +10,7 @@ |
|
|
# |
|
|
# |
|
|
LC_ALL=C |
|
|
LC_ALL=C |
|
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin" |
|
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin" |
|
|
trm_ver="0.3.1" |
|
|
|
|
|
|
|
|
trm_ver="0.3.2" |
|
|
trm_enabled=1 |
|
|
trm_enabled=1 |
|
|
trm_debug=0 |
|
|
trm_debug=0 |
|
|
trm_maxwait=20 |
|
|
trm_maxwait=20 |
|
@ -25,7 +25,7 @@ f_envload() |
|
|
then |
|
|
then |
|
|
. "/lib/functions.sh" |
|
|
. "/lib/functions.sh" |
|
|
else |
|
|
else |
|
|
f_log "error" "required system library not found" |
|
|
|
|
|
|
|
|
f_log "error" "status ::: required system library not found" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
# load uci config and check 'enabled' option |
|
|
# load uci config and check 'enabled' option |
|
@ -85,21 +85,24 @@ f_check() |
|
|
|
|
|
|
|
|
while [ ${cnt} -le ${trm_maxwait} ] |
|
|
while [ ${cnt} -le ${trm_maxwait} ] |
|
|
do |
|
|
do |
|
|
ifname="$(ubus -S call network.wireless status | jsonfilter -l 1 -e "@.*.interfaces[@.config.mode=\"${mode}\"].ifname")" |
|
|
|
|
|
if [ "${mode}" = "sta" ] |
|
|
|
|
|
|
|
|
if [ "${mode}" = "ap" ] |
|
|
then |
|
|
then |
|
|
trm_ifstatus="$(ubus -S call network.interface dump | jsonfilter -e "@.interface[@.device=\"${ifname}\"].up")" |
|
|
|
|
|
else |
|
|
|
|
|
trm_ifstatus="$(ubus -S call network.wireless status | jsonfilter -l1 -e '@.*.up')" |
|
|
trm_ifstatus="$(ubus -S call network.wireless status | jsonfilter -l1 -e '@.*.up')" |
|
|
|
|
|
else |
|
|
|
|
|
ifname="$(ubus -S call network.wireless status | jsonfilter -l1 -e '@.*.interfaces[@.config.mode="sta"].ifname')" |
|
|
|
|
|
if [ -n "${ifname}" ] |
|
|
|
|
|
then |
|
|
|
|
|
trm_ifstatus="$(ubus -S call network.interface dump | jsonfilter -e "@.interface[@.device=\"${ifname}\"].up")" |
|
|
|
|
|
fi |
|
|
fi |
|
|
fi |
|
|
if [ "${trm_ifstatus}" = "true" ] |
|
|
|
|
|
|
|
|
if [ "${mode}" = "initial" ] || [ "${trm_ifstatus}" = "true" ] |
|
|
then |
|
|
then |
|
|
break |
|
|
break |
|
|
fi |
|
|
fi |
|
|
cnt=$((cnt+1)) |
|
|
cnt=$((cnt+1)) |
|
|
sleep 1 |
|
|
sleep 1 |
|
|
done |
|
|
done |
|
|
f_log "debug" "check ::: name: ${ifname}, status: ${trm_ifstatus}, count: ${cnt}" |
|
|
|
|
|
|
|
|
f_log "debug" "check ::: mode: ${mode}, name: ${ifname}, status: ${trm_ifstatus}, count: ${cnt}, max-wait: ${trm_maxwait}" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# function to write to syslog |
|
|
# function to write to syslog |
|
@ -122,8 +125,9 @@ f_log() |
|
|
f_main() |
|
|
f_main() |
|
|
{ |
|
|
{ |
|
|
local ap_list ssid_list config network ssid cnt=1 |
|
|
local ap_list ssid_list config network ssid cnt=1 |
|
|
|
|
|
local sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')" |
|
|
|
|
|
|
|
|
f_check "sta" |
|
|
|
|
|
|
|
|
f_check "initial" |
|
|
if [ "${trm_ifstatus}" != "true" ] |
|
|
if [ "${trm_ifstatus}" != "true" ] |
|
|
then |
|
|
then |
|
|
config_load wireless |
|
|
config_load wireless |
|
@ -138,7 +142,7 @@ f_main() |
|
|
f_log "debug" "main ::: ap-list: ${ap_list}, sta-list: ${trm_stalist}" |
|
|
f_log "debug" "main ::: ap-list: ${ap_list}, sta-list: ${trm_stalist}" |
|
|
if [ -z "${ap_list}" ] || [ -z "${trm_stalist}" ] |
|
|
if [ -z "${ap_list}" ] || [ -z "${trm_stalist}" ] |
|
|
then |
|
|
then |
|
|
f_log "error" "main ::: no usable AP/STA configuration found" |
|
|
|
|
|
|
|
|
f_log "error" "status ::: no usable AP/STA configuration found" |
|
|
fi |
|
|
fi |
|
|
for ap in ${ap_list} |
|
|
for ap in ${ap_list} |
|
|
do |
|
|
do |
|
@ -168,22 +172,27 @@ f_main() |
|
|
f_check "sta" |
|
|
f_check "sta" |
|
|
if [ "${trm_ifstatus}" = "true" ] |
|
|
if [ "${trm_ifstatus}" = "true" ] |
|
|
then |
|
|
then |
|
|
f_log "info " "main ::: wwan interface connected to uplink ${ssid} (${cnt}/${trm_maxretry})" |
|
|
|
|
|
|
|
|
f_log "info " "status ::: wwan interface connected to uplink ${ssid} (${cnt}/${trm_maxretry}, ${sysver})" |
|
|
|
|
|
sleep 5 |
|
|
return 0 |
|
|
return 0 |
|
|
else |
|
|
else |
|
|
uci -q set wireless."${config}".disabled=1 |
|
|
uci -q set wireless."${config}".disabled=1 |
|
|
uci -q commit wireless |
|
|
uci -q commit wireless |
|
|
ubus call network reload |
|
|
ubus call network reload |
|
|
f_log "info " "main ::: wwan interface can't connect to uplink ${ssid} (${cnt}/${trm_maxretry})" |
|
|
|
|
|
|
|
|
f_log "info " "status ::: wwan interface can't connect to uplink ${ssid} (${cnt}/${trm_maxretry}, ${sysver})" |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
done |
|
|
done |
|
|
|
|
|
else |
|
|
|
|
|
f_log "info " "status ::: empty uplink list (${cnt}/${trm_maxretry}, ${sysver})" |
|
|
fi |
|
|
fi |
|
|
cnt=$((cnt+1)) |
|
|
cnt=$((cnt+1)) |
|
|
sleep 5 |
|
|
sleep 5 |
|
|
done |
|
|
done |
|
|
done |
|
|
done |
|
|
f_log "info " "main ::: no wwan uplink found" |
|
|
|
|
|
|
|
|
f_log "info " "status ::: no wwan uplink found (${sysver})" |
|
|
|
|
|
else |
|
|
|
|
|
f_log "info " "status ::: wwan uplink still connected (${sysver})" |
|
|
fi |
|
|
fi |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|