Wifi-SNCF-TGV/wifi-sncf-tgv.sh
2024-04-01 17:53:34 +02:00

20 lines
No EOL
666 B
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
### Wifi @ SNCF TGV INOUI
### Sacha 20240401
### Validate captive portal access
wifiinterface="wlp170s0"
tmpfile=/tmp/wifi-tgv.tmp
# Get DHCP answears
nmap --script broadcast-dhcp-discover -e $wifiinterface > $tmpfile
DNS=$(grep "Domain Name Server" $tmpfile | awk -F: '{gsub (" ", "", $0); print $2}')
# Enabling the wifi
echo "Enabling SNCF's Wifi"
curl --silent --output /dev/null -X POST 'https://wifi.sncf/router/api/connection/activate/auto' --resolve wifi.sncf:443:$DNS
# Optional: Check if we have Internet with perdu.com
echo -n "Checking Internet Access... "
curl --silent perdu.com |grep ici && echo "OK !!!" || echo "KO :((("