fix: dependence on hard-coded url

This commit is contained in:
eneller
2025-11-22 21:09:33 +01:00
parent 77f7bc1b2d
commit 930e3ad1ba
2 changed files with 13 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
default: debug
debug:
bash -x wifi4eu.login
# return true to not see Makefile errors
sh -x wifi4eu.login || true
deploy:
scp *.login router:/etc/travelmate

View File

@@ -1,18 +1,22 @@
#!/bin/sh
# auto-login for https://wifi4eu.ec.europa.eu or general fortigate
trm_fetch="$(command -v curl)"
trm_domain="http://10.0.1.1:1000"
trm_captiveurl="$(uci_get travelmate global trm_captiveurl "http://detectportal.firefox.com")"
# initial request to get magic id
magic="$($trm_fetch -Ls -o /dev/null -w '%{urle.query}' $trm_domain)"
# initial request to get login url
trm_url="$($trm_fetch -Ls -o /dev/null -w '%{url_effective}' $trm_captiveurl)"
# extract magic id into $2
IFS="?"
set -- $trm_url
# log in
$trm_fetch $trm_domain \
$trm_fetch "$1?$2" \
-X POST \
-L \
-H "Referer: $trm_domain/fgtauth?$magic" \
-w '%{http_code}' \
-H "Referer: $1?$2" \
--data "4Tredir=https://krksistemi.hr/rijeka2/" \
--data "magic=$magic" \
--data "magic=$2" \
--data "username=Disclaimer+user" \
--data "password=123"
[ "${?}" = "0" ] && exit 0 || exit 255