Skip to content

Instantly share code, notes, and snippets.

@pythoninthegrass
Created June 20, 2016 20:17
Show Gist options
  • Save pythoninthegrass/042fb01bd03e87012bc3a73520d23e67 to your computer and use it in GitHub Desktop.
Save pythoninthegrass/042fb01bd03e87012bc3a73520d23e67 to your computer and use it in GitHub Desktop.
#!/bin/bash
JAMFHELPER="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
# Constants
mdmAirport="AirportNetworkName"
jhWindowType="utility"
jhTitle="System Management"
jhDescription="Please select the $mdmAirport network from the AirPort menu in the menu bar."
# The icon to show in the jamfHelper dialog box
jhIcon="/Library/Application Support/JAMF/icon.png"
# Name of the AirPort network which will be removed and added by removing and adding MDM profiles
wifiDevice=$(networksetup -listallhardwareports | grep -A 1 Wi-Fi 2> /dev/null | grep Device 2> /dev/null | awk '{print $2}' 2> /dev/null)
if [[ -z "$wifiDevice" ]]; then
echo "No Wi-Fi device found"
else
echo "Wi-Fi found on device: $wifiDevice"
wifiNetwork=$(networksetup -getairportnetwork "$wifiDevice" | sed 's/Current Wi-Fi Network: //')
if [[ -n "$wifiNetwork" ]]; then
echo "Wi-Fi network: $wifiNetwork"
else
echo "No Wi-Fi network on device $wifiDevice"
fi
fi
echo "Removing MDM Profile"
/usr/sbin/jamf removeMdmProfile -verbose
echo "Sleeping"
sleep 5
if [[ "$wifiNetwork" = "$mdmAirport" ]]; then
echo "Displaying dialog"
killall jamfHelper
"$JAMFHELPER" -windowType "$jhWindowType" -icon "$jhIcon" -title "$jhTitle" -description "$jhDescription" 2> /dev/null &
while true; do
echo "Checking connection"
jssConnection=$(/usr/sbin/jamf checkJSSConnection > /dev/null; echo $?)
if [[ "$jssConnection" -eq 0 ]]; then
echo "Connected to JSS"
killall jamfHelper
break;
fi
echo "Connection timed out"
done
fi
echo "JAMF manage"
/usr/sbin/jamf manage -verbose
/usr/sbin/jamf recon
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment