This worklet will evaluate Mac devices to ensure the latest version of Firefox is installed. If the worklet finds the Firefox applications is not installed, the remediation code will install it on the device.
Evaluation:
#!/bin/bash
#example script for installing Firefox on Mac devices
#evaluate the device to see if Firefox is currently installed.
if [ -d "/Applications/firefox.app" ]; then
exit 0
else
exit 1
fi
Remediation:
#!/bin/bash
#example script for installing Firefox on Mac devices
#create a temporary directory to download Firefox install file
set -e
tempfile=$(mktemp)
#download the latest version of Firefox to the temp file
echo "Downloading Firefox..."
curl -L "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -o "$tempfile"
echo "Installing Firefox..."
#mount the firefox dmg file to a volume
hdiutil attach /tmp/Firefox.dmg
#copy the firefox app to the devices applications
cp -R /Volumes/Firefox/Firefox.app/ /Applications/Firefox.app
#remove tmp file and unmount the image from the volume
echo "Cleaning up..."
hdiutil detach /Volumes/Firefox/ -quiet
sleep 2
rm -f "$tempfile"