Help with Self Service Installers(Google Chrome)

DavidCJ
New Contributor II

Hey everyone I could really use some help. I’m trying to add installers to self service. I’m starting simple with Google Chrome. I’m new to scripting and Jamf and slightly confused.

What I’m trying to do is this: Uninstall the current version of Chrome; download an updated version of chrome; install updated version; add it to dock.

 

I found this article that helped but having an issue moving the DMG to the applications folder.

https://community.jamf.com/t5/jamf-pro/install-latest-version-of-google-chrome-without-re-packaging/...

My uninstall script works like a charm:

 

#!/bin/bash

# This script can delete apps that are sandboxed and live in /Applications

# The first parameter is used to kill the app. It should be the app name or path

# as required by the pkill command.

applicationPath="$4"

 

if [[ -z "${applicationPath}" ]]; then

    echo "No application specified!"

    exit 1

fi

## Closing Application

echo "Closing application: ${applicationPath}"

pkill "${applicationPath}"

## Removing Application

echo "Removing application: ${applicationPath}"

rm -rf "/Applications/${applicationPath}.app"

exit 0

 

Then I have this script for the reinstall:

 

#!/bin/sh

 

####################################################################################################

#

# Google Chrome Installation Script

#

####################################################################################################

#

# DESCRIPTION

#

# Automatically download and install Google Chrome

#

####################################################################################################

#

# HISTORY

#

# Created by Caine Hörr on 2016-07-25

#

# v1.1 - 2016-10-11 - Caine Hörr

# Added -nobrowse flag to hdiutil attach /tmp/$VendorDMG command line arguments

# Shout out to Chad Brewer (cbrewer) on JAMFNation for this fix/update

# https://jamfnation.jamfsoftware.com/viewProfile.html?userID=1685

#

# v1.0 - 2016-07-25 - Caine Hörr

# Google Chrome Installation script

 

# Vendor supplied DMG file

VendorDMG="googlechrome.dmg"

 

# Download vendor supplied DMG file into /tmp/

curl https://dl.google.com/chrome/mac/stable/GGRO/$VendorDMG -o /tmp/$VendorDMG

 

# Mount vendor supplied DMG File

hdiutil attach /tmp/$VendorDMG -nobrowse

 

# Copy contents of vendor supplied DMG file to /Applications/

# Preserve all file attributes and ACLs

cp -pPR /Volumes/GoogleChrome/GoogleChrome.app /Applications/

 

# Identify the correct mount point for the vendor supplied DMG file

GoogleChromeDMG="$(hdiutil info | grep "/Volumes/GoogleChrome" | awk '{ print $1 }')"

 

# Unmount the vendor supplied DMG file

hdiutil detach $GoogleChromeDMG

 

# Remove the downloaded vendor supplied DMG file

rm -f /tmp/$VendorDMG

 

Here is the Policy I set up:

General:

Display name: “Reinstall Google Chrome”

Enabled = Checked

Execution Frequency = Ongoing
Make Available Offline = Checked

Scripts:

Points to the script in System Settings > Computer Management > Scripts

Alpha unistall google chrome = Before / Application Name = Google Chrome

Google Chrome Install Script = After

Dock Items:

Action = Remove from Dock

Action = Add to beginning from dock

Maintenance:

Update Inventory = Checked

Finally here is my problem:

[STEP 1 of 8]
Executing Policy Reinstall Google Chrome
[STEP 2 of 8]
Running script Alpha uninstall google chrome...
Script exit code: 0
Script result: Closing application: Google Chrome
Removing application: Google Chrome
[STEP 3 of 8]
[STEP 4 of 8]
[STEP 5 of 8]
Running script Google Chrome Installation Script...
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 4 102M 4 4719k 0 0 5784k 0 0:00:18 --:--:-- 0:00:18 5777k 13 102M 13 14.2M 0 0 8008k 0 0:00:13 0:00:01 0:00:12 8004k 25 102M 25 26.6M 0 0 9700k 0 0:00:10 0:00:02 0:00:08 9697k 38 102M 38 39.9M 0 0 10.4M 0 0:00:09 0:00:03 0:00:06 10.4M 52 102M 52 53.7M 0 0 11.1M 0 0:00:09 0:00:04 0:00:05 11.1M 64 102M 64 66.1M 0 0 11.3M 0 0:00:09 0:00:05 0:00:04 12.2M 78 102M 78 80.8M 0 0 11.8M 0 0:00:08 0:00:06 0:00:02 13.3M 92 102M 92 95.1M 0 0 12.1M 0 0:00:08 0:00:07 0:00:01 13.6M 100 102M 100 102M 0 0 12.0M 0 0:00:08 0:00:08 --:--:-- 13.3M /dev/disk2 Apple_partition_scheme /dev/disk2s1 Apple_partition_map /dev/disk2s2 Apple_HFS /Volumes/Google Chrome cp: /Volumes/GoogleChrome/GoogleChrome.app: No such file or directory hdiutil: detach: no device name specified Usage: hdiutil detach [options] <devname> hdiutil detach -help
[STEP 6 of 8]
[STEP 7 of 8]
Inventory will be updated when all queued actions in Self Service are complete.
[STEP 8 of 8]
Relaunching dock(s)...

I would be grateful for any advise or help. Please I'm a novice so nothing is to simple and I'm trying to learn to build more of these with other apps.  

1 ACCEPTED SOLUTION

karthikeyan_mac
Valued Contributor

@DavidCJ The scripts fails because of Google Chrome incorrect (mistype) in the below lines. It should be Google Chrome not GoogleChrome (Note the space). 

 

cp -pPR /Volumes/Google Chrome/Google Chrome.app /Applications/

# Identify the correct mount point for the vendor supplied DMG file

GoogleChromeDMG="$(hdiutil info | grep "/Volumes/Google Chrome" | awk '{ print $1 }')"

# Unmount the vendor supplied DMG file

hdiutil detach $GoogleChromeDMG

View solution in original post

9 REPLIES 9

Tribruin
Valued Contributor II

I would take a look at this utility:

https://github.com/Installomator/Installomator

This will take all the effort out of trying to write a script to install the application. 

DavidCJ
New Contributor II

Thank you for responding. I'll try this out. reading the material.

bwoods
Valued Contributor

Installomator is King!

karthikeyan_mac
Valued Contributor

@DavidCJ The scripts fails because of Google Chrome incorrect (mistype) in the below lines. It should be Google Chrome not GoogleChrome (Note the space). 

 

cp -pPR /Volumes/Google Chrome/Google Chrome.app /Applications/

# Identify the correct mount point for the vendor supplied DMG file

GoogleChromeDMG="$(hdiutil info | grep "/Volumes/Google Chrome" | awk '{ print $1 }')"

# Unmount the vendor supplied DMG file

hdiutil detach $GoogleChromeDMG

howie_isaacks
Valued Contributor II

If someone installs Chrome through Self Service, and they have a previous version of the app installed, it just gets overwritten.

The problem I saw with that on ours, is that overwriting works, but the Chrome app bundle houses all the old versions and keeps getting bigger. One user had Chrome as 5Gb, but deleting and installing fresh was 488 Mb.

Same with the User Cache in their library.

jcarr
Release Candidate Programs Tester

FWIW, Google now offers a pre-built .pkg for Chrome: 

 

https://chromeenterprise.google/browser/download/ 

howie_isaacks
Valued Contributor II

This is good. Now I won't have to build a package every time there's an update. Being the paranoid anti-Chrome guy that I am I will download the package from this site to make sure nothing I don't want is being snuck into the package that would be installed on my users' Macs.

SDeLorme
New Contributor II

This sounds like a better workflow than I have been using. I use Composer to make an updated package and push over the top. The issue I have found is that the Chrome bundle is 3-4Gb because it is housing all the older revisions, rather than the 400+ Mb, that a fresh install is.

So killing the Chrome app process is the first step, then delete the Chrome app, then install the new one. Sounds correct?  I will have to look at Installomator.