Last active
January 7, 2016 23:33
-
-
Save calum-github/30edcbce86c5561ac83c to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
| ################################################################ | |
| # # | |
| # Author: Calum Hunter # | |
| # Date: 04-01-2016 # | |
| # Version: 0.2 # | |
| # Purpose: Munki Conditional to determine if the client # | |
| # machine is eligible for iWork and or iLife # | |
| # Based on the bundled software information # | |
| # from Apple. The machines listed were bundled with # | |
| # iLife '11+ OR Yosemite+ iLife and iWork versions # | |
| # # | |
| ################################################################ | |
| # Define some things | |
| CONDITION_ILIFE=ilife_eligible | |
| CONDITION_IWORK=iwork_eligible | |
| # Define paths | |
| DEFAULTS=/usr/bin/defaults | |
| MUNKI_DIR=$($DEFAULTS read /Library/Preferences/ManagedInstalls ManagedInstallDir) | |
| COND_DOMAIN="${MUNKI_DIR}/ConditionalItems" | |
| # Create an array in our conditional plist | |
| $DEFAULTS write "${COND_DOMAIN}" "${CONDITION_IWORK}" | |
| $DEFAULTS write "${COND_DOMAIN}" "${CONDITION_ILIFE}" | |
| # Determine the machine model | |
| getModel=$(sysctl hw.model | awk '{print$2}') | |
| # Print the ilife or iwork eligibility status | |
| notify_success(){ | |
| echo " - [STATUS] iWork status: $iwork_approved ***" | |
| echo " - [STATUS] iLife status: $ilife_approved ***" | |
| } | |
| # write out the key values to the conditional items plist | |
| write_conditionals(){ | |
| $DEFAULTS write "${COND_DOMAIN}" "${CONDITION_ILIFE}" "${ilife_approved}" | |
| $DEFAULTS write "${COND_DOMAIN}" "${CONDITION_IWORK}" "${iwork_approved}" | |
| /usr/bin/plutil -convert xml1 "${COND_DOMAIN}".plist # Convert it from binary to XML in case it gets saved as binary | |
| /bin/chmod 644 "${COND_DOMAIN}".plist # Make sure it has correct permissions | |
| } | |
| # Match our Model Identifier and determine eligibility based on what bundled software the machine came with | |
| case $getModel in | |
| iMac17,1|iMac16,2|iMac16,1|iMac15,1|iMac14,4|iMac14,3|iMac14,2|iMac14,1) # iMac's with iWork and iLife | |
| iwork_approved="yes" | |
| ilife_approved="yes" | |
| write_conditionals | |
| notify_success;; | |
| iMac13,1|iMac13,2|iMac12,1|iMac12,2) # iMacs with just iLife | |
| iwork_approved="no" | |
| ilife_approved="yes" | |
| write_conditionals | |
| notify_success;; | |
| Macmini7,1) # Mac Mini with iwork and ilife | |
| iwork_approved="yes" | |
| ilife_approved="yes" | |
| write_conditionals | |
| notify_success;; | |
| Macmini6,2|Macmini6,1|Macmini5,1,Macmini5,3) # Mac Mini with just ilife | |
| iwork_approved="no" | |
| ilife_approved="yes" | |
| write_conditionals | |
| notify_success;; | |
| MacPro6,1) # Mac Pro with iwork and ilife | |
| iwork_approved="yes" | |
| ilife_approved="yes" | |
| write_conditionals | |
| notify_success;; | |
| MacPro5,1) # Mac pro with ilife only | |
| iwork_approved="no" | |
| ilife_approved="yes" | |
| write_conditionals | |
| notify_success;; | |
| MacBookAir7,2|MacBookAir7,1|MacBookAir6,2|MacBookAir6,1) # MacBook Air with iWork and iLife | |
| iwork_approved="yes" | |
| ilife_approved="yes" | |
| write_conditionals | |
| notify_success;; | |
| MacBookAir5,2|MacBookAir5,1|MacBookAir4,2|MacBookAir4,1|MacBookAir3,2|MacBookAir3,1) # MacBook Air with ilife only | |
| iwork_approved="no" | |
| ilife_approved="yes" | |
| write_conditionals | |
| notify_success;; | |
| MacBookPro12,1|MacBookPro11,5|MacBookPro11,4|MacBookPro11,3|MacBookPro11,2|MacBookPro11,1) # MacBook Pro with iwork and ilife | |
| iwork_approved="yes" | |
| ilife_approved="yes" | |
| write_conditionals | |
| notify_success;; | |
| MacBookPro8,1|MacBookPro8,2|MacBookPro8,3|MacBookPro9,2|MacBookPro9,1|MacBookPro10,1|MacBookPro10,2) # MacBook Pro with ilife only | |
| iwork_approved="no" | |
| ilife_approved="yes" | |
| write_conditionals | |
| notify_success;; | |
| *) | |
| ilife_approved="no" # All machines that don't match the above models | |
| iwork_approved="no" | |
| write_conditionals | |
| notify_success;; | |
| esac | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment