Skip to content

Instantly share code, notes, and snippets.

@dicer
Forked from vollkorn1982/wifionice
Last active February 28, 2024 09:57
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dicer/b21300fbbfdd8cf011756a8673b6f69c to your computer and use it in GitHub Desktop.
HowTo auto connect your Linux to the German Wifi on ICE trains
#!/bin/bash
# change the next line to match your wifi device and put this file in /etc/NetworkManager/dispatcher.d/ and make it executable
WIFI_DEVICE=wlp3s0
IF=$1
STATUS=$2
if [ "$IF" == "$WIFI_DEVICE" ] && [ "$STATUS" == "up" ] && [ $(iwconfig $WIFI_DEVICE | grep -c "ESSID:\"WIFIonICE\"") ]
then
curl 'http://www.wifionice.de/de/' -H 'Host: www.wifionice.de' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://www.wifionice.de/' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: csrf=42' -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' --data 'login=true&CSRFToken=42&connect='
fi
@maltere
Copy link

maltere commented Oct 25, 2019

Works perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment