Posted on 09-13-2023 12:31 PM
Hello,
I am trying to run my Office 365 download through Jamf Pro and I am getting the following errors:
[STEP 1 of 4] |
Executing Policy Installing Microsoft Office |
[STEP 2 of 4] |
Running script install_pkg.sh... |
Script exit code: 4 |
Script result: https://go.microsoft.com/fwlink/?linkid=XXXXXXX Download URL: https://go.microsoft.com/fwlink/?linkid=XXXXXXX Downloading the installation files... hdiutil: attach failed - image not recognized Failed to mount the downloaded dmg; exiting. Cleaning up installation files... |
Error running script: return code was 4. |
[STEP 3 of 4] |
[STEP 4 of 4] |
09-13-2023 12:34 PM - edited 09-13-2023 12:35 PM
What exactly is your script doing? Is there a reason you don't download the installer package from https://macadmins.software and upload directly to your Jamf Pro server for distribution, or use Installomator?
Posted on 09-13-2023 12:56 PM
The script is supposed to download Microsoft office automatically from from Jamf pro. Here is the whole package file:
Posted on 09-13-2023 12:41 PM
i've used this script for years, has always worked well to download and install office.
hope that helps.
<code>
#!/bin/bash
#Caffeinate to disable sleep
echo "Status: Disabling sleep on your Mac while we do some things."
caffeinate -d -i -m -u &
caffeinatepid=$!
/usr/bin/curl -JL "https://go.microsoft.com/fwlink/?linkid=525133" -o /tmp/Office_2019_Latest.pkg
installer -pkg /tmp/Office_2019_Latest.pkg -target /
rm -f /tmp/Office_2019_Latest.pkg
kill "$caffeinatepid"
exit 0
</code>
09-14-2023 07:06 AM - edited 09-14-2023 07:12 AM
Yeah this seems to work.
Posted on 09-13-2023 12:55 PM
while some orgs allow a external pull for a pkg, its not something I would recommend.
Either use JAMF Mac Apps if cloud and that works for you
Or
Download the pkg from Mac Admins and scope that pkg as required.
Posted on 09-13-2023 12:55 PM
The issue is likely with your script. Can you share it?
Posted on 09-13-2023 01:01 PM
#!/bin/bash
downloadURL="$4"
useCommandToGetDownloadURL="$5" # "true" or empty
uuid=$(/usr/bin/uuidgen)
workDir="/private/tmp/$uuid"
function clean_up () {
echo "Cleaning up installation files..."
/usr/bin/hdiutil unmount "$device" -force &> /dev/null
/bin/rm -Rf "$workDir"
/bin/ps -p "$caffeinatePID" > /dev/null && /bin/kill "$caffeinatePID"; wait "$caffeinatePID" 2>/dev/null
}
# Clean up our temporary files upon exiting at any time
trap "clean_up" EXIT
#Check is an old version is there and remove it if it exists
if [ -d "/Applications/OpenVPN Connect.app/" ]; then
echo "Removing Old Version"
'/Applications/OpenVPN/Uninstall OpenVPN Connect.app/Contents/Resources/remove.sh'
fi
# Determine if we are calculating the URL or just using a static url
if [[ "$useCommandToGetDownloadURL" == "true" ]]; then
echo "Calculating Download URL from command."
downloadURL="$(eval "$4")"
fi
echo $5
# Exit if our download url is empty
if [[ -z "$downloadURL" ]]; then
echo "Please specify a URL (parameter 4)."
exit 1
fi
echo $downloadURL
# Caffeinate the Mac so it does not sleep
/usr/bin/caffeinate -d -i -m -u &
caffeinatePID=$!
# Make our working directory with our unique UUID generated in the variables section
/bin/mkdir -p "$workDir"
# Print the download url to help with troubleshooting
echo "Download URL: $downloadURL"
# Exit if there was an error with the curl
echo "Downloading the installation files..."
if ! /usr/bin/curl -s -L -f "$downloadURL" -o "$workDir/installMedium.dmg" ; then
echo "Error while downloading the installation files; exiting."
exit 2
fi
# If no DMG was found in the install files, bail out
if [[ ! -e "$workDir/installMedium.dmg" ]]; then
echo "Failed to download the installation files; exiting."
exit 3
fi
# Mount the DMG, and save its device
device=$(/usr/bin/hdiutil attach -noautoopen -nobrowse "$workDir/installMedium.dmg" | /usr/bin/grep "/Volumes" | /usr/bin/awk '{ print $1 }')
if [[ -z "$device" ]]; then
echo "Failed to mount the downloaded dmg; exiting."
exit 4
fi
# Using the device, determine the mount point
mountPoint=$(/usr/bin/hdiutil info | /usr/bin/grep "^$device" | /usr/bin/cut -f 3)
# Find the pkg inside the DMG
package=$(find "$mountPoint" -type f -iname "*.pkg" -maxdepth 1)
# If no app was found in the dmg, bail out
if [[ -z "$package" ]]; then
echo "Failed to find pkg in downloaded installation files; exiting."
exit 5
fi
if ! installer -pkg "$package" -target / ; then
echo "Failed to install the pkg; exiting."
exit 6
fi
exit 0
Posted on 09-14-2023 08:16 AM
I would highly recommend packaging Office and deploying, or using VPP. DNS poisoning can easily happen and there is no code signature validation happening in this script.
Posted on 09-16-2023 05:20 AM
@ofakilede Are you sure that you do not have any restrictions applied via Jamf Configuration Profile Restriction Payload to disallow the Disk Images?