Using an Outset boot-every script to add default applications via Munki


In Bash script to add optional installs for Munki, I introduced a script that uses PlistBuddy to add optional install items to the client machine’s SelfServeManifest.

I thought at first I could use that as a boot-once script for Outset, but it seemed the script ran too early (actual first boot) and then didn’t actually write the values it should.

As a workaround, I’ve put the script in as an Outset boot-every with a check to see if one of the optional items is already in the Munki install log. Here’s an example:

#!/bin/bash

# See if this has ever run before… have to check the log, because Outset will delete the file once run. We don’t want this to re-run if we update the pkg version
alreadyRun=$(cat /Library/Managed\ Installs/Logs/Install.log | grep “Firefox”)

if [ -z “$alreadyRun” ]; then

# Self-serve manifest location
manifestLocation=’/Library/Managed Installs/manifests/SelfServeManifest’

# PlistBuddy full path
plistBuddy=’/usr/libexec/PlistBuddy’

# Add in “optional” default software
optionalDefaults=(“Firefox”
“GoogleChrome”
“MSExcel2016”
“MSWord2016”
“MSPowerPoint2016”
)

# Check to see if the file exists. If it doesn’t, you may have to create it with an empty array; otherwise,
if [ ! -f “$manifestLocation” ]; then
sudo “$plistBuddy” -c “Add :managed_installs array” “$manifestLocation”
fi

for packageName in “${optionalDefaults[@]}”
do
# Check it’s not already in there
alreadyExists=$(“$plistBuddy” -c “Print: managed_installs” “$manifestLocation” | grep “$packageName”)

# Single quote expansion of variables gets messy in bash, so we’re going to pre-double-quote the single-quotes on the package name
alteredPackageName=”‘””$packageName””‘”

if [ -z “$alreadyExists” ]; then
sudo “$plistBuddy” -c “Add :managed_installs: string $alteredPackageName” “$manifestLocation”
fi
done

fi
So this basically checks for Firefox. If Firefox (one of the default optional installs) is in the install log, it won’t run again.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.