Skip to content

Instantly share code, notes, and snippets.

@tempusthales
Created June 25, 2018 16:34
Show Gist options
  • Save tempusthales/681c9d8a1b9c45495b3bf51ad0ac850a to your computer and use it in GitHub Desktop.
Save tempusthales/681c9d8a1b9c45495b3bf51ad0ac850a to your computer and use it in GitHub Desktop.
Google Chrome for mass deployment with Yo notifications
#!/bin/bash
# Notify user if older version is running
USERNAME=`ps -ajxww | grep -v grep | grep loginwindow | awk '{print $1}'`
USERID="$(id -u $USERNAME)"
CHROMEPKG=GoogleChrome-67.0.3396.87.pkg
# Check for running Google Chrome
if [[ ! "$(pgrep -l Google Chrome | awk '{print$2}')" = "" ]]; then
launchctl asuser ${USERID} /Applications/Utilities/yo.app/Contents/MacOS/yo -t "Google Chrome Update" -s "Restarting Google Chrome" -n "Updating Chrome to version 67-87."
launchctl asuser ${USERID} sudo -u ${USERNAME} osascript -e 'quit app "Google Chrome"'
/usr/sbin/installer -pkg "/usr/local/etc/packages/chrome/$CHROMEPKG" -target /
launchctl asuser ${USERID} sudo -u ${USERNAME} open -a "/Applications/Google Chrome.app"
else
/usr/sbin/installer -pkg "/usr/local/etc/packages/chrome/$CHROMEPKG" -target /
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment