Google Chrome script for installing either Intel or M1 (Apple Silicon) no packaging needed.

Geissbuhler
Contributor

I have created a script to check for Architecture and snag the correct installer for Chrome. This is currently working, hope this helps others.

There is a similar Topic here: https://community.jamf.com/t5/jamf-pro/install-latest-version-of-google-chrome-without-re-packaging/...

Wanted to start a new one with the focus on Intel and M1

Thanks to @cbrewer for the solution I did not need to choose between and intel and an M1 installer, I also Changed the .dmg to a .pkg with the extra bit of agreeing to the license etc, with the appended URL.

 

#!/bin/zsh
# Changed the installer from .dmg to .pkg and took out the bit for choosing an architecture.

# make temp folder for downloads

mkdir "/tmp/googlechrome"

# change working directory

cd "/tmp/googlechrome"

# Download Google Chrome
 
curl -L -o "/tmp/googlechrome/googlechrome.pkg" "https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms/googlechrome.pkg"

# Install Google Chrome

sudo /usr/sbin/installer -pkg googlechrome.pkg -target /

#Tidy Up

sudo rm -rf "/tmp/googlechrome"

#Bless Google Chrome app

xattr -rc "/Applications/Google Chrome.app"

 

In case anyone has found an installer that has separate Installers for Intel Vs. ARM You could use this as a template in the download section:

 

# Download Correct installer based on Architecture
 
arch_name="$(uname -m)"
 
if [ "${arch_name}" = "x86_64" ]; 
then 
curl -L -o "<path to temp directory>/<Package Name>" "URL to Intel Package"
elif [ "${arch_name}" = "arm64"] 
then curl -L -o "<path to temp directory>/<Package Name>" "URL to ARM Package"
fi

 

 

2 ACCEPTED SOLUTIONS

cbrewer
Valued Contributor II

Any reason you're not just using the universal copy for all Macs?

Also, Google offers a package installer which might be preferred depending on what you're trying to accomplish. I believe the package installer will install the Google Keystone updater for you, but maybe you're trying to avoid that.

 

https://support.google.com/chrome/a/answer/9915669?hl=en

 

View solution in original post

Something like this:

 

 

#!/bin/zsh

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

# change working directory
cd "/tmp/googlechrome"

# Download Google Chrome
 
curl -L -o "/tmp/googlechrome/googlechrome.pkg" "https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms/googlechrome.pkg"

# Install Google Chrome

sudo /usr/sbin/installer -pkg googlechrome.pkg -target /

#Tidy Up
sudo rm -rf "/tmp/googlechrome"

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

 

 

 

View solution in original post

35 REPLIES 35

cbrewer
Valued Contributor II

Why not just put the Universal copy on all of your Macs? Chrome offers a universal pkg installer.

 

You can also automatically accept the terms and conditions by placing the following between your download path and the package name:

accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms

 

The full URL would look like:

https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252...

 

https://support.google.com/chrome/a/answer/9915669?hl=en

cbrewer
Valued Contributor II

Any reason you're not just using the universal copy for all Macs?

Also, Google offers a package installer which might be preferred depending on what you're trying to accomplish. I believe the package installer will install the Google Keystone updater for you, but maybe you're trying to avoid that.

https://support.google.com/chrome/a/answer/9915669?hl=en

 

https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252...

cbrewer
Valued Contributor II

Any reason you're not just using the universal copy for all Macs?

Also, Google offers a package installer which might be preferred depending on what you're trying to accomplish. I believe the package installer will install the Google Keystone updater for you, but maybe you're trying to avoid that.

 

https://support.google.com/chrome/a/answer/9915669?hl=en

 

Good to know, I mean it makes sense that the Universal version is, well Universal! I think I was confused as when you go and manually download they make a really big deal about choosing an Intel Installer vs the arm64 (M1 installer).

Wondering why they would make you choose if there was not difference. Why wouldn't google just have everyone download the Universal version? Maybe google got lazy on this one, like at one time there were 2 diff packages.

 

To be fair this does what I set out to do, maybe the architecture lookup can help someone who finds an app where they actually are separate. I already have one in my env. We also have Google Chrome Manager in place so that takes care of all of the settings we need.

beareye321
New Contributor II

Hello, with the package deployed I am constantly getting the error 11 when going to "About Google Chrome".

Update failed (error: 11)

Error details:
Updates are disabled.
Version 95.0.4638.69 (Official Build) (x86_64)
 
I tried removing ~/Library/Google/GoogleSoftwareUpdate and /Library/Google/GoogleSoftwareUpdate folders and then reinstalled Google Software Update and reinstalled Chrome using the package but for some reason I always wend up with that error. 

Any ideas what might be causing this? Could you expand on what you said about "the package installer will install the Google Keystone updater for you.."? Thank you

I believe he is saying in the script if you replace all of the .dmg with .pkg the installer will come down as a .pkg instead. And change the install part from Copy the contents to run the installer. I can see if I can work on that bit.

 

 

 

Something like this:

 

 

#!/bin/zsh

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

# change working directory
cd "/tmp/googlechrome"

# Download Google Chrome
 
curl -L -o "/tmp/googlechrome/googlechrome.pkg" "https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms/googlechrome.pkg"

# Install Google Chrome

sudo /usr/sbin/installer -pkg googlechrome.pkg -target /

#Tidy Up
sudo rm -rf "/tmp/googlechrome"

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

 

 

 

NRutkowski
New Contributor

I tried using the Universal link but it wont install on M1. Installer just spins. Does anyone have the direct link to the ARM installer?

The link is in the script above, that is a universal installer which I currently have working for both intel and M1, I just tried this script before responding to make sure. As long as you run as root locally you should be all set.

 

sudo sh /path/to/script

 

or if you paste this into the scripts in Jamf and use that script in a policy.

I'm using jamf to deploy via script you posted. The self service downloads the file but spins when installing. Never completes, doesn't error. 

Can you post your logs from the policy?

There are none. It says pending. I let it run for a while and its still processing. The script successfully ran on an intel iMac. 

I have changed this script a few times, can you please copy and paste the exact script you are using back here please 🙂

#!/bin/zsh
# Changed the installer from .dmg to .pkg and took out the bit for choosing an architecture.

# make temp folder for downloads

mkdir "/tmp/googlechrome"

# change working directory

cd "/tmp/googlechrome"

# Download Google Chrome

curl -L -o "/tmp/googlechrome/googlechrome.pkg" "https://dl.google.com/chrome/mac/stable/googlechrome.pkg"

# Install Google Chrome

sudo /usr/sbin/installer -pkg googlechrome.pkg -target /

#Tidy Up

sudo rm -rf "/tmp/googlechrome"

#Bless Google Chrome app

xattr -rc "/Applications/Google Chrome.app"

I should also add that i've tried it with both the short direct link and the longer agreement link. 

This is my current Policy for self Service:

Policy with Name of Script 1Policy with Name of Script 1Name of Script 2Name of Script 2Name of Script 3Name of Script 3

Contents of Scripts

Chrome - Pregame Self Service:

 

#!/bin/bash
killall "Google Chrome"
rm -rf /Applications/Google\ Chrome.app
exit 0

 

z - Open Google Chrome:

 

#!/bin/zsh
open /Applications/Google\ Chrome.app

 

I am still using the redundant script that chooses architecture:

Download and install Google Chrome:

 

#!/bin/zsh

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

# change working directory
cd "/tmp/googlechrome"

# Download Correct Google Chrome based on Architecture
 
arch_name="$(uname -m)"
 
if [ "${arch_name}" = "x86_64" ]; 
then 
curl -L -o "/tmp/googlechrome/Googlechrome.dmg" "https://dl.google.com/chrome/mac/stable/GGRO/Googlechrome.dmg"
elif [ "${arch_name}" = "arm64" ]; 
then curl -L -o "/tmp/googlechrome/Googlechrome.dmg" "https://dl.google.com/chrome/mac/universal/stable/GGRO/Googlechrome.dmg"
fi

# Mount the DMG
hdiutil attach Googlechrome.dmg -nobrowse

# Install Google Chrome
cp -r /Volumes/Google\ Chrome/*app /Applications

#Tidy Up
hdiutil unmount "/Volumes/Google Chrome"
sleep 5
sudo rm -rf "/tmp/googlechrome"
sleep 5

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

 

Let me know if this works for you.

I see that it downloaded the file and mounted the DMG. but again same. it fails to process the installer. I am starting to think that something else may be an issue. I installed rosetta earlier, as it was required by another app.

In that case I would love to see if you could try this on a fresh machine or that same machine wiped. I have had the luck of testing Monterey for a bit now, that "erase all contents and settings" is a major help, I basically get the machine from wiped to all set up in ~ 10 min now.

I have tested this policy on both Monterey and Big sur this AM just to be sure there was nothing OS wise causing this as well.

Feel free to reach out if you need anything 🙂

I have these in place as best practices for my Org is to have the Self Service Policy do the following:

1. Stop the running process of the app.
2. Remove the current installed version.
3. Install current version
4. Launch the app.

All of these are named in specific alphabetical order so they launch in appropriate sequence.

Just to make sure, I have also had the script that only calls the universal installer working on M1 as well, just ran it. (Used the exact set of scripts as above, only swapping the Download and Install Google Chrome Script")

 

Screen Shot 2021-11-17 at 10.50.42 AM.png

 

Contents of script
Download and Install Google Chrome Universal installer only:

 

 

#!/bin/zsh
# Changed the installer from .dmg to .pkg and took out the bit for choosing an architecture.

# make temp folder for downloads

mkdir "/tmp/googlechrome"

# change working directory

cd "/tmp/googlechrome"

# Download Google Chrome
 
curl -L -o "/tmp/googlechrome/googlechrome.pkg" "https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms/googlechrome.pkg"

# Install Google Chrome

sudo /usr/sbin/installer -pkg googlechrome.pkg -target /

# Tidy Up

sudo rm -rf "/tmp/googlechrome"

# Bless Google Chrome app

xattr -rc "/Applications/Google Chrome.app"

 

 



After a wipe and reinstall.  It still doesn't run but I got an error. 

[STEP 1 of 6]
Executing Policy Install Latest Google Chrome V4
[STEP 2 of 6]
Running script Google install Script 1...
Script exit code: 0
Script result: No matching processes were found
[STEP 3 of 6]
Running script Google install Script 2...
Script exit code: 1
Script result: The file /Applications/Google Chrome.app does not exist.
Error running script: return code was 1.
[STEP 4 of 6]
Running script Google install Script 3...
Script exit code: 0
Script result: % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 10 201M 10 21.1M 0 0 22.2M 0 0:00:09 --:--:-- 0:00:09 22.1M 46 201M 46 93.8M 0 0 47.1M 0 0:00:04 0:00:01 0:00:03 47.1M 69 201M 69 140M 0 0 47.6M 0 0:00:04 0:00:02 0:00:02 47.6M 94 201M 94 189M 0 0 47.8M 0 0:00:04 0:00:03 0:00:01 47.8M 100 201M 100 201M 0 0 48.9M 0 0:00:04 0:00:04 --:--:-- 48.9M installer: Package name is Google Chrome installer: Installing at base path / installer: The install was successful.
[STEP 5 of 6]
[STEP 6 of 6]

I think I see where it errored. In the 2nd script. It failed to launch an app that doesn't exist. I did check the app installed. Thank you for your help.

Looks like they are running out of order, likely due to naming of the scripts or not having before/after set properly like in my screenshots.

We want the launch one to run last, that's why I put a "z -" in the title.

They make an Intel Only version, and the Universal version which works on Both ARM (M1) and intel. They do not make one specifically for just ARM unless I am sorely mistaken.

If you are looking for the link without the agree to it should be:

https://dl.google.com/chrome/mac/stable/googlechrome.pkg

 

kiltedtenor
New Contributor III

I'm looking to run this script and it runs fine in terminal, but does not run when deployed via Self Service. Chrome isn't our primary browser, so it's only available there and will be left up to the user to update. No part of the script, from beginning to end runs properly. It's like self service isn't even trying to run it. Any ideas on where this could be hanging up? It has been copied and pasted directly from the latest script above.

I've had this happen before, what happens when you delete the policy and try again?

Also screenshots of the elements of the policy may help us as well if after recreation it is still not working 🙂

kiltedtenor
New Contributor III

I ended up with the same result. Just a failure notification from Self Service and seemingly no activity takes place. I'm watching /tmp for the googlechrome folder to appear as my point of reference for if the script is even trying to run. I've also looked for logs, but luck there either.

Screen Shot 2021-11-22 at 11.34.16 AM.png

Screen Shot 2021-11-22 at 11.34.26 AM.png

Screen Shot 2021-11-22 at 11.34.36 AM.png

Very Strange, have you tried choosing a trigger (I know it's not needed with Self Service) or recreating it from scratch, I have had multiple policies fail on me (no indication of running) and had to recreate them for some reason, or is there anything that might prevent this from running on the machine, like another policy?

I finally broke down and hit up Jamf support. Looks like something just happened to be broken on the couple machines that I was testing on, regarding the device certificate for Jamf. I renewed it through terminal and archived the old one. That seemed to do the trick. It was weird because all of the other functions of Jamf were working through self service. App installation, etc. and the device was sending inventory and check-ins to our Jamf Pro server, but JUST scripts were broken. We're good now and the script works perfectly as written, so thank you for sharing it!

You are very welcome, glad you eventually got it up and running! 🙂

tcandela
Valued Contributor II

does anyone have a working script that will install Google Chrome web browser (universal)?

I'm using this old script but i've recently noticed on both Intel & M1 it's now not installing the most current Google Chrome version of 101.***. it's installing at version 98.*****

I'm testing that script from @Geissbuhler 

ITHoneyBadger
New Contributor III

Thanks for this script @Geissbuhler .   We ran into an issue where Chrome wouldn't autoupdate on our MacBooks.  We don't give the staff local admin so they weren't able to do the reinstall that the Macs were requiring them to do.  Set the script up in Self Service and it runs flawlessly for this.