-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcoreapp-chrome-install-or-update
78 lines (61 loc) · 2.5 KB
/
coreapp-chrome-install-or-update
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
###################################################################
#
# This script will check whether the currently installed version
# of Chrome matches that available from Google's servers. If
# the versions differ, it will download the latest version and
# install it.
#
#
# Date: "Tue 8 Jan 2019 14:33:03 GMT"
# Version: 0.0.2
# Origin: https://github.com/UoE-macOS/jss.git
# Released by JSS User: smooney
#
##################################################################
# Get current stable build version number of Chrome from the web, do this in a single line to keep it encapsulated
chrome_latest_stable="$(curl https://omahaproxy.appspot.com/all | grep "mac,stable" | sed "s/,/ /g" | awk '{print $3}')"
# Get version number on currently installed Chrome app
installed_version="$(/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version | grep -iE "[0-9.]{10,20}" | tr -d " <>-:;/,&\"=#[a-z][A-Z]")"
DOWNLOAD_URL="https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg"
install_Chrome() {
# Create a temporary directory in which to mount the .dmg
tmp_mount=`/usr/bin/mktemp -d /tmp/chrome.XXXX`
# Attach the install DMG directly from Google's servers (ensuring HTTPS)
hdiutil attach "$( eval echo "${DOWNLOAD_URL}" )" -nobrowse -quiet -mountpoint "${tmp_mount}"
rm -fR "/Applications/Google Chrome.app"
ditto "${tmp_mount}/Google Chrome.app" "/Applications/Google Chrome.app"
# Let things settle down
sleep 1
# Detach the dmg and remove the temporary mountpoint
hdiutil detach "${tmp_mount}" && /bin/rm -rf "${tmp_mount}"
if [ -e "/Applications/Google Chrome.app" ]; then
echo "******Latest version of Chrome is installed on target Mac.******"
fi
}
check_Running ()
{
# To find if the app is running, use:
ps -A | grep "Google Chrome.app" | grep -v "grep" > /tmp/RunningApps.txt
if grep -q "Google Chrome.app" /tmp/RunningApps.txt;
then
echo "******Application is currently running on target Mac. Installation of Chrome cannot proceed.******"
exit 1;
else
echo "******Application is not running on target Mac. Proceeding...******"
install_Chrome
exit 0
fi
}
# If the version installed differs at all from the available version
# then we want to update
case "${installed_version}" in
"${chrome_latest_stable}")
echo "****** Chrome version checked OK (${latest_stable}) ******"
;;
*)
echo "****** Chrome version differs - installed: ${installed_version}, available: ${latest_stable} ******"
check_Running
;;
esac
exit 0;