Install DMG Files using Shell Script

Scalefusion offers support to distribute Apple VPP apps and PKG (product archive packages) natively using the Dashboard. Most Enterprise apps use either of the above mechanisms for distribution in an enterprise scenario, however there might be certain cases where the developer has made the installer available in the form of a DMG (Disk Image File).

In such cases where only a DMG file is available, IT Admins can use the script described below and deploy it via Scalefusion MDM agent to remotely install the DMG. Please follow the steps below to use this method.

1. This method uses script to install the DMG file, though Scalefusion has tested these scripts, please validate the scripts on a test machine before deploying them on all your managed devices.
2. Scalefusion will not be responsible for any loss of data or system malfunction that may arise due to the usage of these scripts.


  1. Deploy Scalefusion MDM Agent
  2. Scalefusion subscription plan with access to Content Management
DMG files which wrap a PKG file that is when extracted contain a PKG file cannot be distributed by this mechanism. We suggest to use the PKG file directly in such cases.

Step 1: Generate a Download URL for DMG file

The first step is to generate a download URL for the DMG file that needs to be installed. You can use any of your servers (if you have one already) or storage provider like Amazon S3, Cloudflare R2 to upload your DMG and generate a public download URL.

In case you don't have a storage provider that you use, you can also use Scalefusion's Content Management to upload your DMG files and obtain a DMG URL. Follow the steps below to upload the file to Scalefusion's content management and generate the download URL,

  1. Navigate to Content Management > Content and click Upload File to upload the DMG.
  1. Wait for the DMG file to be uploaded and to appear in the list of files. Once the file appears click on the file to view the file details window.
  1. Click on the 3 dots and from the menu select Copy Download Link
  1. Now you can open TextEdit (or any text editor) on your Mac/PC and paste the copied URL to your local machine. The URL would look like below,

Step 2: Create the Script

  1. Create a file on your Mac, for example and open it a text editor of your choice like TextEdit
  2. Copy the contents below or click here to download the file from where you can copy the contents



DMGName=`basename $URL`;

cd ~/Downloads/

echo -e "Starting installer for DMG from $URL \n";

http_code="$(curl -w '%{http_code}\n' -o "$DMGName" $URL)"

if [ ! "$http_code" = 200 ]; then
echo "Failed to download file. Failed with error: $http_code";
exit 1;

echo "Starting installation"

VOLUME=`hdiutil attach -nobrowse "$DMGName" | grep Volumes | sed 's/.*\/Volumes\//\/Volumes\//'`
echo -e "\nVolume found : $VOLUME"
cd "$VOLUME"
\cp -rf *.app /Applications
cd ..
hdiutil detach "$VOLUME"

cd ~/Downloads/

if [ $INSTALLED -ne 0 ]; then
echo -e "\nFailed to install"
rm "$DMGName"
exit 1

echo -e "\nSuccessfully installed"
exit 0
  1. Now replace the phrase ENTER_DOWNLOAD_URL_HERE with the download URL that generated in Step 1.
  1. Save the file on your Mac.

Step 3: Deploy the Script

Please use our help document on deploying scripts on macOS devices to upload and publish the script to your managed Mac devices. For easy reference here are the steps,

  1. Navigate to Application Management > Enterprise Store & upload the script as shown below,
    1. Enter Script Name: Enter a name for the script file
    2. Upload Script File: Upload the script file created in Step 2
    3. Run Script as signed-in user: Select Yes from the dropdown
    4. Click Save
  2. Now you can the Publish the script to the device profiles where you want to install this application.
  1. Once the script has been deployed, you can View Status - from the side panel that appears once you click on uploaded script file. Here are sample screenshots,
    1. Successful Installation
    2. Invalid Download URL
    3. Failed to Install DMG File
If you would like to install a DMG from a local file on the managed device, Download the script here and replace the ENTER_PATH_NAME phrase with the path of the local file on the managed Mac device.

How did we do?

Powered by HelpDocs (opens in a new tab)