Skip to content

Commit 609d697

Browse files
committed
Update network-recover.sh
1 parent 9ad882f commit 609d697

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

tools/network-recover.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
#!/bin/bash
22

3-
if ! /usr/bin/nmcli c status id "STRANDS AAF" > /dev/null; then
3+
# make sure you configure /usr/bin/nmcli with the NOPASSWD option in sudoers:
4+
# ALL ALL=(ALL) NOPASSWD: /usr/bin/nmcli
5+
6+
ESSID="STRANDS AAF"
7+
8+
# check for connection status, option 1: ask nmcli
9+
# if ! /usr/bin/nmcli c status id "$ESSID" > /dev/null; then
10+
11+
# check for connection status, option 2: check real connection
12+
curl -D /tmp/headers-$USER.txt -s 'http://captive.apple.com/hotspot-detect' > /tmp/captive-return-$USER.html
13+
http_code=`grep "HTTP/1.1" /tmp/headers-$USER.txt | cut -f2 -d" "`
14+
if [ "$http_code" = "200" ]; then
15+
sleep 1
16+
else
417
echo "connection dropped and needs to be re-initiated"
518
sudo /usr/bin/nmcli nm wifi off
619
sleep 5
720
sudo /usr/bin/nmcli nm wifi on
821
sleep 5
9-
sudo /usr/bin/nmcli c up id "STRANDS AAF"
10-
#nmcli d wifi connect "STRANDS" password 12345678
22+
sudo /usr/bin/nmcli c up id "$ESSID"
1123
fi
24+

0 commit comments

Comments
 (0)