Last active
August 26, 2022 15:42
-
-
Save shurkin18/13f7aabaf95563608aac31ea7199ad6a to your computer and use it in GitHub Desktop.
Mounts the DMG, then runs/installs the installer inside it, then cleans up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Variables, dmgPath is where the DMG installer will be located and the packageName is the installer inside the DMG, | |
# usually it's someting like Install.pkg or Install.mpkg, you need to know what it is and supply it to "packageName" variable | |
# Update these variables based on the DMG/installer you will be using this script on | |
dmgPath="/Users/Shared/Application.dmg" | |
packageName="Install.pkg" | |
################################################################ | |
# DO NOT TOUCH BELOW UNLESS YOU KNOW WHAT YOU ARE DOING! ####### | |
################################################################ | |
# Mount the DMG, and save its' device | |
device=$(/usr/bin/hdiutil attach -nobrowse "$dmgPath" | /usr/bin/grep "/Volumes" | /usr/bin/awk '{ print $1 }') | |
echo "device is: $device" | |
# Using the device, determine the mount point | |
mountPoint=$(/usr/bin/hdiutil info | /usr/bin/grep "^$device" | /usr/bin/cut -f 3) | |
echo "mountPoint is: $mountPoint" | |
# Point to pkg/mpkg | |
pkgToinstall="$mountPoint"/$packageName"" | |
echo "pkgToinstall is: $pkgToinstall" | |
# Install the package | |
/usr/sbin/installer -verbose -pkg "$pkgToinstall" -target / | |
sleep 15 | |
# Detach the volume and remove the DMG with installer | |
/usr/bin/hdiutil detach $device | |
rm -rf /Users/Shared/FortiClient_Installer.dmg | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment