travelmate: minimal change to fix cp detection
* fix cp detection proposed by @ChristianKuehnel * add/adapt mikrotik login script provided by @Christian Kuehnel Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
parent
e2d1af1a29
commit
74c8fb403f
3 changed files with 45 additions and 3 deletions
|
@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
|||
|
||||
PKG_NAME:=travelmate
|
||||
PKG_VERSION:=1.5.5
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
PKG_LICENSE:=GPL-3.0-or-later
|
||||
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
||||
|
||||
|
|
36
net/travelmate/files/mikrotik.login
Executable file
36
net/travelmate/files/mikrotik.login
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
# This script will login to Mikrotik captive portals
|
||||
# Arguments:
|
||||
# username - user name for login
|
||||
# password - password for login
|
||||
|
||||
username="${1}"
|
||||
password="${2}"
|
||||
login_success="You are logged in"
|
||||
cmd="$(command -v curl)"
|
||||
|
||||
if [ "$#" -ne 2 ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x "${cmd}" ]
|
||||
then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Get login domain from redirection information
|
||||
domain="$("${cmd}" -I -s -X GET connectivity-check.ubuntu.com | grep Location | grep -o 'http://[^/]*')"
|
||||
if [ "${domain}" = "" ]
|
||||
then
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Login via username/password
|
||||
response="$("${cmd}" -s -X POST -d "username=${username}&password=${password}&dst=&popup=true" "${domain}"/login)"
|
||||
if [ -n "$(printf "%s" "${response}" | grep "${login_success}")" ]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
exit 4
|
||||
fi
|
|
@ -228,12 +228,18 @@ f_net()
|
|||
{
|
||||
local IFS raw result
|
||||
|
||||
raw="$(${trm_fetch} --timeout=$((trm_maxwait/6)) "${trm_captiveurl}" -O /dev/null 2>&1 | tail -n 1)"
|
||||
raw="$(${trm_fetch} --timeout=$((trm_maxwait/6)) "${trm_captiveurl}" -O /dev/null 2>&1)"
|
||||
if [ "$(printf "%s" "${raw}" | grep -c "^Redirected")" = "1" ]
|
||||
then
|
||||
raw="$(printf "%s" "${raw}" | grep "^Redirected")"
|
||||
else
|
||||
raw="$(printf "%s" "${raw}" | tail -n 1)"
|
||||
fi
|
||||
raw="$(printf "%s" "${raw//[\?\$\%\&\+\|\'\"\:\*\=\/]/ }")"
|
||||
result="$(printf "%s" "${raw}" | awk '/^Failed to redirect|^Redirected/{printf "%s","net cp";exit}/^Download completed/{printf "%s","net ok";exit}/^Failed|Connection error/{printf "%s","net nok";exit}')"
|
||||
if [ "${result}" = "net cp" ]
|
||||
then
|
||||
result="$(printf "%s" "${raw//*on /}" | awk 'match($0,/^([[:alnum:]_-]+\.)+[[:alpha:]]+/){printf "%s","net cp \047"substr(tolower($0),RSTART,RLENGTH)"\047"}')"
|
||||
result="$(printf "%s" "${raw//*on /}" | awk 'match($0,/^([[:alnum:]_-]+\.)+[[:alnum:]]+/){printf "%s","net cp \047"substr(tolower($0),RSTART,RLENGTH)"\047"}')"
|
||||
fi
|
||||
printf "%s" "${result}"
|
||||
f_log "debug" "f_net ::: fetch: ${trm_fetch}, timeout: $((trm_maxwait/6)), url: ${trm_captiveurl}, result: ${result}"
|
||||
|
|
Loading…
Reference in a new issue