Skip to main content
Question

Firefox update script


Show first post

56 replies

Forum|alt.badge.img+16
  • Honored Contributor
  • 336 replies
  • January 28, 2015

@mm2270 still no luck with Reader, but Dropbox and Cyberducky work flawlessly.

Side note, any chance you're working on a way to install multiple at once? This would be quite a time saver as a script to run when we image machines.


Forum|alt.badge.img+5
  • Contributor
  • 29 replies
  • March 23, 2015

Hi all,

Here is a shell script to install or update Firefox: here

Same for Adobe Reader: here
Or Adobe AIR: here

Hope it helps ;)
Kind regards
joe


Forum|alt.badge.img+9
  • Contributor
  • 51 replies
  • March 23, 2015

@joe.farage, I love your Adobe Air and Reader scripts, so thanks! Any chance you have the Firefox one for ESR? I've been trying to modify your script with no luck so far.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • March 23, 2015

@pearlin You can take a look at my script here which can do similar things for a variety of products, although not for Adobe Air at the moment.

I will be releasing a pretty major rewrite of this script pretty soon, that will have a bunch of new features. Its in beta testing right now with a few folks, so if you decide you'd like to use it and want to participate to help catch any issues, be sure to request that.


Forum|alt.badge.img+9
  • Contributor
  • 51 replies
  • March 23, 2015

@mm2270, thanks, I'm definitely interested in helping out!


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • March 23, 2015

@pearlin Can you send me an email at mm2270 [at] me [dot] com? I can get you the beta script to test with sometime later today along with a list of the changes made to it.


Forum|alt.badge.img+5
  • Contributor
  • 29 replies
  • March 24, 2015

Hi all, hi @pearlin

Here is the deployment script for Firefox ESR. Enjoy ;)

1#!/bin/sh
2#####################################################################################################
3#
4# ABOUT THIS PROGRAM
5#
6# NAME
7# FirefoxESRInstall.sh -- Installs or updates Firefox ESR
8#
9# SYNOPSIS
10# sudo FirefoxInstallESR.sh
11#
12####################################################################################################
13#
14# HISTORY
15#
16# Version: 1.0
17#
18# - Joe Farage, 23.03.2015
19#
20####################################################################################################
21# Script to download and install Firefox.
22# Only works on Intel systems.
23#
24# choose language (en-US, fr, de). Default language: en-US
25lang=""
26# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 1 AND, IF SO, ASSIGN TO "lang"
27if [ "$4" != "" ] && [ "$lang" == "" ]; then
28 lang=$4
29else
30 lang="en-US"
31fi
32
33dmgfile="FF_ESR.dmg"
34logfile="/Library/Logs/FirefoxESRInstallScript.log"
35
36# Are we running on Intel?
37if [ '`/usr/bin/uname -p`'="i386" -o '`/usr/bin/uname -p`'="x86_64" ]; then
38 ## Get OS version and adjust for use with the URL string
39 OSvers_URL=$( sw_vers -productVersion | sed 's/[.]/_/g' )
40
41 ## Set the User Agent string for use with curl
42 userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X ${OSvers_URL}) AppleWebKit/535.6.2 (KHTML, like Gecko) Version/5.2 Safari/535.6.2"
43
44 # Get the latest version of Firefox ESR available from Firefox page.
45 latestver=`/usr/bin/curl -s -A "$userAgent" https://download-installer.cdn.mozilla.net/pub/firefox/releases/latest-esr/mac/${lang}/ | grep 'Firefox%20.*esr.dmg' | sed 's/.*Firefox%20//' | sed 's/esr.dmg.*//' | /usr/bin/awk '{print $1}'`
46 echo "Language: $lang"
47 echo "Latest Version is: $latestver"
48
49 # Get the version number of the currently-installed FF, if any.
50 if [ -e "/Applications/Firefox.app" ]; then
51 currentinstalledver=`/usr/bin/defaults read /Applications/Firefox.app/Contents/Info CFBundleShortVersionString`
52 echo "Current installed version is: $currentinstalledver"
53 if [ ${latestver} = ${currentinstalledver} ]; then
54 echo "Firefox is current. Exiting"
55 exit 0
56 fi
57 else
58 currentinstalledver="none"
59 echo "Firefox is not installed"
60 fi
61
62 url="https://download-installer.cdn.mozilla.net/pub/firefox/releases/latest-esr/mac/${lang}/Firefox%20${latestver}esr.dmg"
63
64 echo "Latest version of the URL is: $url"
65 echo "`date`: Download URL: $url" >> ${logfile}
66
67 # Compare the two versions, if they are different or Firefox is not present then download and install the new version.
68 if [ "${currentinstalledver}" != "${latestver}" ]; then
69 /bin/echo "`date`: Current Firefox version: ${currentinstalledver}" >> ${logfile}
70 /bin/echo "`date`: Available Firefox version: ${latestver}" >> ${logfile}
71 /bin/echo "`date`: Downloading newer version." >> ${logfile}
72 /usr/bin/curl -s -o /tmp/${dmgfile} ${url}
73 /bin/echo "`date`: Mounting installer disk image." >> ${logfile}
74 /usr/bin/hdiutil attach /tmp/${dmgfile} -nobrowse -quiet
75 /bin/echo "`date`: Installing..." >> ${logfile}
76 ditto -rsrc "/Volumes/Firefox/Firefox.app" "/Applications/Firefox.app"
77
78 /bin/sleep 10
79 /bin/echo "`date`: Unmounting installer disk image." >> ${logfile}
80 /usr/bin/hdiutil detach $(/bin/df | /usr/bin/grep Firefox | awk '{print $1}') -quiet
81 /bin/sleep 10
82 /bin/echo "`date`: Deleting disk image." >> ${logfile}
83 /bin/rm /tmp/${dmgfile}
84
85 #double check to see if the new version got updated
86 newlyinstalledver=`/usr/bin/defaults read /Applications/Firefox.app/Contents/Info CFBundleShortVersionString`
87 if [ "${latestver}" = "${newlyinstalledver}" ]; then
88 /bin/echo "`date`: SUCCESS: Firefox has been updated to version ${newlyinstalledver}" >> ${logfile}
89 # /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -title "Firefox Installed" -description "Firefox has been updated." &
90 else
91 /bin/echo "`date`: ERROR: Firefox update unsuccessful, version remains at ${currentinstalledver}." >> ${logfile}
92 /bin/echo "--" >> ${logfile}
93 exit 1
94 fi
95
96 # If Firefox is up to date already, just log it and exit.
97 else
98 /bin/echo "`date`: Firefox is already up to date, running ${currentinstalledver}." >> ${logfile}
99 /bin/echo "--" >> ${logfile}
100 fi
101else
102 /bin/echo "`date`: ERROR: This script is for Intel Macs only." >> ${logfile}
103fi
104
105exit 0

Forum|alt.badge.img+7
  • Contributor
  • 43 replies
  • August 3, 2015

@joe.farage Is there an easy way to add support for multiple languages based on what language the OS is using?


Forum|alt.badge.img+1
  • New Contributor
  • 9 replies
  • December 2, 2015

the ftp site is giving a 404 error now. I had to edit a similar script that had been working until recently.
here it is.

1#!/bin/sh
2# updateFirefox.sh
3#to determine if there's a update for Firefox and, if there is, deploy it
4#
5#to show script startup in maint_logfile
6echo 'start updateFirefox.sh'
7#
8
9date
10#
11
12ffv=$(/Applications/Firefox.app/Contents/MacOS/firefox -v)
13set -- $ffv
14ffvn=$3
15echo "Installed Firefox version is $ffvn"
16
17# somehow find current version
18curl -O FireFox*.dmg "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" > /scripts/firefox.txt
19
20# parse text file to find dmg file name and version
21nffvf=$(grep dmg /scripts/firefox.txt | sed 's/.*href="(.*.dmg).>.*/1/')
22nffv=$(grep dmg /scripts/firefox.txt | sed 's/.*releases.(.*).mac.*/1/')
23
24echo "Latest Firefox version is $nffv"
25if [[ "$ffvn" < "$nffv" ]] ; then
26 echo Updating Firefox to $nffv from $ffvn
27 #download actual dmg file
28 echo Getting "$nffvf"
29 sudo curl -o /scripts/Firefox.dmg "$nffvf"
30 #mount dmg
31 sudo hdiutil mount "/scripts/Firefox.dmg"
32 if [ $? = 0 ]; then # if mount is successful
33 #remove previous version of firefox
34 sudo rm -rd /Applications/Firefox.app
35 #install new version
36 sudo cp -R /Volumes/Firefox/Firefox.app /Applications
37 sleep 15
38 #Unmount
39 sudo hdiutil detach /Volumes/Firefox
40# sudo hdiutil unmount /Volumes/Firefox
41 sleep 5
42 fi
43 #remove files
44 sudo rm /scripts/Firefox.dmg
45
46fi
47sudo rm /scripts/firefox.txt
48echo 'end updateFirefox.sh'
49exit 0

Forum|alt.badge.img+1
  • New Contributor
  • 9 replies
  • December 2, 2015

edit out the sudo commands, they are not needed when run under the policy


Forum|alt.badge.img+21
  • Honored Contributor
  • 970 replies
  • January 25, 2016

start updateFirefox.sh
Mon 25 Jan 2016 11:05:04 GMT
Installed Firefox version is 42.0
test.sh: line 18: /scripts/firefox.txt: No such file or directory
grep: /scripts/firefox.txt: No such file or directory
grep: /scripts/firefox.txt: No such file or directory
Latest Firefox version is rm: /scripts/firefox.txt: No such file or directory
end updateFirefox.sh


Forum|alt.badge.img+21
  • Honored Contributor
  • 970 replies
  • January 25, 2016

changed the path to /tmp

1#!/bin/sh
2# updateFirefox.sh
3#to determine if there's a update for Firefox and, if there is, deploy it
4#
5#to show script startup in maint_logfile
6echo 'start updateFirefox.sh'
7#
8
9date
10#
11
12ffv=$(/Applications/Firefox.app/Contents/MacOS/firefox -v)
13set -- $ffv
14ffvn=$3
15echo "Installed Firefox version is $ffvn"
16
17# somehow find current version
18curl -O FireFox*.dmg "https://download.mozilla.org/?product=firefox-esr-latest&os=osx&lang=en-US" > /tmp/firefox.txt
19
20# parse text file to find dmg file name and version
21nffvf=$(grep dmg /tmp/firefox.txt | sed 's/.*href="(.*.dmg).>.*/1/')
22nffv=$(grep dmg /tmp/firefox.txt | sed 's/.*releases.(.*).mac.*/1/')
23
24echo "Latest Firefox version is $nffv"
25if [[ "$ffvn" < "$nffv" ]] ; then
26echo Updating Firefox to $nffv from $ffvn
27#download actual dmg file
28echo Getting "$nffvf"
29curl -o /tmp/Firefox.dmg "$nffvf"
30
31#mount dmg
32hdiutil mount -nobrowse "/tmp/Firefox.dmg"
33if [ $? = 0 ]; then # if mount is successful
34
35#remove previous version of firefox
36if [ -d /Applicarions/Firefox.app ]; then
37rm -rd /Applications/Firefox.app
38fi
39
40#install new version
41cp -R /Volumes/Firefox/Firefox.app /Applications
42sleep 15
43#Unmount
44hdiutil detach /Volumes/Firefox
45sleep 5
46 fi
47
48#remove files
49rm /tmp/Firefox.dmg
50
51fi
52rm /tmp/firefox.txt
53echo 'end updateFirefox.sh'
54exit 0

Forum|alt.badge.img+9
  • Contributor
  • 57 replies
  • July 27, 2016

I don't know if this would help at all being that it's a bit of an older thread but I found this page after digging around: https://download-installer.cdn.mozilla.net/pub/firefox/releases/latest/README.txt

Firefox actually tells you how to use wget to download the file, however that only works if you have wget installed on your machine. I was able to cobble together this cURL command to download the file:

1curl -GL -o Firefox.dmg -d "product=firefox-latest&os=osx&lang=en-US" https://download.mozilla.org/

I figured this would help is you're not using the ESR version and simply using the public version.


AVmcclint
Forum|alt.badge.img+21
  • Esteemed Contributor
  • 1043 replies
  • July 28, 2016

I took the script and wrapped it up in a Platypus app so users can see the output/progress. I also added a

1sleep 10

at the end to give users a chance to see the final status before it automatically closed. I then pushed the app to /Applications/Utilities/ and built a Policy to run

1/Applications/Utilities/Firefox_Updater.app/Contents/MacOS/Firefox Update

since it needs elevated rights to install the updates. Seems to work like a champ. I'm trying to find a downside to this though. Is there really?


Forum|alt.badge.img+9
  • Contributor
  • 57 replies
  • July 28, 2016

@AVmcclint The only downside I could see is that if your company removes admin rights to their users then you'd have to temporarily elevate their permissions while the scripts run so that they can perform the update. I'm only thinking about that probably bc my company is looking to do that to a select group of users. Other than that, I can't think of a downside.


AVmcclint
Forum|alt.badge.img+21
  • Esteemed Contributor
  • 1043 replies
  • July 28, 2016

My users don't have admin rights. That's why I'm launching the app from a Policy so it runs as root.


Forum|alt.badge.img+9
  • Contributor
  • 57 replies
  • July 28, 2016

@AVmcclint Duh. I should've thought of that. Ha. I was in the same mind set that Google runs their updater. You have to run it as the local user as it will bomb out complaining that it's being run by root. If FF lets the root user run the updater that's awesome! Then I retract my previous statement...I see no downside to this. :)


AVmcclint
Forum|alt.badge.img+21
  • Esteemed Contributor
  • 1043 replies
  • July 28, 2016

From what I can tell about this script is that it is completely independent of the Firefox application. One line in the script deletes the pre-existing copy of Firefox from /Applications. I added a line for pkill firefox before the bulk of the script runs too to make sure there isn't any running processes that could object to being replaced.


Forum|alt.badge.img+5
  • Contributor
  • 53 replies
  • November 11, 2016

So where is everyone with this? I had a FF ESR update script working last Spring, based on mm2270's wonderful work, but it quit working (I assume the problem with the FTP site?). All I want is something simple to put in Self Service for my users (non-admins) to be able to run on demand to update FF. Anyone have a working script for that with 10.11.6? I have had really bad luck with AutoPKG, so please stick with script-based solutions.


AVmcclint
Forum|alt.badge.img+21
  • Esteemed Contributor
  • 1043 replies
  • November 11, 2016

I'm using the script above with the modifications I noted. I did have to recently modify the script and redeploy it as a Self Service Policy so that it could get through our new web proxy. I'm not getting the ESR release, I'm only getting the regular public release you can download yourself from getfirefox.com. It seems to work well.


rstasel
Forum|alt.badge.img+13
  • Valued Contributor
  • 338 replies
  • November 29, 2016

Has anyone had trouble installing the ESR version over the top of a non-ESR version? I have a policy deploying ESR, but it doesn't want to replace the newer non-ESR version. I even set a custom trigger, and tried on my machine. Firefox wasn't open. I had version 49.0.2 installed. When the policy fired, it said it was successful, but checking the version info, it still said 49.0.2, and not 45.5.0.

Anyone seen this before?


Forum|alt.badge.img+18
  • Esteemed Contributor
  • 831 replies
  • March 10, 2017

So I've applied an edit to use the Public releases for FireFox and the script seems to work great since the end result is an updated working version, but I get a curl error. Even with the following error everything seems to work. (I just don't like seeing errors though).

curl: Remote file name has no length!
curl: try 'curl --help' or 'curl --manual' for more information

Any ideas? Below is my full script built on the shoulders of @tkimpton built on the back of @dlang etc,etc,:

1#!/bin/sh
2# updateFirefox.sh
3#to determine if there's a update for Firefox and, if there is, deploy it
4#
5#to show script startup in maint_logfile
6echo 'start updateFirefox.sh'
7#
8
9date
10#
11
12ffv=$(/Applications/Firefox.app/Contents/MacOS/firefox -v)
13set -- $ffv
14ffvn=$3
15echo "Installed Firefox version is $ffvn"
16
17# somehow find current version
18curl -O FireFox*.dmg "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" > /tmp/firefox.txt
19
20# parse text file to find dmg file name and version
21nffvf=$(grep dmg /tmp/firefox.txt | sed 's/.*href="(.*.dmg).>.*/1/')
22nffv=$(grep dmg /tmp/firefox.txt | sed 's/.*releases.(.*).mac.*/1/')
23
24echo "Latest Firefox version is $nffv"
25if [[ "$ffvn" < "$nffv" ]] ; then
26echo Updating Firefox to $nffv from $ffvn
27#download actual dmg file
28echo Getting "$nffvf"
29curl -o /tmp/Firefox.dmg "$nffvf"
30
31#mount dmg
32hdiutil mount -nobrowse "/tmp/Firefox.dmg"
33if [ $? = 0 ]; then # if mount is successful
34
35#remove previous version of firefox
36if [ -d /Applicarions/Firefox.app ]; then
37rm -rd /Applications/Firefox.app
38fi
39
40#install new version
41cp -R /Volumes/Firefox/Firefox.app /Applications
42sleep 15
43#Unmount
44hdiutil detach /Volumes/Firefox
45sleep 5
46 fi
47
48#remove files
49rm /tmp/Firefox.dmg
50
51fi
52rm /tmp/firefox.txt
53echo 'end updateFirefox.sh'
54exit 0

Gabe Shackney
Princeton Public Schools


Forum|alt.badge.img+9
  • Contributor
  • 57 replies
  • March 10, 2017

Just my two cents, but I use this as my cURL command:

1curl -GL -o Firefox.dmg -d "product=firefox-latest&os=osx&lang=en-US" https://download.mozilla.org/

I've have great luck then you don't need to worry about the version number of the current install for the sake of the cURL command, at least.


Forum|alt.badge.img+18
  • Esteemed Contributor
  • 831 replies
  • March 10, 2017

Isn't the curl command though in my script writing the version number to a file to double check vs the installed version? Thats a part I like as a reference.

Gabe Shackney
Princeton Public Schools


Forum|alt.badge.img+6
  • Contributor
  • 79 replies
  • June 6, 2017

I have an new script working.
You can download it from git hub:
firefox-esr-install.py

If you try it please let me know how it goes!

Thanks!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings