Firefox update script

itteam
New Contributor

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

56 REPLIES 56

cgiordano
Contributor

@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
Honored Contributor

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

cgiordano
Contributor

@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
Honored Contributor

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.

dmillertds
Contributor

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
Honored Contributor

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
Valued Contributor

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?

GabeShack
Valued Contributor III

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

Gabe Shackney
Princeton Public Schools

cgiordano
Contributor

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.

GabeShack
Valued Contributor III

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

Gabe Shackney
Princeton Public Schools

quedayone
Contributor

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!

bcheney
Release Candidate Programs Tester

@quedayone

First off, THANK YOU!

Trying your script on a 10.12.5 machine with no firefox installed, i'm getting this.

Script result: <br/>Starting Firefox ESR installer script Jul, 03 2017 04:12:41 PM
<br/>Downloading latest version. . . <br/>current: none<br/>latest: 52.2.1<br/>
<br/>Traceback (most recent call last):<br/> File "/Library/Application Support/JAMF/tmp/Firefox Update & Install", line 87, in <module><br/> if int(currentFirefoxVersion) >= int(latestFirefoxVersion):<br/>ValueError: invalid literal for int() with base 10: 'none'<br/>

I fixed a small part of the code, changing 'none' to 0.

# # Get currently installed version of Firefox
if isfile(plistFile):
    pl = readPlist(plistFile)
    currentFirefoxVersion=pl["CFBundleShortVersionString"]
else:
    currentFirefoxVersion="0"
#

quedayone
Contributor

@bcheney Sweet! Thank you. I have updated on my git hub.

bcheney
Release Candidate Programs Tester

@quedayone

Seeing one other issue --

My App icon is showing up as the standard pen/pencil and paper Application icon, but not the Firefox logo (on dock and in apps folder). But if I open finder, copy and paste the logo onto itself, it asks for admin rights and fixes itself. Any idea? Can something be done to alleviate the issue?

Thanks again!

Chris_Hathaway
New Contributor II

@joe.farage

I would like to start by saying thanks for the script, it is just what I needed. So after I downloaded your script to update a few laptops running an old version of Firefox jamf showed it as failed. It fails every time when I am running it out of jamf. However, if I run it manually on the laptop from terminal using sudo it works correctly. Do you by chance have any ideas as to why this may be occurring?

Thanks in advance :)

burdett
Contributor II

@tkimpton, I'v been using your script and I was wondering how I could inspect the status of the downloaded app signature.

I found that I can check the app signature with the command;
codesign --verify --verbose /Volumes/Firefox/Firefox.app

the result is;
/Volumes/Firefox/Firefox.app: valid on disk
/Volumes/Firefox/Firefox.app: satisfies its Designated Requirement

I haven't been able to figure out a way to test the result in the script and exit if it fails.

Arre
New Contributor II

@bcheney

I have the same issue with the app icon on latest High Sierra 10.13.6 using this script.
It's something tied to icon cache, tried a few things, like deleting icon cache in /private/var/folders but didn't work.

What worked was just "touching" the app:

sudo touch /Applications/Firefox.app

Someone also said that if this is not enough maybe touching the Info.plist inside the Contents folder, but for me always worked just with the .app

sudo touch /Applications/Firefox.app/Contents/Info.plist

And also, what I found out, this happens only for the user that is logged in when the script runs, and I think a log out/restart will fix it by itself.