From e484cd8ce143d25f084dc646040307f0f45f0e94 Mon Sep 17 00:00:00 2001 From: Augustin Martignoni Date: Wed, 16 Nov 2022 11:57:32 +0100 Subject: [PATCH 1/3] Replace airport and scselect commands with the networksetup command. --- locationchanger.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locationchanger.sh b/locationchanger.sh index 37f24b3..66eb6d4 100755 --- a/locationchanger.sh +++ b/locationchanger.sh @@ -24,10 +24,10 @@ ts() { ID=`whoami` ts "I am '$ID'" -SSID=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep ' SSID' | cut -d : -f 2- | sed 's/^[ ]*//'` +SSID=`networksetup -getairportnetwork en0 | awk '{print $NF}'` -LOCATION_NAMES=`scselect | tail -n +2 | cut -d \( -f 2- | sed 's/)$//'` -CURRENT_LOCATION=`scselect | tail -n +2 | egrep '^\ +\*' | cut -d \( -f 2- | sed 's/)$//'` +LOCATION_NAMES=`networksetup -listlocations` +CURRENT_LOCATION=`networksetup -getcurrentlocation` ts "Connected to '$SSID'" From 43cddada347315e1149b89b7bf956e8b1749e315 Mon Sep 17 00:00:00 2001 From: Augustin Martignoni Date: Sun, 20 Nov 2022 12:47:03 +0100 Subject: [PATCH 2/3] Generalise selection of WiFi hardware interface. --- locationchanger.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locationchanger.sh b/locationchanger.sh index 66eb6d4..e53ce20 100755 --- a/locationchanger.sh +++ b/locationchanger.sh @@ -24,7 +24,7 @@ ts() { ID=`whoami` ts "I am '$ID'" -SSID=`networksetup -getairportnetwork en0 | awk '{print $NF}'` +SSID=`networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}' | xargs networksetup -getairportnetwork | awk '{print $NF}'` LOCATION_NAMES=`networksetup -listlocations` CURRENT_LOCATION=`networksetup -getcurrentlocation` From cdb71632a490a9031af64ff265cca3b55228443e Mon Sep 17 00:00:00 2001 From: Giles Wells Date: Tue, 20 Dec 2022 15:18:02 -0500 Subject: [PATCH 3/3] Add skip for the root run to address issue #28 --- locationchanger.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/locationchanger.sh b/locationchanger.sh index e53ce20..1090646 100755 --- a/locationchanger.sh +++ b/locationchanger.sh @@ -24,6 +24,11 @@ ts() { ID=`whoami` ts "I am '$ID'" +if [ "$ID" == "root" ]; then + ts "Running as root will read a bad config, exiting." + exit 1; +fi + SSID=`networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}' | xargs networksetup -getairportnetwork | awk '{print $NF}'` LOCATION_NAMES=`networksetup -listlocations`