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.
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 p> -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:
Executing Policy Reinstall Google Chrome |
dSTEP 2 of 8] |
Running script Alpha uninstall google chrome... |
Script exit code: 0 |
Script result: Closing application: Google Chrome Removing application: Google Chrome |
dSTEP 3 of 8] |
dSTEP 4 of 8] |
dSTEP 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 hoptions] <devname> hdiutil detach -help |
dSTEP 6 of 8] |
dSTEP 7 of 8] |
Inventory will be updated when all queued actions in Self Service are complete. |
dSTEP 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.