File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 "
1123fi
24+
You can’t perform that action at this time.
0 commit comments