Tableau Desktop - Install Script

SlipStream
Contributor

Through necessity, a need arose to enable users to be able to install Tableau Desktop on their Macs via Self Service. But with the app not currently being available in the Jamf App Catalog, a scripted process was devised to enable the installation of Tableau Desktop on a Mac, whilst ensuring the correct variant for CPU architecture (i.e arm64 on Apple Silicon or x86_64 in Intel based Macs) was deployed.

After putting time into curating the script, I felt it would be good to share this with the community for anyone else who may need to deploy this within their environment:

 

#!/bin/bash
cd "/Library/Application Support/JAMF/tmp"

# Update variables. These shouldn't need to change for each update
dmgname="TableauDesktop.dmg"
pkgname="Tableau Desktop.pkg"
apptoreplacerunningname="Tableau"

# Determine CPU architecture for download
arch=$(/usr/bin/arch)
if [ "$arch" == "arm64" ]; then
	dmglink="https://www.tableau.com/downloads/desktop/mac-arm64"
	echo "Running process to download arm64 version"
else
	dmglink="https://www.tableau.com/downloads/desktop/mac"
	echo "Running process to download x86_64 version"
fi

# Download DMG
curl -L -o $dmgname "$dmglink"

# Mount DMG
hdiutil mount -nobrowse $dmgname

# Grab the name of the mounted .dmg as it changes with each version
dmgmountedname=`ls /Volumes | grep "Tableau"`
echo "The DMG mounted is: $dmgmountedname"

# Grab the name of the currently installed Tableau version, if present, as it changes with each version.
tableauCheck=`ls "/Applications/" | grep "Tableau"`

# If Tableau Desktop is already installed, remove it prior to installing the latest version.
if [ "$tableauCheck" != "" ]; then
	echo "The currently installed Tableau application is: $apptoreplace"
	# Kill the app if it is running
	echo "Killing the app if it is running..."
	killall -Kill "$apptoreplacerunningname"
	echo "Removing /Applications/$apptoreplace prior to installing..."
	rm -rf "/Applications/$apptoreplace"
else
	echo "No existing versions of Tableau Desktop detected."
fi

# Install the PKG from the DMG
sudo installer -pkg "/Volumes/$dmgmountedname/$pkgname" -target /

# Unmount the DMG
hdiutil unmount "/Volumes/$dmgmountedname"

# Remove the downloaded DMG
rm "/Library/Application Support/JAMF/tmp/$dmgname"

# Clear out the used variables
unset arch
unset dmgname
unset dmglink
unset pkgname
unset dmgmountedname
unset tableauCheck
unset apptoreplacerunningname
exit 0

 

In addition to be able to deploy the latest version of the Tableau Desktop application, a need was identified to determine which computers also already had the application installed.
Due to the application's name being slightly different with each version released, this made creating a smart computer group using the criteria of "Application Title" a challenge to say the least. To solve the problem, a computer extension attribute was created called "Tableau Desktop" to run the following script:

 

#!/bin/bash
tableauCheck=`ls "/Applications/" | grep "Tableau"`

if [ "$tableauCheck" != "" ]; then
	echo "<result>Installed</result>"
else
	echo "<result>Not Installed</result>"
fi

unset tableauCheck

 

This extension attribute then allows a computer smart group to be used to capture any Macs with where "Tableau Desktop" is reported to have the status of "Installed", regardless of the variation on the application name.

My hope is that the above information should make life easier for anyone else also looking to deploy Tableau Desktop.

1 REPLY 1

sdagley
Esteemed Contributor II

@SlipStream If you prefer the scripted install approach over AutoPkg/AutoPkgr you should take a look at https://github.com/Installomator/Installomator . It supports scripted installs for a _large_ number of applications, including all of the Tableau apps.