Skip to main content

Worklet: Ensuring Firefox is installed on Mac devices


AdamW-Automox
Forum|alt.badge.img

This worklet will evaluate Mac devices to ensure the latest version of Firefox is installed. If the worklet finds the Firefox applications is not installed, the remediation code will install it on the device.

Evaluation:

#!/bin/bash
#example script for installing Firefox on Mac devices

#evaluate the device to see if Firefox is currently installed.  
if [ -d "/Applications/firefox.app" ]; then
        exit 0
else
        exit 1
fi

Remediation:

#!/bin/bash
#example script for installing Firefox on Mac devices

#create a temporary directory to download Firefox install file
set -e
tempfile=$(mktemp)

#download the latest version of Firefox to the temp file
echo "Downloading Firefox..."
curl -L "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -o "$tempfile"
echo "Installing Firefox..."

#mount the firefox dmg file to a volume 
hdiutil attach /tmp/Firefox.dmg

#copy the firefox app to the devices applications 
cp -R /Volumes/Firefox/Firefox.app/ /Applications/Firefox.app

#remove tmp file and unmount the image from the volume
echo "Cleaning up..."

hdiutil detach /Volumes/Firefox/ -quiet
sleep 2

rm -f "$tempfile"
This topic has been closed for comments

23 replies

PaulB
  • Former Automox Employee
  • 9 replies
  • August 22, 2019

Two things caught my eye:

“Google firefox.app” looks wrong?

And the URL to get the most recent version of Firefox for OS X would be something like so: https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US


Nic-Automox
  • Former Automox Employee
  • 832 replies
  • August 22, 2019

It looks like Adam is pulling from their CDN directly, which might explain the different URL.


Nic-Automox
  • Former Automox Employee
  • 832 replies
  • August 22, 2019

I think you’re right on the “Google firefox.app” - I’ll fix that to just say “firefox.app”


AdamW-Automox
Forum|alt.badge.img
  • Author
  • Automox Employee
  • 48 replies
  • August 22, 2019

I typed that in by accident when adding comments. Please make the change.


AdamW-Automox
Forum|alt.badge.img
  • Author
  • Automox Employee
  • 48 replies
  • August 22, 2019

Made the change


Nic-Automox
  • Former Automox Employee
  • 832 replies
  • August 22, 2019

Thanks @awhitman!


AdamW-Automox
Forum|alt.badge.img
  • Author
  • Automox Employee
  • 48 replies
  • August 22, 2019

This is correct, but I can update it to the Mozilla URL


PaulB
  • Former Automox Employee
  • 9 replies
  • August 22, 2019

I wonder if the CDN has a most recent URL too. I went by the instructions that I found on their FTP server. Old school.

https://ftp.mozilla.org/pub/firefox/releases/latest/README.txt


AdamW-Automox
Forum|alt.badge.img
  • Author
  • Automox Employee
  • 48 replies
  • August 22, 2019

had issues curling the latest version URL. Direct pull from CDN and I will update the latest URL link


AdamW-Automox
Forum|alt.badge.img
  • Author
  • Automox Employee
  • 48 replies
  • August 22, 2019

This is for the .exe which would work. Just need to change the syntax to run the .exe instead of mounting the .dmg to a volume.


Nic-Automox
  • Former Automox Employee
  • 832 replies
  • August 22, 2019

It’s already live - people are getting to see the sausage made in real time 🙂


PaulB
  • Former Automox Employee
  • 9 replies
  • August 22, 2019

This cURL command worked for me. But I did not try it in the sausage machine.

curl “https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US” > “Firefox.dmg”


AdamW-Automox
Forum|alt.badge.img
  • Author
  • Automox Employee
  • 48 replies
  • August 22, 2019

Worked for me too! Must have clicked the wrong link. Made the change and tested it. Should be good to go!


Nic-Automox
  • Former Automox Employee
  • 832 replies
  • August 22, 2019

And that is how quickly we fix stuff at Automox 🙂

Thanks for the speedy response guys!


ChristianB
  • Former Automox Employee
  • 3 replies
  • August 23, 2019

Sudo isn’t required in this context as the agent runs as root user. It will actually change the environment if you use it here.

That curl command will return an HTML document as that address is a CDN so you need to follow links with curl -L <address>

hdiutil can return errors if that URL returns a bad value and may not error the way you like.

Shouldn’t the remediation script also return 1 or 0?


  • Novice
  • 19 replies
  • April 17, 2020

Hi, I am trying to use the firefox worklet but I am getting this error:
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0/Library/Application Support/Automox/execDir080237696/execcmd361802207: line 12: 1”: command not found curl: (6) Could not resolve host: “https


Schuyler-Automox

That is strange. The error implies that curl is not on the machine, but the output for the first piece is the status in curl.
% Total % Received % Xferd Average Speed Time....
Let me see if I can reproduce this behavior.


AdamW-Automox
Forum|alt.badge.img
  • Author
  • Automox Employee
  • 48 replies
  • April 18, 2020

Could you check to make sure cURL is installed on the OS?

run the command curl --help and see if it returns with the help option for curl. If not, then it isn’t installed on your Mac’s OS.

To install curl follow these instructions

Once installed, try to run the Firefox install Worklet again.

If that does not work, It maybe a bad cURL install, which is why it shows the curl output in the first piece. Try to uninstall, and reinstall.

I also see Could not resolve host: “https at the end of the stderr snippet you have. This usually means that there is an issue connecting to the host provided in the curl. Can you confirm your mac device can connect to https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US and see if it download the Firefox .dmg?


  • Novice
  • 19 replies
  • April 20, 2020

Hi Yes curl is installed.
the mac os version is 10.15.4
and yes I can run the curl download manually just fine.
thank you


Forum|alt.badge.img
  • Automox Employee
  • 134 replies
  • April 20, 2020

L4d1k,
check out this post regarding an identical issue. In the OPs case, it was DNS configuration, which is what your message alludes to when it states the URL is not found.


Nic-Automox
  • Former Automox Employee
  • 832 replies
  • April 20, 2020

Or you can consult this handy website which will tell you if the problem is DNS related:
https://isitdns.com/

(note: this is a joke website 🙂 )


  • Novice
  • 19 replies
  • April 20, 2020

Hi, the strange think is if I run it manually using terminal then it downloads fine.


Nic-Automox
  • Former Automox Employee
  • 832 replies
  • April 20, 2020

That’s probably because the terminal is running as you whereas what comes through Automox is running as root. Differences in the environment variables could be throwing a wrench in things.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings