Last active
November 6, 2024 00:54
-
-
Save talkingmoose/5336e69480d87014a4c2ea1d6ec0ea4e to your computer and use it in GitHub Desktop.
Downloads and installs the latest available Zoom Client for Mac software directly on the client. This avoids having to manually download and store an up-to-date installer on a distribution server. Includes an optional checksum for added security.
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/zsh | |
:<<'ABOUT_THIS_SCRIPT' | |
----------------------------------------------------------------------- | |
Written by:William Smith | |
Professional Services Engineer | |
Jamf | |
bill@talkingmoose.net | |
https://gist.github.com/talkingmoose/5336e69480d87014a4c2ea1d6ec0ea4e | |
Originally posted: March 21, 2020 | |
Purpose: Downloads and installs the latest available Zoome Client | |
for Mac directly on the client. This avoids having to manually | |
download and store an up-to-date installer on a distribution server | |
every month. | |
Instructions: Optionally update the sha256Checksum value with a | |
known SHA 256 string. Run the script with elevated privileges. | |
If using Jamf Pro, consider replacing the sha256Checksum value | |
with "$4", entering the checksum as script parameter in a policy. | |
Except where otherwise noted, this work is licensed under | |
http://creativecommons.org/licenses/by/4.0/ | |
"Do not obey in advance." | |
----------------------------------------------------------------------- | |
ABOUT_THIS_SCRIPT | |
# enter the SHA 256 checksum for the download file | |
# download the package and run '/usr/bin/shasum -a 256 /path/to/file.pkg' | |
# this will change with each version | |
# leave blank to to skip the checksum verification (less secure) or if using a $4 script parameter with Jamf Pro | |
sha256Checksum="" # e.g. "67b1e8e036c575782b1c9188dd48fa94d9eabcb81947c8632fd4acac7b01644b" | |
if [ "$4" != "" ] && [ "$sha256Checksum" = "" ] | |
then | |
sha256Checksum=$4 | |
fi | |
# temporary file name for downloaded package | |
pkgFile="Zoom.us.pkg" | |
# process name of running app (check first to avoid installing while running) | |
appProcess="zoom.us" | |
# this is the full download URL to the latest version of the product | |
# https://support.zoom.us/hc/en-us/articles/115001799006-Mass-Deployment-with-Preconfigured-Settings-for-Mac | |
url="https://zoom.us/client/latest/ZoomInstallerIT.pkg" | |
# check for running process first | |
echo "Checking for process '$appProcess'" | |
if [[ $( /usr/bin/pgrep "$appProcess" ) = "" ]]; then | |
echo "Verified '$appProcess' process is not running" | |
else | |
echo "Application is running. Aborting installation." | |
exit 1 | |
fi | |
# create temporary working directory | |
echo "Creating working directory '$tempDirectory'" | |
workDirectory=$( /usr/bin/basename $0 ) | |
tempDirectory=$( /usr/bin/mktemp -d "/private/tmp/$workDirectory.XXXXXX" ) | |
# change directory to temporary working directory | |
echo "Changing directory to working directory '$tempDirectory'" | |
cd "$tempDirectory" | |
# download the installer package | |
echo "Downloading package $pkgFile" | |
/usr/bin/curl "$url" \ | |
--location \ | |
--silent \ | |
--output "$pkgFile" | |
# checksum the download | |
downloadChecksum=$( /usr/bin/shasum -a 256 "$tempDirectory/$pkgFile" | /usr/bin/awk '{ print $1 }' ) | |
echo "Checksum for downloaded package: $downloadChecksum" | |
# install the package if checksum validates | |
if [ "$sha256Checksum" = "$downloadChecksum" ] || [ "$sha256Checksum" = "" ]; then | |
echo "Checksum verified. Installing package $pkgFile" | |
/usr/sbin/installer -pkg "$pkgFile" -target / | |
exitCode=0 | |
else | |
echo "Checksum failed. Recalculate the SHA 256 checksum and try again. Or download may not be valid." | |
exitCode=1 | |
fi | |
# remove the temporary working directory when done | |
/bin/rm -Rf "$tempDirectory" | |
echo "Deleting working directory '$tempDirectory' and its contents" | |
exit $exitCode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment