2024-04-01 17:53:34 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
### Wifi @ SNCF TGV INOUI
|
2024-04-29 11:57:19 +02:00
|
|
|
### Sacha at aquilenet.fr 20240401
|
2024-04-01 17:53:34 +02:00
|
|
|
### Validate captive portal access
|
|
|
|
|
2024-08-22 13:02:37 +02:00
|
|
|
# Put your wifi interface name here
|
2024-04-01 17:53:34 +02:00
|
|
|
wifiinterface="wlp170s0"
|
|
|
|
tmpfile=/tmp/wifi-tgv.tmp
|
|
|
|
|
2024-08-22 13:02:37 +02:00
|
|
|
# Check if we have nmap
|
|
|
|
which nmap || echo "Please install nmap" && exit 1
|
|
|
|
|
2024-04-01 17:53:34 +02:00
|
|
|
# Get DHCP answears
|
|
|
|
nmap --script broadcast-dhcp-discover -e $wifiinterface > $tmpfile
|
|
|
|
DNS=$(grep "Domain Name Server" $tmpfile | awk -F: '{gsub (" ", "", $0); print $2}')
|
|
|
|
|
2024-04-01 17:54:41 +02:00
|
|
|
# Enabling the wifi
|
2024-04-01 17:53:34 +02:00
|
|
|
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
|
|
|
|
|
2024-08-22 13:02:37 +02:00
|
|
|
# Optional: Check if we have Internet (& DNS resolution) with perdu.com
|
2024-04-01 17:53:34 +02:00
|
|
|
echo -n "Checking Internet Access... "
|
2024-04-28 12:12:39 +02:00
|
|
|
curl --silent perdu.com |grep ici && echo "Internet is OK !!!" || echo "Internet is KO :((("
|