SCRIPT | Install-Google-Drive-Latest

Install Google Drive

Summary

This script will install the latest version of the Google Drive desktop application.


Script Content

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

# Update variables. These shouldn't need to change for each update
dmgname="googledrive.dmg"
dmglink="https://dl.google.com/drive-file-stream/googledrive.dmg"
dmgmountedname="Install Google Drive"
pkgname="GoogleDrive.pkg"
apptoreplace="Google Drive.app"
apptoreplacerunningname="Google Drive"

# Download DMG
curl -L -O "$dmglink"

# Mount DMG 
hdiutil mount -nobrowse $dmgname

# Kill the app if it is running
killall -Kill "$apptoreplacerunningname"

# Remove the app from the Applications Folder
rm -rf "/Applications/$apptoreplace"

# Install the new version by running the .pkg file
installer -pkg "/Volumes/$dmgmountedname/$pkgname" -target /

sudo xattr -rc "/Applications/$apptoreplace/"

# Set the user as the current logged in user
netname=`ls -l /dev/console | cut -d " " -f 4`

# User-enabled browser authentication for Google Drive
sudo -s -u $netname defaults write com.google.drivefs.settings ForceBrowserAuth -bool true

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

# Remove the downloaded DMG
rm $dmgname

# Clear out the used variables
unset dmgname
unset dmglink
unset dmgmountedname
unset apptoreplace
unset apptoreplacerunningname
unset accounttype
unset pkgname
exit 0

Concluding Comments

The Google Drive desktop application makes sync’ing Google Drive contents to and from your Mac easier than ever.