Created
March 1, 2023 18:12
-
-
Save wklaebe/25ae5994ac3aeda776cfdcce30060d96 to your computer and use it in GitHub Desktop.
A script to download and install Firefox to /opt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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