Skip to main content

Hi all
Being a newbie please be gentle.
I have found and used the Flash update script on this site and was wondering if there is a way of doing similar qwith Firefox - script downloads and installs the latest Firefox for compatible Macs
kind regards
john

@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.


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


@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.


@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.


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


@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.


Hi all, hi @pearlin



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



#!/bin/sh
#####################################################################################################
#
# ABOUT THIS PROGRAM
#
# NAME
# FirefoxESRInstall.sh -- Installs or updates Firefox ESR
#
# SYNOPSIS
# sudo FirefoxInstallESR.sh
#
####################################################################################################
#
# HISTORY
#
# Version: 1.0
#
# - Joe Farage, 23.03.2015
#
####################################################################################################
# Script to download and install Firefox.
# Only works on Intel systems.
#
# choose language (en-US, fr, de). Default language: en-US
lang=""
# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 1 AND, IF SO, ASSIGN TO "lang"
if [ "$4" != "" ] && [ "$lang" == "" ]; then
lang=$4
else
lang="en-US"
fi

dmgfile="FF_ESR.dmg"
logfile="/Library/Logs/FirefoxESRInstallScript.log"

# Are we running on Intel?
if [ '`/usr/bin/uname -p`'="i386" -o '`/usr/bin/uname -p`'="x86_64" ]; then
## Get OS version and adjust for use with the URL string
OSvers_URL=$( sw_vers -productVersion | sed 's/[.]/_/g' )

## Set the User Agent string for use with curl
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"

# Get the latest version of Firefox ESR available from Firefox page.
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}'`
echo "Language: $lang"
echo "Latest Version is: $latestver"

# Get the version number of the currently-installed FF, if any.
if [ -e "/Applications/Firefox.app" ]; then
currentinstalledver=`/usr/bin/defaults read /Applications/Firefox.app/Contents/Info CFBundleShortVersionString`
echo "Current installed version is: $currentinstalledver"
if [ ${latestver} = ${currentinstalledver} ]; then
echo "Firefox is current. Exiting"
exit 0
fi
else
currentinstalledver="none"
echo "Firefox is not installed"
fi

url="https://download-installer.cdn.mozilla.net/pub/firefox/releases/latest-esr/mac/${lang}/Firefox%20${latestver}esr.dmg"

echo "Latest version of the URL is: $url"
echo "`date`: Download URL: $url" >> ${logfile}

# Compare the two versions, if they are different or Firefox is not present then download and install the new version.
if [ "${currentinstalledver}" != "${latestver}" ]; then
/bin/echo "`date`: Current Firefox version: ${currentinstalledver}" >> ${logfile}
/bin/echo "`date`: Available Firefox version: ${latestver}" >> ${logfile}
/bin/echo "`date`: Downloading newer version." >> ${logfile}
/usr/bin/curl -s -o /tmp/${dmgfile} ${url}
/bin/echo "`date`: Mounting installer disk image." >> ${logfile}
/usr/bin/hdiutil attach /tmp/${dmgfile} -nobrowse -quiet
/bin/echo "`date`: Installing..." >> ${logfile}
ditto -rsrc "/Volumes/Firefox/Firefox.app" "/Applications/Firefox.app"

/bin/sleep 10
/bin/echo "`date`: Unmounting installer disk image." >> ${logfile}
/usr/bin/hdiutil detach $(/bin/df | /usr/bin/grep Firefox | awk '{print $1}') -quiet
/bin/sleep 10
/bin/echo "`date`: Deleting disk image." >> ${logfile}
/bin/rm /tmp/${dmgfile}

#double check to see if the new version got updated
newlyinstalledver=`/usr/bin/defaults read /Applications/Firefox.app/Contents/Info CFBundleShortVersionString`
if [ "${latestver}" = "${newlyinstalledver}" ]; then
/bin/echo "`date`: SUCCESS: Firefox has been updated to version ${newlyinstalledver}" >> ${logfile}
# /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -title "Firefox Installed" -description "Firefox has been updated." &
else
/bin/echo "`date`: ERROR: Firefox update unsuccessful, version remains at ${currentinstalledver}." >> ${logfile}
/bin/echo "--" >> ${logfile}
exit 1
fi

# If Firefox is up to date already, just log it and exit.
else
/bin/echo "`date`: Firefox is already up to date, running ${currentinstalledver}." >> ${logfile}
/bin/echo "--" >> ${logfile}
fi
else
/bin/echo "`date`: ERROR: This script is for Intel Macs only." >> ${logfile}
fi

exit 0

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


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.



#!/bin/sh
# updateFirefox.sh
#to determine if there's a update for Firefox and, if there is, deploy it
#
#to show script startup in maint_logfile
echo 'start updateFirefox.sh'
#

date
#

ffv=$(/Applications/Firefox.app/Contents/MacOS/firefox -v)
set -- $ffv
ffvn=$3
echo "Installed Firefox version is $ffvn"

# somehow find current version
curl -O FireFox*.dmg "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" > /scripts/firefox.txt

# parse text file to find dmg file name and version
nffvf=$(grep dmg /scripts/firefox.txt | sed 's/.*href="(.*.dmg).>.*/1/')
nffv=$(grep dmg /scripts/firefox.txt | sed 's/.*releases.(.*).mac.*/1/')

echo "Latest Firefox version is $nffv"
if [[ "$ffvn" < "$nffv" ]] ; then
echo Updating Firefox to $nffv from $ffvn
#download actual dmg file
echo Getting "$nffvf"
sudo curl -o /scripts/Firefox.dmg "$nffvf"
#mount dmg
sudo hdiutil mount "/scripts/Firefox.dmg"
if [ $? = 0 ]; then # if mount is successful
#remove previous version of firefox
sudo rm -rd /Applications/Firefox.app
#install new version
sudo cp -R /Volumes/Firefox/Firefox.app /Applications
sleep 15
#Unmount
sudo hdiutil detach /Volumes/Firefox
# sudo hdiutil unmount /Volumes/Firefox
sleep 5
fi
#remove files
sudo rm /scripts/Firefox.dmg

fi
sudo rm /scripts/firefox.txt
echo 'end updateFirefox.sh'
exit 0

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


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


changed the path to /tmp



#!/bin/sh
# updateFirefox.sh
#to determine if there's a update for Firefox and, if there is, deploy it
#
#to show script startup in maint_logfile
echo 'start updateFirefox.sh'
#

date
#

ffv=$(/Applications/Firefox.app/Contents/MacOS/firefox -v)
set -- $ffv
ffvn=$3
echo "Installed Firefox version is $ffvn"

# somehow find current version
curl -O FireFox*.dmg "https://download.mozilla.org/?product=firefox-esr-latest&os=osx&lang=en-US" > /tmp/firefox.txt

# parse text file to find dmg file name and version
nffvf=$(grep dmg /tmp/firefox.txt | sed 's/.*href="(.*.dmg).>.*/1/')
nffv=$(grep dmg /tmp/firefox.txt | sed 's/.*releases.(.*).mac.*/1/')

echo "Latest Firefox version is $nffv"
if [[ "$ffvn" < "$nffv" ]] ; then
echo Updating Firefox to $nffv from $ffvn
#download actual dmg file
echo Getting "$nffvf"
curl -o /tmp/Firefox.dmg "$nffvf"

#mount dmg
hdiutil mount -nobrowse "/tmp/Firefox.dmg"
if [ $? = 0 ]; then # if mount is successful

#remove previous version of firefox
if [ -d /Applicarions/Firefox.app ]; then
rm -rd /Applications/Firefox.app
fi

#install new version
cp -R /Volumes/Firefox/Firefox.app /Applications
sleep 15
#Unmount
hdiutil detach /Volumes/Firefox
sleep 5
fi

#remove files
rm /tmp/Firefox.dmg

fi
rm /tmp/firefox.txt
echo 'end updateFirefox.sh'
exit 0

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:



curl -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.


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



sleep 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



/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?


@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.


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


@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. :)


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.


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.


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.


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?


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,:



#!/bin/sh
# updateFirefox.sh
#to determine if there's a update for Firefox and, if there is, deploy it
#
#to show script startup in maint_logfile
echo 'start updateFirefox.sh'
#

date
#

ffv=$(/Applications/Firefox.app/Contents/MacOS/firefox -v)
set -- $ffv
ffvn=$3
echo "Installed Firefox version is $ffvn"

# somehow find current version
curl -O FireFox*.dmg "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" > /tmp/firefox.txt

# parse text file to find dmg file name and version
nffvf=$(grep dmg /tmp/firefox.txt | sed 's/.*href="(.*.dmg).>.*/1/')
nffv=$(grep dmg /tmp/firefox.txt | sed 's/.*releases.(.*).mac.*/1/')

echo "Latest Firefox version is $nffv"
if [[ "$ffvn" < "$nffv" ]] ; then
echo Updating Firefox to $nffv from $ffvn
#download actual dmg file
echo Getting "$nffvf"
curl -o /tmp/Firefox.dmg "$nffvf"

#mount dmg
hdiutil mount -nobrowse "/tmp/Firefox.dmg"
if [ $? = 0 ]; then # if mount is successful

#remove previous version of firefox
if [ -d /Applicarions/Firefox.app ]; then
rm -rd /Applications/Firefox.app
fi

#install new version
cp -R /Volumes/Firefox/Firefox.app /Applications
sleep 15
#Unmount
hdiutil detach /Volumes/Firefox
sleep 5
fi

#remove files
rm /tmp/Firefox.dmg

fi
rm /tmp/firefox.txt
echo 'end updateFirefox.sh'
exit 0


Gabe Shackney
Princeton Public Schools


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



curl -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.


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


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