Posted on 01-07-2015 05:54 AM
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
Posted on 01-07-2015 06:06 AM
Hallo John,
We use autopkg for this.
Posted on 01-07-2015 07:37 AM
Autopkg would make the most sense overall to use for this purpose. However, everyone's needs and/or tolerances for what should be something packaged and contained in the JSS, versus just allowing the clients to download and install the latest version, will be unique.
That said, I have a single script that can be used to update up to 8 different apps/plug-ins, including Flash Player, Oracle's Java, Silverlight, Adobe Reader, VLC, Flip4Mac (free version), Office 2011 and Firefox.
In all above cases, it doesn't require any packaging of the apps or plug-ins. It will direct the client to download and install the product directly. For this reason, if internet bandwidth usage is a concern, then this wouldn't be a good solution. If bandwidth use is not a concern, then it can be an option. My primary reason for working on it was that I was getting tired of needing to build complex Smart Groups to target the right machines with package install policies. The script checks the installed version and will know if it needs to be updated. If its not installed, in all cases except for Office since those are only updaters, it can install it new. Its just a flag you can set in the script to install new or skip if not installed.
The script also has both a silent mode and a Self Service mode, which uses cocoaDialog for dialogs, progress bars and feedback, etc.
Posted on 01-07-2015 07:47 AM
@mm2270 for us mooches ;) any chance you have a scrubbed version of that script that folks can look at?
Posted on 01-07-2015 07:49 AM
I second this request
Posted on 01-07-2015 07:50 AM
@emilykausalik - Right now I do not, but that won't be hard to do. There isn't much "scrubbing" needed for it. Only one line actually reference anything in our org and its only for the titles of the dialogs. Everything else is pretty standard. Give me a day or two and I will post it on my github page and post back here.
Posted on 01-07-2015 07:58 AM
@mm2270 you're a hero! Perhaps even a superhero.
Posted on 01-07-2015 08:00 AM
thanks Mike! much appreciated!
Posted on 01-07-2015 08:59 AM
I wish there was some sort of JAMF repository for things like this (or is there?). Thanks so much for offering to share.....super helpful and super nice to share.
Posted on 01-07-2015 10:08 AM
There is the Script section (https://jamfnation.jamfsoftware.com/scripts.html) located under the More... tab at the top of JAMF Nation, though pretty much almost everything is shared in individual githubs.
Posted on 01-09-2015 10:00 AM
I've posted the script that I mentioned above to my github page now. The information can be found here:
https://github.com/mm2270/CasperSuiteScripts
Its the first script mentioned in the ReadMe, "Update_Core_Apps.sh" which you can get to directly with this link:
https://github.com/mm2270/CasperSuiteScripts/blob/master/Update_Core_Apps.sh
The ReadMe has most of the information you need to understand how it works, but if anyone has questions on it, feel free to ask. Just a couple of details:
The power of the script comes from a case statement that sets a large number of variables to use as the script runs, which is set by whatever is passed in Parameter 4. The case statement keeps the number of functions down a bit since in some cases a single function can be used for any of the apps or plug-ins the script can update.
As I mentioned above, since the script downloads updates directly and installs them, bandwidth conscious environments may not want to use something like this since it means each client will be accessing the downloads over the internet. But the advantage of the approach is not needing to worry about Smart Groups and updating Smart Groups to target Macs that need an update. The script takes care of the version checks.
The script is still a little bit of a work in progress but is pretty much feature complete as I envisioned it anyway. But of course if you see anything not working, or see any odd issues, let me know and I will look into it. Any feedback is welcome.
Posted on 01-09-2015 02:00 PM
Hallo Mike i really admire your post here on jamfnation !! looking @your script seems like you spend allot of time on it all i can say is thank you for sharing.
Great work!
Posted on 01-09-2015 03:10 PM
@mm2270][/url very nice work and thanks for posting this. Is there a way I'm missing to string all of the apps in $4 or is it one at a time? I tested the Java update portion and that seems to be unable to gather the latest version from Oracle. If someone else could verify for me, if I add the script multiple times it grabs the same value even if you set different values for each run of the script.
Posted on 01-09-2015 06:01 PM
@hcodfrie and @jhbush1973 - thanks for the feedback guys.
@ Jason - right now it works with one app/plug-in at a time. This is because when I began working on it, I saw it as a way to add to single policies that would appear in Self Service Though I've already been thinking about a way to make it run through a list of apps to check and update all of them at once. In fact, I have something else that is doing something along those lines right now, so it shouldn't be hard to do, once I get around to it.
As for the Java issue, what OS version did you test on? Was it Yosemite? I've occasionally seen some issues with 10.10 and the Java version check. I thought I corrected that, but I may need to take another look at it. I just tested the script today against 10.9.5 and it was working fine to grab the latest Java version.
Posted on 01-09-2015 09:13 PM
Hey jhbush1973 i had the same i created 7 scripts for this with both the $4 and $5 also have problems updating the java one.
It would be nice to gave them running in one script, can we make a feature request?
Posted on 01-10-2015 03:53 PM
@hcodfrie and @jhbush1973 - If you guys can let me know some details on the Macs you tested the Oracle Java update on, I can see if I can replicate it. If so, I'll see how to get it fixed. As I mentioned, I don't see the issue in testing on 10.9.5, so I suspect it may be under 10.10 or an earlier OS, so I would just need to know that if possible.
As for making it work to update all apps/plug-ins at once, as I mentioned, its something I've been thinking about. Just a question on that though - were you guys thinking mostly silent updates, or also for Self Service? If you also mean the latter, I would have to think about how to make that happen. Right now, its designed to work as follows in Self Service mode-
1) Policy runs and checks installed version against current released version
2) If a new version is found, it prompts the user if they would like to update
3) If they click Update Now it:
a) Shows download progress for update
b) Shows install progress as it installs
4) Shows final confirmation dialog (success or failure)
To have that sequence repeat for as many as 7 or 8 products at once would not be a good UX, so it would need to be reworked quite a bit. The same general process under the hood would apply for determining what needs to be updated, but i would need to show it as a single installation process and not separate ones for each. I'm not saying it isn't possible, just that it would take some work. I'm willing to do it, but its not a couple of lines of code change.
Posted on 01-10-2015 04:59 PM
Hey mike i tested it with a 10.10.1 machine with the $5 option ... So selfservice would be great.
Posted on 01-12-2015 07:46 AM
I realize I'm a little late to the party, but here is the script I created to install/update Firefox with the latest ESR version:
#!/usr/bin/python
############
# This script installs/updates the latest ESR version of the Firefox web browser.
############
# 1.0 - Jorge Escala - 2014-12-24
# * Initial script creation.
############
import re, os
from distutils.dir_util import copy_tree
from os.path import isfile
from plistlib import readPlist
from ftplib import FTP
server='ftp.mozilla.org'
path='pub/mozilla.org/firefox/releases/latest-esr/mac/en-US'
plistFile='/Applications/Firefox.app/Contents/Info.plist'
DEBUG=False
ftp=FTP(server)
ftp.login()
ftp.cwd(path)
fileList=(ftp.nlst())
# Get latest version of Firefox and filename
latestFirefoxDownload=next(i for i in fileList if re.match( r'Firefox.*.dmg', i))
latestFirefoxVersion=latestFirefoxDownload[8:-7]
# Get currently installed version of Firefox
if isfile(plistFile):
pl = readPlist(plistFile)
currentFirefoxVersion=pl["CFBundleShortVersionString"]
else:
currentFirefoxVersion="none"
if DEBUG:
print("current: "+currentFirefoxVersion)
print("latest: "+latestFirefoxVersion)
if latestFirefoxVersion != currentFirefoxVersion:
ftp.retrbinary('RETR '+latestFirefoxDownload, open('/tmp/Firefox.dmg', 'wb').write)
commandCall='hdiutil attach -nobrowse -mountpoint "/Volumes/Firefox" "/tmp/Firefox.dmg"'
os.system(commandCall)
copy_tree("/Volumes/Firefox/Firefox.app", "/Applications/Firefox.app")
commandCall='hdiutil detach "/Volumes/Firefox"'
os.system(commandCall)
Posted on 01-13-2015 08:30 AM
Love the script. The only thing I changed for our school district was to modify the upToDate function to output the version information, because people here like to see what version is installed when they are told that they are already at the most recent version.
EDIT: I know that information is in the logs, I just added it to what is shown to the user in Self Service mode.
Posted on 01-13-2015 08:45 AM
Thanks @musat! That's a good modification. I may incorporate your edit into my posted version.
Posted on 01-13-2015 01:02 PM
The script was updated to correct for the Java version checking issue that was reported. Seems to be working as expected now.
I haven't incorporated a change as @musat mentioned to include the version info when the app/plug-in is up to date (in the Self Service dialogs), but will do that soon.
Posted on 01-28-2015 12:17 PM
Looks like that Update_Core_Apps script is not working for Adobe Reader installs/updates. It fails saying it could not locate the package in the mounted volume. Oddly, it works as an update with dialogue but not silently or a new install.
Posted on 01-28-2015 12:26 PM
@McAwesome - just curious, but when did you download the script? I had corrected that issue some days back and updated the script on github. It was a string in the case statement that was set wrong, so it was looking for the wrong package name. Try downloading the script again from my page and try it again. If you still see an issue with this, either post here, or better yet, submit an issue on my github page so we can track it.
In the meantime, I'll run it locally in silent mode to see if I can reproduce the problem.
Thanks.
Posted on 01-28-2015 12:41 PM
I downloaded it(the Jan 15, 2015 version) a couple of hours ago today. With the GUI, it gets to 97% or so and fails. Silently it gets to stage 5 and fails. I'd report it on GitHub, but I currently don't have an account there(never have to use it myself).
Posted on 01-28-2015 01:27 PM
@McAwesome - please download the script again. It was just updated. I had a grep where there should have been an egrep on one line. The new version labeled as modified on 2015-01-28 is now working in silent mode. I just tested it by updating Adobe Reader to 11.0.10 on my Mac.
The latest script also includes the ability to update or install Dropbox and Cyberduck. MS Lync was also rolled in from a previous beta version.
Posted on 01-28-2015 01:48 PM
Dear sweet baby spaghetti monster.
STEPS:
;)
Posted on 01-28-2015 02:49 PM
@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.
Posted on 03-23-2015 05:59 AM
Posted on 03-23-2015 09:52 AM
@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.
Posted on 03-23-2015 10:19 AM
@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.
Posted on 03-23-2015 11:03 AM
@mm2270, thanks, I'm definitely interested in helping out!
Posted on 03-23-2015 11:22 AM
@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.
Posted on 03-24-2015 02:12 AM
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
Posted on 08-03-2015 09:13 AM
@joe.farage Is there an easy way to add support for multiple languages based on what language the OS is using?
Posted on 12-02-2015 08:47 AM
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
Posted on 12-02-2015 08:50 AM
edit out the sudo commands, they are not needed when run under the policy
Posted on 01-25-2016 03:06 AM
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
Posted on 01-25-2016 04:46 AM
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
Posted on 07-27-2016 04:03 PM
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.
Posted on 07-28-2016 06:38 AM
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?