aboutsummaryrefslogtreecommitdiff
path: root/net/travelmate/files/travelmate.sh
diff options
context:
space:
mode:
authorDirk Brenken <dev@brenken.org>2021-09-11 18:23:35 +0200
committerDirk Brenken <dev@brenken.org>2021-09-11 18:23:35 +0200
commit3167e00aff44c1ae5172f4c5547b3136caef6088 (patch)
tree09520e9ac9a49c88bf182afc93e75d7d8cc8870b /net/travelmate/files/travelmate.sh
parenta6968744d900e629b9e70a204e4fd6226634b21d (diff)
travelmate: update to 2.0.7
* add wpa-supplicant package dependency * removed no longer working 'db-bahn.login' and 'wifionice.login' auto-login scripts * added the new 'wifibahn.login' script for auto-logins to captive portals WIFI@BAHN (DE), run tested on a single ICE (station logins are currently unsupported!) * vodafone.login prepared to support free/time limited logins (still WIP!) * change return code handling in login scripts and travelmate * refine f_wifi function * fix a few conercase issues Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'net/travelmate/files/travelmate.sh')
-rwxr-xr-xnet/travelmate/files/travelmate.sh48
1 files changed, 34 insertions, 14 deletions
diff --git a/net/travelmate/files/travelmate.sh b/net/travelmate/files/travelmate.sh
index a37461773..6a0fe7f8a 100755
--- a/net/travelmate/files/travelmate.sh
+++ b/net/travelmate/files/travelmate.sh
@@ -10,7 +10,7 @@ export LC_ALL=C
export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
set -o pipefail
-trm_ver="2.0.6"
+trm_ver="2.0.7"
trm_enabled="0"
trm_debug="0"
trm_iface=""
@@ -148,9 +148,9 @@ f_char() {
# wifi helper function
#
f_wifi() {
- local status radio timeout="0"
+ local status radio radio_up timeout="0"
- "${trm_wifi}" reconf
+ "${trm_wifi}" reload
for radio in ${trm_radiolist}; do
while true; do
if [ "${timeout}" -ge "${trm_maxwait}" ]; then
@@ -159,6 +159,10 @@ f_wifi() {
status="$("${trm_wifi}" status 2>/dev/null)"
if [ "$(printf "%s" "${status}" | jsonfilter -q -l1 -e "@.${radio}.up")" != "true" ] ||
[ "$(printf "%s" "${status}" | jsonfilter -q -l1 -e "@.${radio}.pending")" != "false" ]; then
+ if [ "${radio}" != "${radio_up}" ]; then
+ "${trm_wifi}" up "${radio}"
+ radio_up="${radio}"
+ fi
timeout="$((timeout + 1))"
sleep 1
else
@@ -166,8 +170,10 @@ f_wifi() {
fi
done
done
- sleep "$((trm_maxwait / 6))"
- timeout="$((timeout + (trm_maxwait / 6)))"
+ if [ "${timeout}" -lt "${trm_maxwait}" ]; then
+ sleep "$((trm_maxwait / 6))"
+ timeout="$((timeout + (trm_maxwait / 6)))"
+ fi
f_log "debug" "f_wifi ::: radio_list: ${trm_radiolist}, radio: ${radio}, timeout: ${timeout}"
}
@@ -179,10 +185,9 @@ f_vpn() {
vpn="$(f_getval "vpn")"
vpn_service="$(f_getval "vpnservice")"
vpn_iface="$(f_getval "vpniface")"
- if [ -z "${vpn_action}" ]; then
- [ "${vpn}" = "1" ] && vpn_action="enable" || vpn_action="disable"
- fi
- if [ -x "${trm_vpnpgm}" ] && [ -n "${vpn_service}" ] && [ -n "${vpn_iface}" ]; then
+ [ -z "${vpn_action}" ] && { [ "${vpn}" = "1" ] && vpn_action="enable" || vpn_action="disable"; }
+
+ if [ -x "${trm_vpnpgm}" ] && [ -n "${vpn_service}" ] && [ -n "${vpn_iface}" ] && [ -f "${trm_ntpfile}" ]; then
if { [ "${vpn_action}" = "disable" ] && [ -f "${trm_vpnfile}" ]; } ||
{ [ "${vpn}" = "1" ] && [ "${vpn_action}" = "enable" ] && [ ! -f "${trm_vpnfile}" ]; } ||
{ [ "${vpn}" != "1" ] && [ "${vpn_action}" = "enable" ] && [ -f "${trm_vpnfile}" ]; }; then
@@ -211,13 +216,20 @@ f_mac() {
uci_set "wireless" "${section}" "macaddr" "${result}"
elif [ "${trm_randomize}" = "1" ]; then
result="$(hexdump -n6 -ve '/1 "%.02X "' /dev/random 2>/dev/null |
- awk -v local="2,6,A,E" -v seed="$(date +%s)" 'BEGIN{srand(seed)}NR==1{split(local,b,",");seed=int(rand()*4+1);printf "%s%s:%s:%s:%s:%s:%s",substr($1,0,1),b[seed],$2,$3,$4,$5,$6}')"
+ awk -v local="2,6,A,E" -v seed="$(date +%s)" 'BEGIN{srand(seed)}NR==1{split(local,b,",");
+ seed=int(rand()*4+1);printf "%s%s:%s:%s:%s:%s:%s",substr($1,0,1),b[seed],$2,$3,$4,$5,$6}')"
uci_set "wireless" "${section}" "macaddr" "${result}"
else
- result="$(uci_get "wireless" "${section}" "macaddr")"
+ uci_remove "wireless" "${section}" "macaddr" 2>/dev/null
+ ifname="$(ubus -S call network.wireless status 2>/dev/null | jsonfilter -q -l1 -e '@.*.interfaces[@.config.mode="sta"].ifname')"
+ result="$(${trm_iwinfo} "${ifname}" info 2>/dev/null | awk '/Access Point:/{printf "%s",$3}')"
fi
elif [ "${action}" = "get" ]; then
result="$(uci_get "wireless" "${section}" "macaddr")"
+ if [ -z "${result}" ]; then
+ ifname="$(ubus -S call network.wireless status 2>/dev/null | jsonfilter -q -l1 -e '@.*.interfaces[@.config.mode="sta"].ifname')"
+ result="$(${trm_iwinfo} "${ifname}" info 2>/dev/null | awk '/Access Point:/{printf "%s",$3}')"
+ fi
fi
printf "%s" "${result}"
f_log "debug" "f_mac ::: action: ${action:-"-"}, section: ${section:-"-"}, macaddr: ${macaddr:-"-"}, result: ${result:-"-"}"
@@ -568,9 +580,17 @@ f_check() {
login_script_args="$(f_getval "script_args")"
"${login_script}" ${login_script_args} >/dev/null 2>&1
rc="${?}"
- f_log "info" "captive portal login for '${cp_domain}' has been executed with rc '${rc}'"
- if [ "${rc}" = "0" ]; then
- result="$(f_net)"
+ if [ "${rc}" = "255" ]; then
+ f_log "info" "captive portal login script for '${cp_domain}' failed with rc '${rc}'"
+ unset trm_connection
+ trm_ifstatus="${status}"
+ f_jsnup
+ break
+ else
+ f_log "info" "captive portal login script for '${cp_domain}' has been finished with rc '${rc}'"
+ if [ "${rc}" = "0" ]; then
+ result="$(f_net)"
+ fi
fi
fi
fi