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>
The issue is likely with your script. Can you share it?
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.
https://macadmins.software/
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?
The script is supposed to download Microsoft office automatically from from Jamf pro. Here is the whole package file:
#!/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
The issue is likely with your script. Can you share it?
#!/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
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>
Yeah this seems to work.
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.
@ofakilede Are you sure that you do not have any restrictions applied via Jamf Configuration Profile Restriction Payload to disallow the Disk Images?