diff --git a/Makefile b/Makefile index 51a044d..c821d15 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/wifi4eu.login b/wifi4eu.login index ec2df0e..8193d4c 100755 --- a/wifi4eu.login +++ b/wifi4eu.login @@ -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 \ No newline at end of file +[ "${?}" = "0" ] && exit 0 || exit 255