SCRIPT | Install-Firefox-Latest

ByDan Ashley

SCRIPT | Install-Firefox-Latest

Install Firefox

Summary

This script will install the latest version of Firefox.


Script Content

#!/bin/bash
cd "/Library/Application Support/JAMF/tmp"

# Update variables. These shouldn't need to change for each update
dmgname="Firefox.dmg"
dmglink="http://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US"
dmgmountedname="Firefox"
apptoreplace="Firefox.app"
apptoreplacerunningname="Firefox"

# Download DMG
curl -L -o $dmgname "$dmglink"

# Mount DMG 
hdiutil mount -nobrowse $dmgname

# Kill the app if it is running
killall -Kill "$apptoreplacerunningname"

# Remove the app from the Applications Folder
rm -rf "/Applications/$apptoreplace"

# Copy the new version into the Applications Folder
cp -R "/Volumes/$dmgmountedname/$apptoreplace" /Applications

# Set the user as the current logged in user
netname=`ls -l /dev/console | cut -d " " -f 4`

chown -R ${netname}:Staff "/Applications/$apptoreplace"

sudo xattr -rc "/Applications/$apptoreplace/"

# Unmount the DMG
hdiutil unmount "/Volumes/$dmgmountedname"

# Remove the downloaded DMG
rm $dmgname

# Clear out the used variables
unset dmgname
unset dmglink
unset dmgmountedname
unset apptoreplace
unset apptoreplacerunningname
unset netname
exit 0

Concluding Comments

Firefox is a common web browser often used as an alternative to either Google Chrome of Safari for macOS users. This script allows you to know the latest version is always being deployed.

About the author

Dan Ashley administrator