Firefox universal pkg installer script

tcandela
Valued Contributor II

I'm using this following script https://github.com/jamf/Jamf-Nation-Scripts/blob/master/FirefoxInstall.sh that is labeled in the top area of the script 'Only works on Intel system'. 

Looks like the current Firefox macOS download is universal.   Does anyone have a script this will download and install the current version of Firefox?  or will simply removing from the script the 'IF' check for intel systems simply work????

 

here is the download link for macOS firefox when i copy the link from the mozilla firefox download page

https://download.mozilla.org/?product=firefox-latest-ssl&os=osx&lang=en-US&_gl=1*1hew6xw*_ga*MTA4NjE...

8 REPLIES 8

tcandela
Valued Contributor II

It looks like i might have found a post with the solution, so i'll test it out

https://community.jamf.com/t5/jamf-pro/latest-firefox-now-available-as-pkg/td-p/228259

tcandela
Valued Contributor II

actually it looks like there is some issue with the if statement in this script https://github.com/jamf/Jamf-Nation-Scripts/blob/master/FirefoxInstall.sh  and the script actually runs on M1 system.   But the problem is is that it installs firefox version 98.02 and not the current version as of 6/17/2022 (which is something like 101).

So i've seen on both intel and M1 macs that his script runs on both but installs version 98.02  no matter how many times the script is executed.

I'm going to test  this script now https://community.jamf.com/t5/jamf-pro/latest-firefox-now-available-as-pkg/td-p/228259

 

 

talkingmoose
Honored Contributor II
Honored Contributor II

Here's one I put together a while back.

https://gist.github.com/talkingmoose/b99a43948c4784631e9ad60eb714c776

It'll install and/or update Firefox. I've designed it to not install while Firefox is running and it should compare what's installed with what's available before doing anything.

tcandela
Valued Contributor II

@talkingmoose   so your script is good to go  no matter  if it's run on  INTEL or M1 macs?   I'm pretty sure the firefox installer is universal anyways.

talkingmoose
Honored Contributor II
Honored Contributor II

According to the System Information app, the version my script just downloaded is Universal.

mmcallister
Contributor II

Installomator (https://github.com/Installomator/Installomator) is working for us on both Intel and Apple Silicon Macs.

tcandela
Valued Contributor II

@talkingmoose  in the script i see a couple of one liners like this = logresult "Downloaded DMG." "Failed to download DMG."

is this another way of writing an IF statement?

 

talkingmoose
Honored Contributor II
Honored Contributor II

@tcandela, that's a little function I put together a while back and keep reusing in a lot of my scripts where I want to write a log file for quick and easy access.

First, I define where the log is written:

# create log file in same directory as script
log="/Library/Logs/My Script.log"

Then I create a function named "logresult". It writes a timestamped message to the log file defined above.

function logresult() {
if [ $? = 0 ] ; then
/bin/date "+%Y-%m-%d %H:%M:%S $1" >> "$log"
else
/bin/date "+%Y-%m-%d %H:%M:%S $2" >> "$log"
fi
}

 Usually, all I want to know is whether a command succeeded or failed. If I run $? immediately after any command it'll either return 0 (success) or something other than 0 like 1 (fail).

When I want to log "success" or "fail", I write immediately after the command:

logresult "Success" "Fail"

The positions of "Success" and "Fail" are like script parameters. "Success" = "$1" and "Fail" = "$2". If I needed more options I could write something like:

logresult "Yes" "No" "I don't know" "I don't care"

"Yes" = "$1"

"No" = "$2"

"I don't know" = "$3"

"I don't care" = "$4"

Putting it all together:

  1. Run a command
  2. Immediately run the "logresult" function with a message for success as the "$1" parameter and a message for fail as the "$2" parameter.
  3. The function runs $? to see if the command returned 0 or something else.
  4. The if statement in the function writes the success message ($1) to the log if the command returned 0. Otherwise, it writes the fail message ($2) to the log file if the command returned something other than 0.