Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- PROFILE=$(mktemp -d)
- if [[ -d ~/firefox/default/ ]]; then
- cp --recursive ~/firefox/default/* $PROFILE
- fi
- if [[ $# -eq 0 ]] ; then
- if [[ -x /usr/bin/firefox ]]; then
- echo 'Launching...'
- /usr/bin/firefox --new-instance --profile $PROFILE
- rm -rf $PROFILE
- exit
- else
- echo "No version given and no installed version found"
- exit 1
- fi
- fi
- # if the given version is without minor version (e.g. "55" instead of )
- VERSION="$1"
- if [[ ! -z "${VERSION##*.*}" ]]; then
- VERSION="$1.0"
- fi
- # if the version has already been downloaded, then we can launch it and be done
- if [[ -x ~/firefox/firefox-$VERSION/firefox/firefox ]]; then
- echo 'Launching...'
- ~/firefox/firefox-$VERSION/firefox/firefox --new-instance --profile $PROFILE
- rm -rf $PROFILE
- exit 0
- fi
- mkdir -p ~/firefox/firefox-$VERSION/
- # download the version from mozillas archive
- echo 'Downloading from archives...'
- wget -q \
- -O ~/firefox/firefox-$VERSION.tar.bz2 \
- http://ftp.mozilla.org/pub/firefox/releases/$VERSION/linux-$(uname -m)/en-US/firefox-$VERSION.tar.bz2
- # if the download failed, clean up and die
- if [[ $? -ne 0 ]]; then
- echo 'Download failed (possibly unknown version). Cleaning up...'
- echo 'Available releases: http://ftp.mozilla.org/pub/firefox/releases/'
- rm ~/firefox/firefox-$VERSION.tar.bz2
- rmdir ~/firefox/firefox-$VERSION/
- exit 1
- fi
- # unpack the tar
- echo 'Unpacking...'
- tar -xjf ~/firefox/firefox-$VERSION.tar.bz2 -C ~/firefox/firefox-$VERSION/ >/dev/null
- rm ~/firefox/firefox-$VERSION.tar.bz2
- # disable auto update mechanism (the hard way)
- rm ~/firefox/firefox-$VERSION/firefox/updater
- rm ~/firefox/firefox-$VERSION/firefox/updater.ini
- rm ~/firefox/firefox-$VERSION/firefox/update-settings.ini
- # and we're done
- echo 'Launching...'
- ~/firefox/firefox-$VERSION/firefox/firefox --new-instance --profile $PROFILE
- rm -rf $PROFILE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement