Skip to content

Instantly share code, notes, and snippets.

@quantenProjects
Forked from hacker-bastl/bahn.sh
Last active March 14, 2024 14:26
Show Gist options
  • Save quantenProjects/4050863f5b232eb8a337d6fb647b8f81 to your computer and use it in GitHub Desktop.
Save quantenProjects/4050863f5b232eb8a337d6fb647b8f81 to your computer and use it in GitHub Desktop.
NetworkManager WIFIonICE login automation
#!/bin/bash
# this script goes to /etc/NetworkManager/dispatcher.d/
IF=$1
STATUS=$2
case "$2" in
up)
if [ "$CONNECTION_ID" == "WIFIonICE" ]
then
logger -s "logging in to wifionice"
/opt/wifionice.sh
elif [ "$CONNECTION_ID" == "FlixBus Wi-Fi" ]
then
logger -s "logging in to flixbuswifi"
curl https://www.ombord.info/hotspot/hotspot.cgi?method=login > /dev/null 2> /dev/null
fi
;;
*)
;;
esac
#!/bin/bash
# get the CSRF token required for login
TOKEN=$(curl --silent --cookie /tmp/wifionice_cookie --cookie-jar /tmp/wifionice_cookie 'http://wifionice.de/en/' | grep CSRFToken | cut -d '"' -f 12)
# perform WIFIonICE login
curl -vvv --cookie /tmp/wifionice_cookie --cookie-jar /tmp/wifionice_cookie --data "login=true&CSRFToken=$TOKEN&connect=" "http://wifionice.de/en/"
# remove cookie file
rm /tmp/wifionice_cookie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment