The .dmg disk image is a particularly tricky format. The main reason for this is that a .dmg file must be mounted by the macOS file system before the installation files contained within it can be examined and installed.
For this reason, Addigy recommends that you remove .pkg installations from within the .dmg and upload it individually when at all possible.
However, sometimes the software will require installation from within the .dmg volume. In this case, you will need to generate your own Installation script. The other steps for this Smart Software should mirror the .pkg installation described in our article Creating Smart Software.
In our example, we’ll be installing Firefox. Specifically, my Firefox .dmg has a ".app" file inside of the .dmg drive.
I've entered the basic information of the Smart Software item and already uploaded the .dmg file.
All that's left are the scripts.
To install from a .dmg we need to accomplish these three major steps:
1) Mount the .dmg file.
2) Install files and software from the mounted volume.
3) Unmount the .dmg file.
Steps 1 and 3 are largely the same for every .dmg installation, all that needs to be changed are the paths for the commands to work.
Here's the Installation Script that performs all these steps:
hdiutil attach -nobrowse "/Library/Addigy/ansible/packages/Firefox Example (75.0.0)/Firefox 75.0.dmg" cp -R /Volumes/Firefox/Firefox.app /Applications/ sudo hdiutil detach /Volumes/Firefox/
Note: Since I’ve used Firefox for my example, be sure to change the directory names to match your Smart Software and file names.
If you're unsure where to get the Smart Software directory, you can find it at the top of the Edit Software page.
Don't forget to put the .dmg file path in after the Smart Software name, and if there are spaces in the directory, be sure to add quotes just like the example below.
"/Library/Addigy/ansible/packages/My Smart Software (1.0.0)/My DMG.dmg"
The Condition script for this software is quite simple. It checks to see if the software we installed is in the correct folder.
if [ -f '/Applications/Firefox.app' ]; then exit 1 fi exit 0
The Condition Script for your Smart Software will likely be very different, but even a simple script similar to this which checks for existing files can serve as a perfectly good Condition.
If you'd also like to ensure the removal of your Smart Software when a device is removed from the appropriate policy, you may want to add a Removal script to the Smart Software payload.
If you have an Addigy account and have additional questions, you can create a ticket by emailing email@example.com.
Alternatively, you can submit a support request within Addigy.