Skip to content

Instantly share code, notes, and snippets.

@wklaebe
Created March 1, 2023 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wklaebe/25ae5994ac3aeda776cfdcce30060d96 to your computer and use it in GitHub Desktop.
Save wklaebe/25ae5994ac3aeda776cfdcce30060d96 to your computer and use it in GitHub Desktop.
A script to download and install Firefox to /opt
#!/bin/bash -ex
if [ "$UID" != "0" ]; then
sudo "$0"
exit
fi
d="$(mktemp -d)"
cd "$d"
trap "rm -rf $d" EXIT
wget --content-disposition 'https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=en-US'
fv="$(ls -1 firefox-*.tar.*)"
f="${fv//.tar.*}"
if [ -z "$fv" ]; then
echo "No firefox-*.tar.bz2 found! Problem while downloading?"
exit 1
fi
if [ -d "/opt/$f" ]; then
echo "Downloaded version ${f#firefox-} already installed!"
exit 0
fi
tar xvaf "$fv"
if [ ! -d firefox ]; then
echo "Cannot find a 'firefox' directory after extracting downloaded archive!"
exit 2
fi
mv firefox "/opt/$f"
cd /opt
ln -sfT "$f" firefox
echo "Firefox ${f#firefox-} installed successfully!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment