-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcoreapp-firefox-esr-install-or-update.sh
82 lines (65 loc) · 2.67 KB
/
coreapp-firefox-esr-install-or-update.sh
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
78
79
80
81
#!/bin/sh
###################################################################
#
# This script will check whether the currently installed version
# of Firefox ESR matches that available from Mozilla's servers. If
# the versions differ, it will download the latest version and
# install it.
#
#
# Date: "Fri 9 Nov 2018 15:59:35 GMT"
# Version: 0.1.3
# Origin: https://github.com/UoE-macOS/jss.git
# Released by JSS User: ganders1
#
##################################################################
# We may want to version lock Firefox ESR or can let it upgrade from vendor derived info.
if [ -z "$4" ]; then
#available_version="$(curl https://www.mozilla.org/en-US/firefox/organizations/all/ | grep "data-esr-versions=" | awk -F '"' '{print $10}')"
available_version="$(curl https://www.mozilla.org/en-US/firefox/organizations/all/ | grep "data-esr-versions=" | awk -F 'data-esr-versions="' '{print $2}' | cut -d'"' -f1)"
else
available_version="$4"
fi
DOWNLOAD_URL="http://download-origin.cdn.mozilla.net/pub/firefox/releases/${available_version}esr/mac/en-GB/Firefox ${available_version}esr.dmg"
installed_version="$(defaults read /Applications/Firefox.app/Contents/info CFBundleShortVersionString)"
install_Firefox() {
# Create a temporary directory in which to mount the .dmg
tmp_mount=`/usr/bin/mktemp -d /tmp/firefox.XXXX`
# Attach the install DMG directly from Mozilla's servers (ensuring HTTPS)
hdiutil attach "$( eval echo "${DOWNLOAD_URL}" )" -nobrowse -quiet -mountpoint "${tmp_mount}"
rm -dfR "/Applications/Firefox.app"
ditto "${tmp_mount}/Firefox.app" "/Applications/Firefox.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/Firefox.app" ]; then
echo "******Latest version of Firefox ESR is installed on target Mac.******"
fi
}
check_Running ()
{
# To find if the app is running, use:
ps -A | grep "Firefox.app" | grep -v "grep" > /tmp/RunningApps.txt
if grep -q "Firefox.app" /tmp/RunningApps.txt;
then
echo "******Application is currently running on target Mac. Installation of Firefox ESR cannot proceed.******"
exit 1;
else
echo "******Application is not running on target Mac. Proceeding...******"
install_Firefox
exit 0
fi
}
# If the version installed differs at all from the available version
# then we want to update
case "${installed_version}" in
"${available_version}")
echo "****** Firefox version checked OK (${available_version}) ******"
;;
*)
echo "****** Firefox version differs - installed: ${installed_version}, available: ${available_version} ******"
check_Running
;;
esac
exit 0;