Skip to main content

Anyone gotta script that will automatically download the latest version of Dropbox?



As the app is constantly updated, I'd like to have self service and enrollment policy that will always grab the latest version, but their download link does not lead to a specific DMG or package. With other apps I do this via CURL, but that doesn't seem to be an option here.



https://www.dropbox.com/download?os=mac

Thanks guys! worked perfectly!!!



#!/bin/sh
curl -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15" -L https://www.dropbox.com/download?os=mac > /var/tmp/DropBoxInstaller.dmg
hdiutil attach /var/tmp/DropBoxInstaller.dmg
cd /Volumes/Dropbox Installer/Dropbox.app/Contents/MacOS/
./Dropbox Installer
hdiutil detach /Volumes/Dropbox Installer/
rm -rf /var/tmp/DropBoxInstaller.dmg
exit 0


This article is a bit old. Only know if this still works for Mac OS 12 and/or  M1 machines? 

 


This article is a bit old. Only know if this still works for Mac OS 12 and/or  M1 machines? 

 


Check the script posted by KretZoR on â€Ž08-03-2021 01:45 PM.  That version was tested on M1s and Big Sur, and will probably work on Monterey as well.


Hi everyone,

I have after your input created a new version of the script (version 1.3) to handle the issues that @RobL and @techgeek found. I have "borrowed" some code from your general purpose script @sam_clark  to solve one of the issues 😉

#!/bin/bash

###############################################################################################################################################
#
# Install or Update Dropbox
#
# Created By: Jamf Nation
# Description: Installs or updates Dropbox
# Prerequisites: None
#
###############################################################################################################################################
#
# HISTORY
#
# Version: 1.3
#
# - v1.0 Jamf Nation, 2019-11-07 : https://www.jamf.com/jamf-nation/discussions/32726/script-to-always-download-the-latest-version-of-dropbox
# - v1.1 Martin Kretz, 2020-02-27 : Changed download URL, unmount behavior and added functions and checks
# - v1.2 Martin Kretz, 2021-03-24 : Added StableVersion variable to populate the new download URL
# - v1.3 Martin Kretz, 2021-08-03 : Fixed issue with variable "StableVersion" having text "Stable Build" in front (thanks "RobL" at Jamf Nation for finding the issue). Fixed issue with standard user not being able to open app without authentication (thanks "sam_clark" at Jamf Nation for solving the issue in your general purpose install script)
#
################################################################################################################################################

# Get current user
currentUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name 😕😕 && ! /loginwindow/ { print $3 }')

# Get latest stable Dropbox version
StableVersion=$(curl -s 'https://www.dropboxforum.com/t5/forums/filteredbylabelpage/board-id/101003016/label-name/stable%20build' | grep -m "1" -a "Stable Build" | sed -e 's/.*Build\\(.*\\).*/\\1/' | sed -e 's/<[^>]*>//g' | sed 's/^ *//g')

# Curl variables
DownloadURL="https://clientupdates.dropboxstatic.com/dbx-releng/client/Dropbox%20$StableVersion.dmg"
MountPath="/var/tmp/DropBox Installer.dmg"
UserAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15"

# Empty variable to populate with "yes" if current user is admin user
Admin=""

# Function to check if user is admin user
CheckAdmin ()
{
# Checking if user is admin
if [[ -n $(id -Gn "${currentUser}" | grep "admin") ]]; then
Admin="$Admin yes"
fi
}

# Function to copy application from mounted DMG to local Applications folder
CopyApp ()
{
# Checking if user is admin
CheckAdmin

# Remove earlier versions of Dropbox
rm -fR "/Applications/Dropbox.app"

# Copy app file to applications folder
Copy=$(cp -R "/Volumes/Dropbox Offline Installer/Dropbox.app" "/Applications/Dropbox.app")
if $Copy;then
echo "INFO - Application copied to local Applications folder"
else
echo "ERROR- Could not copy files from mounted DMG to local Applications folder"
exit 1
fi

# Set perimssions to app file
/bin/chmod 755 "/Applications/Dropbox.app" && echo "INFO - Permissions set"

# Set owner to app file depending on user type
if /bin/echo "$Admin" | grep yes;then
echo "INFO - User is admin, setting admin rights to app"
/usr/sbin/chown -R root:wheel "/Applications/Dropbox.app"
else
echo "INFO - User is standard, setting standard rights to app"
/usr/sbin/chown -R "${currentUser}":wheel "/Applications/Dropbox.app"
fi
}

# Function to check if application is running
CheckRunning ()
{
# If Dropbox is running kill its processes
if pgrep "Dropbox";then
echo "INFO - Application is currently running, trying to kill application processes"
AppKill=$(killall "Dropbox";sleep 5)

# If Dropbox kill successfull function "CopyApp" will run else script will stop with error
if $AppKill;then
echo "INFO - Application kill confirmed!"
CopyApp
else
echo "ERROR - Could not kill application"
exit 1
fi
else
echo "INFO - Application is not running. Proceeding with install/update..."
CopyApp
fi
}

# Function to check if application is installed
CheckInstalled ()
{
if [ -e "/Applications/Dropbox.app" ]; then
echo "INFO - Application installed, checking versions."

# Get current version of Dropbox
DropboxCurrentVersion=$(defaults read "/Applications/Dropbox.app/Contents/Info.plist" CFBundleShortVersionString | sed -e 's/\\.//g')
echo "INFO - Current version is: $DropboxCurrentVersion"

# Get latest version of Dropbox
DropboxLatestVersion=$(defaults read "/Volumes/Dropbox Offline Installer/Dropbox.app/Contents/Info.plist" CFBundleShortVersionString | sed -e 's/\\.//g')
echo "INFO - Latest version is: $DropboxLatestVersion"

# If current version is lower than latest version run function "CheckRunning" else end script successfull
if [ "$DropboxCurrentVersion" -lt "$DropboxLatestVersion" ]; then
# Copy application from mounted DMG to local Applications folder
echo "INFO - Latest version newer than current version. Update will begin!"
CheckRunning
else
echo "INFO - Current version same or higher than latest stable version. No update needed!"
exit 0
fi

else
echo "INFO - Appication not installed. Installation will begin!"
CheckRunning
fi

}

# Download DMG from vendor
echo "INFO - Downloading DMG"
curl -A "$UserAgent" -L "$DownloadURL" > "$MountPath"

# Mount DMG
echo "INFO - Mounting DMG"
hdiutil attach "$MountPath" -nobrowse

# Check if application is already installed
echo "INFO - Checking if application is installed"
CheckInstalled

# Change to other directory than installer to prevent unmount to fail
echo "INFO - Changing to other directory than installer to prevent unmount to fail"
cd /var/tmp/

# Unmount DMG
echo "INFO - Unmounting DMG"
hdiutil detach /Volumes/Dropbox\\ Offline\\ Installer/ -force

# Remove temporary files
echo "INFO - Removing temporary files"
rm -rf "$MountPath"

# Start application
echo "INFO - Starting application"
open -a /Applications/Dropbox.app

exit 0

 

Please try it out and let me know if it works or there are any issues.
 


This is a great script, but it downloads the Intel version of the app and I need the Universal version. Has anyone else reported this?


Hi everyone,

I have after your input created a new version of the script (version 1.3) to handle the issues that @RobL and @techgeek found. I have "borrowed" some code from your general purpose script @sam_clark  to solve one of the issues 😉

#!/bin/bash

###############################################################################################################################################
#
# Install or Update Dropbox
#
# Created By: Jamf Nation
# Description: Installs or updates Dropbox
# Prerequisites: None
#
###############################################################################################################################################
#
# HISTORY
#
# Version: 1.3
#
# - v1.0 Jamf Nation, 2019-11-07 : https://www.jamf.com/jamf-nation/discussions/32726/script-to-always-download-the-latest-version-of-dropbox
# - v1.1 Martin Kretz, 2020-02-27 : Changed download URL, unmount behavior and added functions and checks
# - v1.2 Martin Kretz, 2021-03-24 : Added StableVersion variable to populate the new download URL
# - v1.3 Martin Kretz, 2021-08-03 : Fixed issue with variable "StableVersion" having text "Stable Build" in front (thanks "RobL" at Jamf Nation for finding the issue). Fixed issue with standard user not being able to open app without authentication (thanks "sam_clark" at Jamf Nation for solving the issue in your general purpose install script)
#
################################################################################################################################################

# Get current user
currentUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name 😕😕 && ! /loginwindow/ { print $3 }')

# Get latest stable Dropbox version
StableVersion=$(curl -s 'https://www.dropboxforum.com/t5/forums/filteredbylabelpage/board-id/101003016/label-name/stable%20build' | grep -m "1" -a "Stable Build" | sed -e 's/.*Build\\(.*\\).*/\\1/' | sed -e 's/<[^>]*>//g' | sed 's/^ *//g')

# Curl variables
DownloadURL="https://clientupdates.dropboxstatic.com/dbx-releng/client/Dropbox%20$StableVersion.dmg"
MountPath="/var/tmp/DropBox Installer.dmg"
UserAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15"

# Empty variable to populate with "yes" if current user is admin user
Admin=""

# Function to check if user is admin user
CheckAdmin ()
{
# Checking if user is admin
if [[ -n $(id -Gn "${currentUser}" | grep "admin") ]]; then
Admin="$Admin yes"
fi
}

# Function to copy application from mounted DMG to local Applications folder
CopyApp ()
{
# Checking if user is admin
CheckAdmin

# Remove earlier versions of Dropbox
rm -fR "/Applications/Dropbox.app"

# Copy app file to applications folder
Copy=$(cp -R "/Volumes/Dropbox Offline Installer/Dropbox.app" "/Applications/Dropbox.app")
if $Copy;then
echo "INFO - Application copied to local Applications folder"
else
echo "ERROR- Could not copy files from mounted DMG to local Applications folder"
exit 1
fi

# Set perimssions to app file
/bin/chmod 755 "/Applications/Dropbox.app" && echo "INFO - Permissions set"

# Set owner to app file depending on user type
if /bin/echo "$Admin" | grep yes;then
echo "INFO - User is admin, setting admin rights to app"
/usr/sbin/chown -R root:wheel "/Applications/Dropbox.app"
else
echo "INFO - User is standard, setting standard rights to app"
/usr/sbin/chown -R "${currentUser}":wheel "/Applications/Dropbox.app"
fi
}

# Function to check if application is running
CheckRunning ()
{
# If Dropbox is running kill its processes
if pgrep "Dropbox";then
echo "INFO - Application is currently running, trying to kill application processes"
AppKill=$(killall "Dropbox";sleep 5)

# If Dropbox kill successfull function "CopyApp" will run else script will stop with error
if $AppKill;then
echo "INFO - Application kill confirmed!"
CopyApp
else
echo "ERROR - Could not kill application"
exit 1
fi
else
echo "INFO - Application is not running. Proceeding with install/update..."
CopyApp
fi
}

# Function to check if application is installed
CheckInstalled ()
{
if [ -e "/Applications/Dropbox.app" ]; then
echo "INFO - Application installed, checking versions."

# Get current version of Dropbox
DropboxCurrentVersion=$(defaults read "/Applications/Dropbox.app/Contents/Info.plist" CFBundleShortVersionString | sed -e 's/\\.//g')
echo "INFO - Current version is: $DropboxCurrentVersion"

# Get latest version of Dropbox
DropboxLatestVersion=$(defaults read "/Volumes/Dropbox Offline Installer/Dropbox.app/Contents/Info.plist" CFBundleShortVersionString | sed -e 's/\\.//g')
echo "INFO - Latest version is: $DropboxLatestVersion"

# If current version is lower than latest version run function "CheckRunning" else end script successfull
if [ "$DropboxCurrentVersion" -lt "$DropboxLatestVersion" ]; then
# Copy application from mounted DMG to local Applications folder
echo "INFO - Latest version newer than current version. Update will begin!"
CheckRunning
else
echo "INFO - Current version same or higher than latest stable version. No update needed!"
exit 0
fi

else
echo "INFO - Appication not installed. Installation will begin!"
CheckRunning
fi

}

# Download DMG from vendor
echo "INFO - Downloading DMG"
curl -A "$UserAgent" -L "$DownloadURL" > "$MountPath"

# Mount DMG
echo "INFO - Mounting DMG"
hdiutil attach "$MountPath" -nobrowse

# Check if application is already installed
echo "INFO - Checking if application is installed"
CheckInstalled

# Change to other directory than installer to prevent unmount to fail
echo "INFO - Changing to other directory than installer to prevent unmount to fail"
cd /var/tmp/

# Unmount DMG
echo "INFO - Unmounting DMG"
hdiutil detach /Volumes/Dropbox\\ Offline\\ Installer/ -force

# Remove temporary files
echo "INFO - Removing temporary files"
rm -rf "$MountPath"

# Start application
echo "INFO - Starting application"
open -a /Applications/Dropbox.app

exit 0

 

Please try it out and let me know if it works or there are any issues.
 


version 1.3 no longer returns the latest dropbox build - the board id has changed. Are you updating this script?

 


Hi everyone,

I have after your input created a new version of the script (version 1.3) to handle the issues that @RobL and @techgeek found. I have "borrowed" some code from your general purpose script @sam_clark  to solve one of the issues 😉

#!/bin/bash

###############################################################################################################################################
#
# Install or Update Dropbox
#
# Created By: Jamf Nation
# Description: Installs or updates Dropbox
# Prerequisites: None
#
###############################################################################################################################################
#
# HISTORY
#
# Version: 1.3
#
# - v1.0 Jamf Nation, 2019-11-07 : https://www.jamf.com/jamf-nation/discussions/32726/script-to-always-download-the-latest-version-of-dropbox
# - v1.1 Martin Kretz, 2020-02-27 : Changed download URL, unmount behavior and added functions and checks
# - v1.2 Martin Kretz, 2021-03-24 : Added StableVersion variable to populate the new download URL
# - v1.3 Martin Kretz, 2021-08-03 : Fixed issue with variable "StableVersion" having text "Stable Build" in front (thanks "RobL" at Jamf Nation for finding the issue). Fixed issue with standard user not being able to open app without authentication (thanks "sam_clark" at Jamf Nation for solving the issue in your general purpose install script)
#
################################################################################################################################################

# Get current user
currentUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name 😕😕 && ! /loginwindow/ { print $3 }')

# Get latest stable Dropbox version
StableVersion=$(curl -s 'https://www.dropboxforum.com/t5/forums/filteredbylabelpage/board-id/101003016/label-name/stable%20build' | grep -m "1" -a "Stable Build" | sed -e 's/.*Build\\(.*\\).*/\\1/' | sed -e 's/<[^>]*>//g' | sed 's/^ *//g')

# Curl variables
DownloadURL="https://clientupdates.dropboxstatic.com/dbx-releng/client/Dropbox%20$StableVersion.dmg"
MountPath="/var/tmp/DropBox Installer.dmg"
UserAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15"

# Empty variable to populate with "yes" if current user is admin user
Admin=""

# Function to check if user is admin user
CheckAdmin ()
{
# Checking if user is admin
if [[ -n $(id -Gn "${currentUser}" | grep "admin") ]]; then
Admin="$Admin yes"
fi
}

# Function to copy application from mounted DMG to local Applications folder
CopyApp ()
{
# Checking if user is admin
CheckAdmin

# Remove earlier versions of Dropbox
rm -fR "/Applications/Dropbox.app"

# Copy app file to applications folder
Copy=$(cp -R "/Volumes/Dropbox Offline Installer/Dropbox.app" "/Applications/Dropbox.app")
if $Copy;then
echo "INFO - Application copied to local Applications folder"
else
echo "ERROR- Could not copy files from mounted DMG to local Applications folder"
exit 1
fi

# Set perimssions to app file
/bin/chmod 755 "/Applications/Dropbox.app" && echo "INFO - Permissions set"

# Set owner to app file depending on user type
if /bin/echo "$Admin" | grep yes;then
echo "INFO - User is admin, setting admin rights to app"
/usr/sbin/chown -R root:wheel "/Applications/Dropbox.app"
else
echo "INFO - User is standard, setting standard rights to app"
/usr/sbin/chown -R "${currentUser}":wheel "/Applications/Dropbox.app"
fi
}

# Function to check if application is running
CheckRunning ()
{
# If Dropbox is running kill its processes
if pgrep "Dropbox";then
echo "INFO - Application is currently running, trying to kill application processes"
AppKill=$(killall "Dropbox";sleep 5)

# If Dropbox kill successfull function "CopyApp" will run else script will stop with error
if $AppKill;then
echo "INFO - Application kill confirmed!"
CopyApp
else
echo "ERROR - Could not kill application"
exit 1
fi
else
echo "INFO - Application is not running. Proceeding with install/update..."
CopyApp
fi
}

# Function to check if application is installed
CheckInstalled ()
{
if [ -e "/Applications/Dropbox.app" ]; then
echo "INFO - Application installed, checking versions."

# Get current version of Dropbox
DropboxCurrentVersion=$(defaults read "/Applications/Dropbox.app/Contents/Info.plist" CFBundleShortVersionString | sed -e 's/\\.//g')
echo "INFO - Current version is: $DropboxCurrentVersion"

# Get latest version of Dropbox
DropboxLatestVersion=$(defaults read "/Volumes/Dropbox Offline Installer/Dropbox.app/Contents/Info.plist" CFBundleShortVersionString | sed -e 's/\\.//g')
echo "INFO - Latest version is: $DropboxLatestVersion"

# If current version is lower than latest version run function "CheckRunning" else end script successfull
if [ "$DropboxCurrentVersion" -lt "$DropboxLatestVersion" ]; then
# Copy application from mounted DMG to local Applications folder
echo "INFO - Latest version newer than current version. Update will begin!"
CheckRunning
else
echo "INFO - Current version same or higher than latest stable version. No update needed!"
exit 0
fi

else
echo "INFO - Appication not installed. Installation will begin!"
CheckRunning
fi

}

# Download DMG from vendor
echo "INFO - Downloading DMG"
curl -A "$UserAgent" -L "$DownloadURL" > "$MountPath"

# Mount DMG
echo "INFO - Mounting DMG"
hdiutil attach "$MountPath" -nobrowse

# Check if application is already installed
echo "INFO - Checking if application is installed"
CheckInstalled

# Change to other directory than installer to prevent unmount to fail
echo "INFO - Changing to other directory than installer to prevent unmount to fail"
cd /var/tmp/

# Unmount DMG
echo "INFO - Unmounting DMG"
hdiutil detach /Volumes/Dropbox\\ Offline\\ Installer/ -force

# Remove temporary files
echo "INFO - Removing temporary files"
rm -rf "$MountPath"

# Start application
echo "INFO - Starting application"
open -a /Applications/Dropbox.app

exit 0

 

Please try it out and let me know if it works or there are any issues.
 


the curl command to find the latest version of Dropbox with this URL works - 

'https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/308787'


Hi everyone,

I have after your input created a new version of the script (version 1.3) to handle the issues that @RobL and @techgeek found. I have "borrowed" some code from your general purpose script @sam_clark  to solve one of the issues 😉

#!/bin/bash

###############################################################################################################################################
#
# Install or Update Dropbox
#
# Created By: Jamf Nation
# Description: Installs or updates Dropbox
# Prerequisites: None
#
###############################################################################################################################################
#
# HISTORY
#
# Version: 1.3
#
# - v1.0 Jamf Nation, 2019-11-07 : https://www.jamf.com/jamf-nation/discussions/32726/script-to-always-download-the-latest-version-of-dropbox
# - v1.1 Martin Kretz, 2020-02-27 : Changed download URL, unmount behavior and added functions and checks
# - v1.2 Martin Kretz, 2021-03-24 : Added StableVersion variable to populate the new download URL
# - v1.3 Martin Kretz, 2021-08-03 : Fixed issue with variable "StableVersion" having text "Stable Build" in front (thanks "RobL" at Jamf Nation for finding the issue). Fixed issue with standard user not being able to open app without authentication (thanks "sam_clark" at Jamf Nation for solving the issue in your general purpose install script)
#
################################################################################################################################################

# Get current user
currentUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name 😕😕 && ! /loginwindow/ { print $3 }')

# Get latest stable Dropbox version
StableVersion=$(curl -s 'https://www.dropboxforum.com/t5/forums/filteredbylabelpage/board-id/101003016/label-name/stable%20build' | grep -m "1" -a "Stable Build" | sed -e 's/.*Build\\(.*\\).*/\\1/' | sed -e 's/<[^>]*>//g' | sed 's/^ *//g')

# Curl variables
DownloadURL="https://clientupdates.dropboxstatic.com/dbx-releng/client/Dropbox%20$StableVersion.dmg"
MountPath="/var/tmp/DropBox Installer.dmg"
UserAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15"

# Empty variable to populate with "yes" if current user is admin user
Admin=""

# Function to check if user is admin user
CheckAdmin ()
{
# Checking if user is admin
if [[ -n $(id -Gn "${currentUser}" | grep "admin") ]]; then
Admin="$Admin yes"
fi
}

# Function to copy application from mounted DMG to local Applications folder
CopyApp ()
{
# Checking if user is admin
CheckAdmin

# Remove earlier versions of Dropbox
rm -fR "/Applications/Dropbox.app"

# Copy app file to applications folder
Copy=$(cp -R "/Volumes/Dropbox Offline Installer/Dropbox.app" "/Applications/Dropbox.app")
if $Copy;then
echo "INFO - Application copied to local Applications folder"
else
echo "ERROR- Could not copy files from mounted DMG to local Applications folder"
exit 1
fi

# Set perimssions to app file
/bin/chmod 755 "/Applications/Dropbox.app" && echo "INFO - Permissions set"

# Set owner to app file depending on user type
if /bin/echo "$Admin" | grep yes;then
echo "INFO - User is admin, setting admin rights to app"
/usr/sbin/chown -R root:wheel "/Applications/Dropbox.app"
else
echo "INFO - User is standard, setting standard rights to app"
/usr/sbin/chown -R "${currentUser}":wheel "/Applications/Dropbox.app"
fi
}

# Function to check if application is running
CheckRunning ()
{
# If Dropbox is running kill its processes
if pgrep "Dropbox";then
echo "INFO - Application is currently running, trying to kill application processes"
AppKill=$(killall "Dropbox";sleep 5)

# If Dropbox kill successfull function "CopyApp" will run else script will stop with error
if $AppKill;then
echo "INFO - Application kill confirmed!"
CopyApp
else
echo "ERROR - Could not kill application"
exit 1
fi
else
echo "INFO - Application is not running. Proceeding with install/update..."
CopyApp
fi
}

# Function to check if application is installed
CheckInstalled ()
{
if [ -e "/Applications/Dropbox.app" ]; then
echo "INFO - Application installed, checking versions."

# Get current version of Dropbox
DropboxCurrentVersion=$(defaults read "/Applications/Dropbox.app/Contents/Info.plist" CFBundleShortVersionString | sed -e 's/\\.//g')
echo "INFO - Current version is: $DropboxCurrentVersion"

# Get latest version of Dropbox
DropboxLatestVersion=$(defaults read "/Volumes/Dropbox Offline Installer/Dropbox.app/Contents/Info.plist" CFBundleShortVersionString | sed -e 's/\\.//g')
echo "INFO - Latest version is: $DropboxLatestVersion"

# If current version is lower than latest version run function "CheckRunning" else end script successfull
if [ "$DropboxCurrentVersion" -lt "$DropboxLatestVersion" ]; then
# Copy application from mounted DMG to local Applications folder
echo "INFO - Latest version newer than current version. Update will begin!"
CheckRunning
else
echo "INFO - Current version same or higher than latest stable version. No update needed!"
exit 0
fi

else
echo "INFO - Appication not installed. Installation will begin!"
CheckRunning
fi

}

# Download DMG from vendor
echo "INFO - Downloading DMG"
curl -A "$UserAgent" -L "$DownloadURL" > "$MountPath"

# Mount DMG
echo "INFO - Mounting DMG"
hdiutil attach "$MountPath" -nobrowse

# Check if application is already installed
echo "INFO - Checking if application is installed"
CheckInstalled

# Change to other directory than installer to prevent unmount to fail
echo "INFO - Changing to other directory than installer to prevent unmount to fail"
cd /var/tmp/

# Unmount DMG
echo "INFO - Unmounting DMG"
hdiutil detach /Volumes/Dropbox\\ Offline\\ Installer/ -force

# Remove temporary files
echo "INFO - Removing temporary files"
rm -rf "$MountPath"

# Start application
echo "INFO - Starting application"
open -a /Applications/Dropbox.app

exit 0

 

Please try it out and let me know if it works or there are any issues.
 


Hi all,

I have started using Installomator instead of updating this script, I suggest you do the same. It is my new go-to script for installing applications directly from the developers. It support hundreds of other applications aswell!

GitHub - Installomator/Installomator: Installation script to deploy standard software on Macs


Hi all,

I have started using Installomator instead of updating this script, I suggest you do the same. It is my new go-to script for installing applications directly from the developers. It support hundreds of other applications aswell!

GitHub - Installomator/Installomator: Installation script to deploy standard software on Macs


Dredging this one back up. Here's a simple script that is working for us in Ventura. Running from Self Service with standard users.

 

 

#!/bin/sh
#Written by Aaron Getz 2/10/23

loggedInUser=$(stat -f%Su /dev/console)
loggedInUID=$(id -u "$loggedInUser")

dmgfile="DropBoxInstaller.dmg"
logfile="/Library/Logs/DropboxInstallScript.log"
url="https://www.dropbox.com/download?full=1&plat=mac"


echo "`date`: Download URL: $url" >> ${logfile}

/bin/echo "`date`: Downloading latest version." >> ${logfile}
curl -L "$url" > /Users/Shared/${dmgfile}

/bin/echo "`date`: Mounting DMG..." >> ${logfile}
hdiutil attach -nobrowse /Users/Shared/${dmgfile}

sleep 5

/bin/echo "`date`: Installing App..." >> ${logfile}
cd /Volumes/Dropbox\\ Offline\\ Installer/Dropbox.app/Contents/MacOS/
./Dropbox

#Set hidden dropbox folder permissions
chown ${loggedInUser} /Users/${loggedInUser}/.dropbox
chown -R ${loggedInUser} /Users/${loggedInUser}/.dropbox
chmod 755 /Users/${loggedInUser}/.dropbox
chmod -R 755 /Users/${loggedInUser}/.dropbox

/bin/echo "`date`: Unmounting DMG..." >> ${logfile}
hdiutil detach /Volumes/Dropbox\\ Offline\\ Installer/ -force

/bin/echo "`date`: Deleting downloaded DMG..." >> ${logfile}
/bin/rm /Users/Shared/${dmgfile}

exit 0

 

 


Thanks! This script works fine on intel macs, however it installs the same intel version on Apple silicon devices as well. Have you updated the script to identify the processor and install the correct to the target?


Here is an updated script to include the Apple Silicon version

#!/bin/sh
#Written by Aaron Getz 2/10/23
#Updated to support native Apple Silicon installer 7/13/23

loggedInUser=$(stat -f%Su /dev/console)
loggedInUID=$(id -u "$loggedInUser")

dmgfile="DropBoxInstaller.dmg"
logfile="/Library/Logs/DropboxInstallScript.log"


# is this an ARM Mac?
arch=$(/usr/bin/arch)
if [ "$arch" == "arm64" ]; then
echo "Apple Silicon Identified"
url="https://www.dropbox.com/download?full=1&plat=mac&arch=arm64"
else
echo "Intel Based Mac Identified"
url="https://www.dropbox.com/download?full=1&plat=mac"
fi


echo "`date`: Download URL: $url" >> ${logfile}

/bin/echo "`date`: Downloading latest version." >> ${logfile}
curl -L "$url" > /Users/Shared/${dmgfile}

/bin/echo "`date`: Mounting DMG..." >> ${logfile}
hdiutil attach -nobrowse /Users/Shared/${dmgfile}

sleep 5

/bin/echo "`date`: Installing App..." >> ${logfile}
cd /Volumes/Dropbox\\ Offline\\ Installer/Dropbox.app/Contents/MacOS/
./Dropbox

#Set hidden dropbox folder permissions
chown ${loggedInUser} /Users/${loggedInUser}/.dropbox
chown -R ${loggedInUser} /Users/${loggedInUser}/.dropbox
chmod 755 /Users/${loggedInUser}/.dropbox
chmod -R 755 /Users/${loggedInUser}/.dropbox

/bin/echo "`date`: Unmounting DMG..." >> ${logfile}
hdiutil detach /Volumes/Dropbox\\ Offline\\ Installer/ -force

/bin/echo "`date`: Deleting downloaded DMG..." >> ${logfile}
/bin/rm /Users/Shared/${dmgfile}

exit 0

Thanks! This script works fine on intel macs, however it installs the same intel version on Apple silicon devices as well. Have you updated the script to identify the processor and install the correct to the target?


I added an updated version. It looks to be working for me but haven't tested it extensively.


I added an updated version. It looks to be working for me but haven't tested it extensively.


Hi Agetz, Thanks for your quick turn around. It works for me. I can confirm that Apple Silicon version installed to Apple silicon devices and intel version installed to intel devices respectively. Thanks again!


Here is an updated script to include the Apple Silicon version

#!/bin/sh
#Written by Aaron Getz 2/10/23
#Updated to support native Apple Silicon installer 7/13/23

loggedInUser=$(stat -f%Su /dev/console)
loggedInUID=$(id -u "$loggedInUser")

dmgfile="DropBoxInstaller.dmg"
logfile="/Library/Logs/DropboxInstallScript.log"


# is this an ARM Mac?
arch=$(/usr/bin/arch)
if [ "$arch" == "arm64" ]; then
echo "Apple Silicon Identified"
url="https://www.dropbox.com/download?full=1&plat=mac&arch=arm64"
else
echo "Intel Based Mac Identified"
url="https://www.dropbox.com/download?full=1&plat=mac"
fi


echo "`date`: Download URL: $url" >> ${logfile}

/bin/echo "`date`: Downloading latest version." >> ${logfile}
curl -L "$url" > /Users/Shared/${dmgfile}

/bin/echo "`date`: Mounting DMG..." >> ${logfile}
hdiutil attach -nobrowse /Users/Shared/${dmgfile}

sleep 5

/bin/echo "`date`: Installing App..." >> ${logfile}
cd /Volumes/Dropbox\\ Offline\\ Installer/Dropbox.app/Contents/MacOS/
./Dropbox

#Set hidden dropbox folder permissions
chown ${loggedInUser} /Users/${loggedInUser}/.dropbox
chown -R ${loggedInUser} /Users/${loggedInUser}/.dropbox
chmod 755 /Users/${loggedInUser}/.dropbox
chmod -R 755 /Users/${loggedInUser}/.dropbox

/bin/echo "`date`: Unmounting DMG..." >> ${logfile}
hdiutil detach /Volumes/Dropbox\\ Offline\\ Installer/ -force

/bin/echo "`date`: Deleting downloaded DMG..." >> ${logfile}
/bin/rm /Users/Shared/${dmgfile}

exit 0

This one prompts me for admin credentials post installing and launching :(


This one prompts me for admin credentials post installing and launching :(


Hi @mline , please use Installomator script instead. It works and supports a lot of other applications also. 
GitHub - Installomator/Installomator: Installation script to deploy standard software on Macs


Reply