Posted on 02-18-2020 03:33 PM
What I'm looking for is a script to run online/offline to check to see if a specific SSID (on site wifi) is available and if so to connect to that wifi.
Or if it has to be connect to a specific SSID if that not available connect to preferred networks...
I'm looking for a way to get computers connected to our network if they lose network connection without the users having to do anything but maybe log out and log back in.
Posted on 02-18-2020 07:31 PM
Can you use a profile with WIFI payload through JAMF Pro?
Posted on 02-19-2020 09:11 AM
We are looking for a backup in case the wifi payload is removed.
Posted on 02-19-2020 09:36 AM
Make the configuration profile non-removable? Once the Jamf MDM profile is present, the WiFi profile will be too.
Posted on 02-19-2020 04:07 PM
I have computers with a configuration profile to connect to a SSID and to auto join that network. I make a change to that configuration profile and turn off auto join. Most computers are on a different SSID so it shouldn't affect them But the ones that are on this SSID, lose their internet connection when the profile is removed to. be added back with the auto join turned off.
So I want a way to be able to run a script that checks for network access.. if no network access and specific SSID is available to connect to that SSID.
Posted on 02-20-2020 06:59 PM
How is this? fill out your SSID you require connection to, your secondary network SSID and secondary wifi Password.
NOTE: this will send your PW in clear text of course but if this does not worry you, this should work.
You could even add a LaunchAgent with a StartInterval of a determined time and it should be pretty automatic.
#!/bin/bash requiredssid= secondarywifi= secondarywifiPW= wifiport=$(networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}') currentssid=$(networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}' | xargs networksetup -getairportnetwork | awk '{print $4}' ) echo $currentssid echo $wifiport if [ "$currentssid" != "$requiredssid" ] then echo incorrect networksetup -setairportnetwork $wifiport $secondarywifi $secondarywifiPW else echo "wifi correct, no action required" fi sudo jamf log
Posted on 02-20-2020 07:07 PM
This one might work better though..... I actually read your requirements
#!/bin/bash
#checks to see your current SSID does not match your required SSID - if success exit
# If it is not then will attempt to connect to primary SSID
#IF this cannot happen or the network is not available then it will attempt to connect to secondary
requiredssid=
primaryssidpw=
secondarywifi=
secondarywifiPW=
wifiint=$(networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}')
currentssid=$(networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}' | xargs networksetup -getairportnetwork | awk '{print $4}' )
wifiavailable=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s | grep "$requiredssid" )
echo "current SSID $currentssid"
echo "Required SSID $requiredssid"
echo "Current interface $wifiint"
if [ "$wifiavailable" != "" ]
then
echo "Wifi connected to $currentssid no change required"
exit 0
else
echo "attempting to connect to primary SSID"
networksetup -setairportnetwork "$wifiint" "$requiredssid" "$primaryssidpw"
sleep 10
if [ "$currentssid" != "$requiredssid" ]
then
echo "Primary SSID not available Attempting Secondary $secondarywifi"
networksetup -setairportnetwork "$wifiint" "$secondarywifi" "$secondarywifiPW"
fi
fi
currentssid=$(networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}' | xargs networksetup -getairportnetwork | awk '{print $4}' )
if [ "$currentssid" != "$requiredssid" ]
then
echo "Sorry, we are unable to connect to wifi"
else
echo "Wifi connected to $currentssid"
fi
sudo jamf log
exit 0
Posted on 02-21-2020 08:07 AM
Thank you! I will test that.