Last active
July 27, 2022 12:26
-
-
Save sgmills/b485206863efacb3e612c7025c238e7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Location of macOS Build plist for comparison | |
# Subsitute your org name for anyOrg, or place in another location | |
buildPlist="/usr/local/anyOrg/macOSBuild.plist" | |
# Get the local os build version | |
# Using build version accounts for supplimental updates as well as dot updates and os upgrades | |
localOS=$( /usr/bin/sw_vers | awk '/BuildVersion/{print $2}' ) | |
# If the macOS Buld plist key does not exist, create it and write the local os into it | |
if ! /usr/libexec/PlistBuddy -c 'print "macOSBuild"' $buildPlist &> /dev/null; then | |
echo "macOS Build plist does not exist. Creating now..." | |
defaults write $buildPlist macOSBuild $localOS | |
else | |
echo "macOS Build plist already exists. Skipping creation..." | |
fi | |
# Get the os from the macOS build plist now that we have ensured it exists | |
plistOS=$( defaults read $buildPlist macOSBuild ) | |
# If the local OS does not match the plist OS do some maintainance | |
if [[ $localOS != $plistOS ]]; then | |
echo "macOS was updated. Performing maintenance now..." | |
# Update inventory | |
echo "Updating inventory..." | |
/usr/local/bin/jamf recon | |
# Update the local plist file | |
echo "Updating plist with new OS build version..." | |
defaults write $buildPlist macOSBuild $localOS | |
else | |
echo "macOS was not updated. Nothing to do here." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment