Advertisement
egoisticalgoat

Firefox version starter

Jan 14th, 2019
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.95 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. PROFILE=$(mktemp -d)
  4.  
  5. if [[ -d ~/firefox/default/ ]]; then
  6.     cp --recursive ~/firefox/default/* $PROFILE
  7. fi
  8.  
  9. if [[ $# -eq 0 ]] ; then
  10.     if [[ -x /usr/bin/firefox ]]; then
  11.         echo 'Launching...'
  12.         /usr/bin/firefox --new-instance --profile $PROFILE
  13.         rm -rf $PROFILE
  14.         exit
  15.     else
  16.         echo "No version given and no installed version found"
  17.         exit 1
  18.     fi
  19. fi
  20.  
  21. # if the given version is without minor version (e.g. "55" instead of )
  22. VERSION="$1"
  23. if [[ ! -z "${VERSION##*.*}" ]]; then
  24.     VERSION="$1.0"
  25. fi
  26.  
  27. # if the version has already been downloaded, then we can launch it and be done
  28. if [[ -x ~/firefox/firefox-$VERSION/firefox/firefox ]]; then
  29.     echo 'Launching...'
  30.     ~/firefox/firefox-$VERSION/firefox/firefox --new-instance --profile $PROFILE
  31.     rm -rf $PROFILE
  32.     exit 0
  33. fi
  34.  
  35. mkdir -p ~/firefox/firefox-$VERSION/
  36.  
  37. # download the version from mozillas archive
  38. echo 'Downloading from archives...'
  39. wget -q \
  40.     -O ~/firefox/firefox-$VERSION.tar.bz2 \
  41.     http://ftp.mozilla.org/pub/firefox/releases/$VERSION/linux-$(uname -m)/en-US/firefox-$VERSION.tar.bz2
  42.  
  43. # if the download failed, clean up and die
  44. if [[ $? -ne 0 ]]; then
  45.     echo 'Download failed (possibly unknown version). Cleaning up...'
  46.     echo 'Available releases: http://ftp.mozilla.org/pub/firefox/releases/'
  47.     rm ~/firefox/firefox-$VERSION.tar.bz2
  48.     rmdir ~/firefox/firefox-$VERSION/
  49.     exit 1
  50. fi
  51.  
  52. # unpack the tar
  53. echo 'Unpacking...'
  54. tar -xjf ~/firefox/firefox-$VERSION.tar.bz2 -C ~/firefox/firefox-$VERSION/ >/dev/null
  55. rm ~/firefox/firefox-$VERSION.tar.bz2
  56.  
  57. # disable auto update mechanism (the hard way)
  58. rm ~/firefox/firefox-$VERSION/firefox/updater
  59. rm ~/firefox/firefox-$VERSION/firefox/updater.ini
  60. rm ~/firefox/firefox-$VERSION/firefox/update-settings.ini
  61.  
  62. # and we're done
  63. echo 'Launching...'
  64. ~/firefox/firefox-$VERSION/firefox/firefox --new-instance --profile $PROFILE
  65. rm -rf $PROFILE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement