Category filter

Script to install the latest Firefox version on macOS devices

Firefox prioritizes user’s privacy, security, and provides customization options for browsing according to the user’s preferences which makes it ideal for enterprise use. The script in the document ensures that the device is installed with the latest version of Firefox. Administrators can use the script to remotely install the latest Firefox on macOS devices using Hexnode’s Execute Custom Script remote action.

Scripting Language – Shell

File extension – .sh

Disclaimer:


The sample scripts provided below are adapted from third-party open-source sites.

Shell script

Install the latest Firefox version on macOS devices

The above script checks whether the directory “/Applications/Firefox.app” exists or not to verify if the app is present on the device. If Firefox is installed already on the device, the script exits with a success status (‘exit 0’). If Firefox is not installed on the device, the script initiates the download of the latest version by fetching the URL stored in the ‘firefox_url’ variable. The ‘download_dir’ variable specifies the path on the device where the Firefox installer will be downloaded. In this case, the installer is downloaded to the user’s home directory under the ‘Applications’ folder.

‘curl’ is a command-line tool used to make network requests through terminal. In this script, ‘curl’ is used to download Firefox from the specified URL. The ‘-L’ parameter instructs the ‘curl’ command to follow any HTTP redirects, ensuring it completes the download. The ‘-o’ parameter specifies the filename for the downloaded content. ‘hdutil’ mounts the downloaded disk image.

‘cp -r “/Volumes/Firefox/Firefox.app” “/Applications/”’ is used for copying the Firefox application from the mounted disk.

After executing the script successfully, the output can be seen from the Action History.
Output showing the installation of the latest Firefox version

Notes:

  • The script may fail if the device does not have proper network connection.
  • After executing the script from the portal, it may take some time for the script to execute successfully.
  • It is recommended to manually validate the script execution on a system before executing on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository