mirror of
https://git.openwrt.org/feed/packages.git
synced 2024-06-18 13:23:57 +02:00
![Dirk Brenken](/assets/img/avatar_default.png)
* code cleanup * add auto login script for Julianahoeve beach resort (NL) * add auto login script for Vodafone hotspots (DE) * add auto login script for telekom hotspots (DE) * enhance captive portal detection to support html redirects as well * change default captive portal detection url to 'detectportal.firefox.com' Signed-off-by: Dirk Brenken <dev@brenken.org>
33 lines
1.1 KiB
Bash
Executable File
33 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
# captive portal auto-login script template with credentials as parameters
|
|
# Copyright (c) 2020-2021 Dirk Brenken (dev@brenken.org)
|
|
# This is free software, licensed under the GNU General Public License v3.
|
|
|
|
# set (s)hellcheck exceptions
|
|
# shellcheck disable=1091,2039,3040
|
|
|
|
export LC_ALL=C
|
|
export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
|
set -o pipefail
|
|
|
|
# source function library if necessary
|
|
#
|
|
if [ -z "${_C}" ]; then
|
|
. "/lib/functions.sh"
|
|
fi
|
|
|
|
user="${1}"
|
|
password="${2}"
|
|
success="Thank you!"
|
|
trm_domain="example.com"
|
|
trm_useragent="$(uci_get travelmate global trm_useragent "Mozilla/5.0 (Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0")"
|
|
trm_maxwait="$(uci_get travelmate global trm_maxwait "30")"
|
|
trm_fetch="$(command -v curl)"
|
|
|
|
# login with credentials
|
|
#
|
|
raw_html="$("${trm_fetch}" --user-agent "${trm_useragent}" --referer "http://www.example.com" --connect-timeout $((trm_maxwait / 6)) --silent --show-error --header "Content-Type:application/x-www-form-urlencoded" --data "username=${user}&password=${password}" "http://${trm_domain}")"
|
|
if [ -n "${raw_html##*${success}*}" ]; then
|
|
exit 1
|
|
fi
|