What It Does
The script downloads the file from DOWNLOAD_URL, or copies SOURCE_FILE if your RMM already staged one. Plain http is refused. It then refuses to continue unless you give a SHA256 of the file or the Developer ID Team ID that must have signed the app or package, or both. The hash is compared first. The Team ID is checked with codesign and spctl for an app, and with pkgutil --check-signature and spctl for a package.
For an app, it is copied into /Applications and an older copy is replaced. If the download holds more than one app, BUNDLE_ID picks the one to install. For an app, it skips a same or newer version with the same bundle ID and refuses to replace a different bundle at the destination. For a package, it skips installation when readable component IDs and versions all match current or newer receipts. If it cannot read the component information, it warns and runs the installer without this check. It checks receipt presence afterwards for any components it could read. A running app is not replaced unless QUIT_APP is true.
It ships no list of apps. You supply the link and the proof. It runs cleanup on exit to remove temporary files and detach the mounted image. The script does not request a restart. A package can make whatever changes its installer performs.
With DRY_RUN=true it still downloads and checks the file, then reports what it would install.
Before You Run It
- Get the SHA256 or the Team ID from the vendor, not from the file you are about to install. A hash you copy from the same place as the download proves nothing.
- Ask the vendor for the Team ID, a 10-character code, if you do not have it.
- Run it with DRY_RUN=true first. It downloads and checks the file and installs nothing.
- Use QUIT_APP only when the user can lose what they have open in the app.
Type and Risk
- Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
- Risk: Low. Set DRY_RUN=true to list every change without making any.
- What it changes: Installs or replaces an app in /Applications, or runs a package installer.
- Restart: It never restarts the machine.
- Typical run: 1 to 10 minutes, mostly the download.
- Example answer: "Installed Widget 2.1 (com.example.widget); Team ID ABCDE12345 verified"
- Tested before listing on macOS 27 (Apple silicon VM) with /bin/bash 3.2, run as root, against its own test cases.
Inputs
Pass an input as an argument (--input-name value), as an environment variable named as listed, which is how most RMMs pass script variables, or change its default in the DEFAULT_ lines near the top of the script. An argument wins over an environment variable, which wins over the default.
- DOWNLOAD_URL: https link to a .dmg, .pkg or .zip. Give this or SOURCE_FILE.
- SOURCE_FILE: A .dmg, .pkg or .zip already on this Mac (staged by your RMM).
- SHA256: SHA256 the file must have. Give this, TEAM_ID, or both.
- TEAM_ID: Developer ID Team ID (10 characters) that must have signed it.
- BUNDLE_ID: Optional. Picks the app inside a disk image or zip with several apps.
- QUIT_APP: Quit the app first if it is running and needs replacing. Default false.
Every script also takes DRY_RUN, OUTPUT_FORMAT (Text, Answer, Json or Csv), EXPORT_PATH and RESULT_FIELD, which writes the answer to an RMM custom field, unless the list above words one differently.
License
Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.