Newest (2.2021) Google Drive installer Script?

dtrockman
New Contributor III

Hi,
Google Drive File Stream has become Google Drive and all the scripts out there for installing are now defunct. Does anyone want to take a crack at updating the Script out there? I'd love one that works!
aaf5105531b5422d8e2aac218860b5bf

DL location is now https://dl.google.com/drive-file-stream/GoogleDrive.dmg
and the DMG opens to create GoogleDrive.pkg

Note, this still does not run on M1 processor.

1 ACCEPTED SOLUTION

Geissbuhler
Contributor

Not sure if this helps anyone but I found a script and changed a couple of items (if anyone knows who made the original let me know so I can give credit):

I changed the hdiutil mount command to be hdiutil attach with the -nobrowse flag to not mount the google drive.dmg visually to the end user. I also added a bless command for good measure.

 

 

#!/bin/zsh

# make temp folder for downloads
mkdir "/tmp/googledrive"

# change working directory
cd "/tmp/googledrive"

#download Google Drive File Stream
curl -L -o "/tmp/googledrive/GoogleDrive.dmg" "https://dl.google.com/drive-file-stream/GoogleDrive.dmg"

# Mount the DMG
hdiutil attach GoogleDrive.dmg -nobrowse

# Get Volume Name
Volume=$(diskutil info / | grep "Volume Name:" | awk '{print $3,$4,$5,$6}')

# Install Google Drive
sudo installer -pkg /Volumes/Install\ Google\ Drive/GoogleDrive.pkg -target /

#Tidy Up
hdiutil unmount "/Volumes/Install Google Drive"
sleep 5
sudo rm -rf "/tmp/googledrive"
sleep 5

#Bless Google Drive app
xattr -rc "/Applications/Google Drive.app"

 

View solution in original post

19 REPLIES 19

dtrockman
New Contributor III

I took a crack at it and it seems to work just fine. I've commented out the parts that were there to delete the old version of Google Drive Backup and Sync.

#!/bin/sh

# Set some Variables
SupportContactInfo="your system administrator."
dmgfile="GoogleDrive.dmg"
logfile="/Library/Logs/GoogleDriveInstallScript.log"
url="https://dl.google.com/drive-file-stream/GoogleDrive.dmg"
user=`ls -l /dev/console | cut -d " " -f 4`

# Say what we are doing
/bin/echo "`date`: Installing latest version of File Stream for $user..." >> ${logfile}

# Download All the Things
/bin/echo "`date`: Downloading the latest version of File Stream from Google's servers" >> ${logfile}
/usr/bin/curl -k -o /tmp/$ dmgfile $url
/bin/echo "`date`: Mounting dmg file." >> ${logfile}
/usr/bin/hdiutil attach /tmp/$dmgfile -nobrowse -quiet

# Install the things. 
/bin/echo "`date`: Installing pkg" >> ${logfile}
/usr/sbin/installer -pkg /Volumes/Install Google Drive/GoogleDrive.pkg -target /

# Look for Google Drive
#if [ -d /Applications/Google Drive.app/ ]; then
#  /bin/echo "`date`: Found depricated version of Google Drive. Stopping Drive service." >> ${logfile}
#  /usr/bin/osascript -e 'tell application "Google Drive" to quit'
#  /bin/echo "`date`: Deleting Google Drive Application." >> ${logfile}
#  rm -Rf /Applications/Google Drive.app/
#  /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper  -title "Google Drive Version Found" -windowType hud -description "Google Drive Version Found" -description "While installing Google Drive File Stream we found an older version of Google Drive. Since they are not compatible, we removed the older version. However, you still have data stored in your home folder under Google Drive. These files will no longer be synced, so you should either move them or delete them. If you have any addional questions please reach out to ${SupportContactInfo}." &
#fi

# Cleanup Tasks
/bin/echo "`date`: Unmounting installer disk image." >> ${logfile}
/usr/bin/hdiutil detach $(/bin/df | /usr/bin/grep "Install Google Drive" | awk '{print $1}') -quiet
/bin/echo "`date`: Deleting temp files." >> ${logfile}
rm -fv /tmp/$dmgfile
/bin/sleep 3
/bin/echo "`date`: Launching Google Drive" >> ${logfile}
open -a /Applications/Google Drive.app/
/bin/echo "`date`: Finished." >> ${logfile}

exit 0

Philein
New Contributor III

@dtrockman this is my result using your script. What's wrong?
ef6ff4d49d97490cb8e558e8a1018303

dtrockman
New Contributor III

Mine was just full of fun incorrect things. There is a new version today by Geissbuhler to try.

 

 

dtrockman
New Contributor III

@Philein I am not having luck with it either. Dunno what the steps are to say it is not working (on this site) and that it needs help. I think the machine I tested on had a copy sitting on it from testing and then it looked like it was working. I have been manually installing the last few months and lost track of this task. I'll ask around and see who can help.

Chris_Hafner
Valued Contributor II

Check this thread https://www.jamf.com/jamf-nation/discussions/34565/install-google-drive-file-stream-system-extension-blocked

mpoteet
New Contributor II

I am having the same issues. I have tried many scripts out there to see if I could get it to work. I was able to modify one and have success. Hopefully it works for you to.

Notes: Modified
URL to the new one - https://dl.google.com/drive-file-stream/GoogleDrive.dmg
Changed all the Back up and Sync references to Google Drive
Changed the installer to a package installer since its a pkg in the dmg itself.

#!/bin/bash
################################################################################
#
#  NAME:
#    Install-Google-Drive.sh
#
#  SYNOPSIS:
#    sudo .Install-Google-Drive.sh
#
#  DESCRIPTION:
#    Downloads the latest version of Google Drive and installs 
#    it. This scrip also checks to see if Google Drive is installed. If so, the
#    script launches a window that notifies the user that the program is being
#    removed, but any data that is there will remain in place and encourages the
#    user to move the data, or delete it. There is a variable to set with your
#    support information. This script also creates a default settings file that
#    adds the Desktop, Documents, Music, Movies, Pictures, and Public folders as
#    defaults for Google Drive. You can easily edit the varibale section 
#    "settingsContent" to alter any requested changes to those default settings.
#    Take note that this script does not change the default for all users, but
#    only the user that is currently logged in. Nor will this change the sync
#    settings of a user that is already signed in. There is a section that can
#    be uncommented to display a message if depricated versions of Google Drive
#    are found. 
#
#  REQUIREMENTS
#    Intel based Apple computers running macOS ver 10.9 or later. 
#
#  LICENSE
#    Distributed Under the MIT License.
#
#  ADDITIONAL LINKS
#    https://github.com/azusapacificuniversity/scripts
#
################################################################################
#
#  HISTORY:
#    Version 1.0
#      Brian Monroe 19.10.2017
#
################################################################################


# Set some variables
SupportContactInfo="your System Administrator"
url="https://dl.google.com/drive-file-stream/GoogleDrive.dmg"
dmgfile="GoogleDrive.dmg"
volname="Install Google Drive"
user=`ls -l /dev/console | awk '{print $3}'`
logfile="/Library/Logs/GoogleDrive.log"
settingsFile="/Users/${user}/Library/Application Support/Google/Drive/user_default/user_setup.config"

settingsContent="[Computers]
desktop_enabled: True
documents_enabled: True
pictures_enabled: True
folders: /Users/${user}/Music, /Users/${user}/Movies, /Users/${user}/Public
high_quality_enabled: False
always_show_in_photos: False
usb_sync_enabled: False
[MyDrive]
folder: path/to/google_drive
my_drive_enabled: False
[Settings]
autolaunch: True
[Network]
download_bandwidth: 150
upload_bandwidth: 200
use_direct_connection: False"

# Say What We're Doing
/bin/echo "`date`: Installing latest version of Google Drive for $user..." >> ${logfile}

# Create default install settings for Google Drive. 
/bin/echo "`date`: Verify settings path exists." >> ${logfile}
mkdir -p "$(dirname "$settingsFile")"
/bin/echo "`date`: Creating or clearing the config file." >> ${logfile}
> ${settingsFile}
/bin/echo "`date`: Writing settings." >> ${logfile}
/usr/bin/printf  "${settingsContent}" >> ${settingsFile}

# Own that stuff so the user can read it. 
/bin/echo "`date`: Checking ownership." >> ${logfile}
chown -Rf $user /Users/$user/Library/Application Support/Google

# Check for Deprecated versions of Drive
if [ -d /Applications/Google Drive.app/ ]; then
  /bin/echo "`date`: Found depricated version of Google Drive. Stopping Drive service." >> ${logfile}
  /usr/bin/osascript -e 'tell application "Google Drive" to quit'
  /bin/echo "`date`: Deleting Google Drive Application." >> ${logfile}
  rm -Rf /Applications/Google Drive.app/

  # This next section should be uncommented if you are using JAMF and have jamfHelper available
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper  -title "Google Drive Version Found" -windowType hud -description "Google Drive Version Found" -description "While installing Google Drive we found an older version of Google Drive. Since they are not compatible, we removed the older version. However, you still have data stored in your home folder under Google Drive. These files will no longer be synced, so you should either move them or delete them. If you have any addional questions please reach out to ${SupportContactInfo}." &
fi

# Download All The Things!
/bin/echo "`date`: Downloading Google Drive image." >> ${logfile}
/usr/bin/curl -k -o /tmp/$dmgfile $url
/bin/echo "`date`: Mounting disk image." >> ${logfile}
/usr/bin/hdiutil attach /tmp/$dmgfile -nobrowse -quiet

# Install the Application
if [ -d /Applications/Google Drive.app/ ]; then
  /bin/echo "`date`: Found App already installed: Shutting down service." >> ${logfile}
  /usr/bin/osascript -e 'tell application "Google Drive" to quit'
fi
/bin/echo "`date`: Installing..." >> ${logfile}
installer -pkg "/Volumes/${volname}/GoogleDrive.pkg" -target /
/bin/sleep 3

# Cleanup Tasks
/bin/echo "`date`: Unmounting installer disk image." >> ${logfile}
/usr/bin/hdiutil detach $(/bin/df | /usr/bin/grep "${volname}" | awk '{print $1}') -quiet
/bin/echo "`date`: Removing the installer disk image." >> ${logfile}
rm -fv /tmp/$dmgfile
/bin/sleep 3
/bin/echo "`date`: Launching app." >> ${logfile}
open -a /Applications/Google Drive.app/
/bin/echo "`date`: Finished." >> ${logfile}

exit 0

dvasquez
Valued Contributor

This seemed to work on my Ventura macOS laptop as well. 

I received a few errors at the end. 

mostly related to not finding the app file and then some directory missing but I think that is expected. 

Then it took some time for the Drive app to start.  It also picked up previous settings. 

I will try another test laptop and put it inside Jamf Pro. 

I ran it manually to look at the output, first. 

Screenshot 2022-09-12 at 11.42.04 AM.png

Screenshot 2022-09-12 at 11.42.13 AM.png

Screenshot 2022-09-12 at 11.42.29 AM.png

Thanks for sharing this for sure!

user-EMxOpSEmyy
New Contributor II

@mpoteet script worked for me! ty

TomDay
Release Candidate Programs Tester

Reading through the deployment documentation, it looks like the settings file has changed from using the setup file? This has significantly changed how we deploy as in our config file we were deploying with the app we were able to select and add a few folders, I don't see that anywhere now? Have you updated your script to reflect this config setup change?

Geissbuhler
Contributor

Not sure if this helps anyone but I found a script and changed a couple of items (if anyone knows who made the original let me know so I can give credit):

I changed the hdiutil mount command to be hdiutil attach with the -nobrowse flag to not mount the google drive.dmg visually to the end user. I also added a bless command for good measure.

 

 

#!/bin/zsh

# make temp folder for downloads
mkdir "/tmp/googledrive"

# change working directory
cd "/tmp/googledrive"

#download Google Drive File Stream
curl -L -o "/tmp/googledrive/GoogleDrive.dmg" "https://dl.google.com/drive-file-stream/GoogleDrive.dmg"

# Mount the DMG
hdiutil attach GoogleDrive.dmg -nobrowse

# Get Volume Name
Volume=$(diskutil info / | grep "Volume Name:" | awk '{print $3,$4,$5,$6}')

# Install Google Drive
sudo installer -pkg /Volumes/Install\ Google\ Drive/GoogleDrive.pkg -target /

#Tidy Up
hdiutil unmount "/Volumes/Install Google Drive"
sleep 5
sudo rm -rf "/tmp/googledrive"
sleep 5

#Bless Google Drive app
xattr -rc "/Applications/Google Drive.app"

 

GPS-IT
New Contributor II

Does not seem to mount the Drive shortcut to the desktop. 

GPS-IT
New Contributor II

after installation and login that is.. The installer does not remain which was the issue we were having with previous scripts. But now once logged in the shortcut doesn't mount to the desktop. 

Screen Shot 2021-10-27 at 1.02.24 PM.png

I noticed the same a version or so back that they seemed to remove that from the installer. (unless I am missing something)

I had luck locally with running 

alias /Volumes/GoogleDrive ~/Desktop
however it does not seem to keep the google icon just a standard volume icon.

Seems when they added preferences (which contains a link to the folder) they removed that from the install. Used to happen automatically. I do still see a shortcut in the finder sidebar however

Tried installing manually an I also did not get the icon to show, maybe needs to be the .pkg installer, I can check that out next

CasperSally
Valued Contributor II

This is working on Big Sur for me as follows. No PPPC allow lists required as far as I can tell.

Installer script (our users run via self service) works for both intel and M1.

 

#!/bin/zsh

# Make temp folder for downloads
mkdir "/tmp/googledrive"
cd "/tmp/googledrive"

# Download Google Drive
curl -L -o "/tmp/googledrive/GoogleDriveFileStream.dmg" "https://dl.google.com/drive-file-stream/GoogleDriveFileStream.dmg"

# Mount and install GoogleDriveFileStream.dmg
hdiutil mount GoogleDriveFileStream.dmg
installer -pkg "/Volumes/Install Google Drive/GoogleDrive.pkg" -target "/Volumes/Macintosh HD"

# Tidy up
hdiutil unmount "/Volumes/Install Google Drive"
sudo rm -rf "/tmp/googledrive"

 

 

M1 macs need system extension allow listed via config profile.

Team ID EQHXZ8M8AV
com.google.drivefs.filesystems.dfsuse

 

Intel macs still use a kernel extension on Big Sur. I entered team ID etc below, I also had to check the box "Allow standard users to approve legacy kernel extensions (macOS 11 or later)" because if I didn't, the users were prompted that the "system" (it's not system) extension was updated and needed approval again. I had no luck with using jamf's "MDM Restart with Kernel Cache Rebuild" in my install policy to try to avoid users having to manually allow the kext (I think it wasn't loaded when users launch drive, I dunno).


Team ID EQHXZ8M8AV
com.google.drivefs.filesystems.dfsuse

 

You can also use config profile custom plist area to manage settings such as sign in limitations, etc. I pushed this custom plist with our system extension/kernel extension profiles. More info here
com.google.drivefs.settings.plist

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AllowedAccountsPattern</key>
<string>@example.com</string>
<key>DisableMeetOutlookPlugin</key>
<true/>
</dict>
</plist>

 

It's a travesty Apple doesn't fix GUI that it's using a kernel extension and not system extension in Big Sur... and that Google didn't back port the system extension clean install to Intel.

Thanks @TomDay @nstrauss and @McLeanSchool for info I borrowed from.

I think you may like the results of changing 1 line in your script to the following:

 

# Mount and install GoogleDriveFileStream.dmg
hdiutil attach GoogleDriveFileStream.dmg -nobrowse
installer -pkg "/Volumes/Install Google Drive/GoogleDrive.pkg" -target "/Volumes/Macintosh HD"

 

Is there a way to make sure that it is not dependent on the specific HD
name?--




*Dan Trockman*

730 Second Avenue South, Suite 1233
Minneapolis, MN 55402
*C* 612-709-2030
*E* dant@gardner-builders.com
*W* gardner-builders.com






* CLICK TO MEET THE SERVICE TEAM*

Yes:

installer -pkg "/Volumes/Install Google Drive/GoogleDrive.pkg" -target /

GPS-IT
New Contributor II

This is where we are at. Install Script works fine and does not leave installer on Desktop. M1 only requires that user signs in and is otherwise 0 interaction. We have the PPPC to bypass the "Allow Network Volume Access" when Drive mounts as a virtual network drive. On Intel, end user still needs to go into system preferences and hit allow, though standard users can do so, not really the zero touch we like to see. 

Screen Shot 2021-11-01 at 1.25.08 PM.png

Screen Shot 2021-11-01 at 1.25.51 PM.png

Screen Shot 2021-11-01 at 1.25.46 PM.png

Also, seeing an issue where the "allow" button doesn't show at all and the user is stuck in a disconnect now loop but I have been seeing this elsewhere and think its an apple/google issue.