Install/Update Firefox (Mac)
Log In or Register to download the BES file, and more.

0 Votes

Description

Checks for the latest version of Firefox available, and installs it if a newer version is found.

Modify ".MyCompany" on line 23 of the action script, and in the relevance, as needed.

This Fixlet does not validate the hashes of the downloaded Mozilla Firefox installer. Use at your own risk

This Fixlet will become relevant 3 days after its last runtime. To change this, modify the relevance


Property Details

ID27340
StatusProduction - Fully Tested and Ready for Production
TitleInstall/Update Firefox (Mac)
CategorySoftware Distribution
Download Size1350
SourceFirefox Updater
Source ID<Unspecified>
Source Severity<Unspecified>
Source Release Date1/31/2024 12:00:00 AM
Keywordsfirefox, mac, macos, update, upgrade, perpetual, automatic
Is TaskTrue
Added by on 5/6/2024 8:48:51 AM
Last Modified by on 5/6/2024 8:55:06 AM
Counters 267 Views / 1 Download
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.

Relevance

Used in 226 fixlets and 100 analyses   * Results in a true/false
Show indented relevance
mac of operating system
Used in 1 fixlet   * Results in a true/false
Show indented relevance
if (exists file "/Library/.MyCompany/firefoxUpdater/lastRun") then ((now - (line of file "/Library/.MyCompany/firefoxUpdater/lastRun" as time)) > "3 days" as time interval) else True

Actions

Action 1 (default)

Action Link Click  here  to deploy this action
Script Type BigFix Action Script
parameter "mainSWDLogFolder" = "{parent folder of client folder of current site}/__Global/SWDDeployData"
folder create "{parameter "mainSWDLogFolder"}"
parameter "logFile" = "SWD_DeploymentResults.log"
parameter "logFolder" = "{parameter "mainSWDLogFolder"}"

wait sh -c "echo '' >> '{parameter "mainSWDLogFolder"}/{parameter "logFile"}'"
wait sh -c "echo $(date +%Y_%m_%d' '%T) >> '{parameter "mainSWDLogFolder"}/{parameter "logFile"}'"
wait sh -c "echo Action ID: {id of active action} >> '{parameter "mainSWDLogFolder"}/{parameter "logFile"}'"

if {exists application ("Firefox.app" of folder "/Applications")}
parameter "installedVersion" = "{version of application "Firefox.app" of folder "/Applications")}"
wait sh -c "echo Installed Firefox version: {parameter "installedVersion"} >> '{parameter "mainSWDLogFolder"}/{parameter "logFile"}'"
else
parameter "installedVersion" = "0.0"
wait sh -c "echo Firefox is not installed >> '{parameter "mainSWDLogFolder"}/{parameter "logFile"}'"
endif

delete __createfile
delete "__Download/runtime.sh"
createfile until _end_
#/bin/zsh

homepath="/Library/.MyCompany/firefoxUpdater"
currDate=$(LANG=en_US date '+%a, %d %b %Y %H:%M:%S %z' 2>&1)

if [ -d $homepath ]; then
rm -r $homepath
fi
mkdir -p $homepath

echo $currDate > $homepath/lastRun
_end_
copy "__createfile" "__Download/runtime.sh"
wait chmod +x "__Download/runtime.sh"
wait /bin/zsh "__Download/runtime.sh"

delete __createfile
delete getLatestFirefox.sh
delete latestFirefox.txt
createfile until _EOF_
#!/bin/zsh
latestURL=""
tries=0
while [[ -z $latestURL && $tries -lt 20 ]]
do
    if [[ $tries -gt 0 ]]; then
        echo -n "[$(LANG=en_US date +%R 2>&1)] Trying again in $(( 5*$tries )) seconds..." >> "{parameter "logFolder"}/{parameter "logFile"}"
        sleep $(( 5*$tries ))
    fi
    latestURL=$(curl -fIsS 'https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US') 2>> "{parameter "logFolder"}/{parameter "logFile"}"
    curlExit=$?
    tries=$((tries+1))
done
if [[ tries -gt 1 ]]; then
    echo "" >> "{parameter "logFolder"}/{parameter "logFile"}"
fi
if [[ -z $latestURL ]]; then
    echo "Failed to gather latest URL. Exiting..." >> "{parameter "logFolder"}/{parameter "logFile"}"
    exit $curlExit
fi
latestURL=$(echo $latestURL | awk '/^Location/ {{print $NF}')
echo "curl exit $curlExit with value: $latestURL" >> "{parameter "logFolder"}/{parameter "logFile"}"
echo $latestURL > latestFirefox.txt
_EOF_
copy __createfile getLatestFirefox.sh
wait chmod +x getLatestFirefox.sh
wait /bin/zsh getLatestFirefox.sh
parameter "curlCheckError" = "{exit code of action}"
if {parameter "curlCheckError" != "0"}
exit {parameter "curlCheckError"}
endif

parameter "latestFirefoxURL" = "{line of file "latestFirefox.txt"}"
parameter "latestFirefoxVersion" = "{substring before ".dmg" of (substring after "%2520" of (parameter "latestFirefoxURL"))}"
wait sh -c "echo Latest Firefox version: {parameter "latestFirefoxVersion"} >> '{parameter "mainSWDLogFolder"}/{parameter "logFile"}'"

if {pad of version (parameter "latestFirefoxVersion") > pad of version (parameter "installedVersion")}
delete __createfile
delete foxHound.sh
createfile until _EOF_
#!/bin/bash
curl -Lo firefox.pkg '{(substring before ".dmg" of (parameter "latestFirefoxURL") & ".pkg")}'
curlExit=$?
echo "curl download exited with value: $curlExit" >> "{parameter "logFolder"}/{parameter "logFile"}"
installer -pkg "firefox.pkg" -target / >> "{parameter "logFolder"}/{parameter "logFile"}"
_EOF_
copy __createfile foxHound.sh
wait chmod +x foxHound.sh
wait /bin/sh foxHound.sh
parameter "error" = "{exit code of action}"

if {exists running application whose (name of it as lowercase contains "firefox") and exists file "/usr/local/bin/hubcli"}
wait /bin/sh -c "/usr/local/bin/hubcli notify -t 'Please restart Firefox' -i 'Updates have been installed. Click Okay to restart Firefox' --actionbtn 'Okay' --script 'pkill firefox && sleep 5 && open -a firefox &'"
endif

else
//exit code 10 means Firefox is up to date
wait sh -c "echo Firefox is already up to date >> '{parameter "mainSWDLogFolder"}/{parameter "logFile"}'"
parameter "error" = "10"
endif

wait sh -c "echo Return Code: {parameter "error"} >> '{parameter "mainSWDLogFolder"}/{parameter "logFile"}'"

if {parameter "error" != "0" and parameter "error" != "10"}
exit {parameter "error"}
endif

exit {parameter "error"}
Success Criteria

This action will be considered successful when all lines of the action script have completed successfully.


Sharing

Social Media:
Share this page on Yammer

Comments

Log In or Register to leave comments!