install-from-tarball 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. #
  3. # Copyright 2019 Mason Hock <mason@masonhock.com>
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. # determine browser
  17. if [[ $(basename $1) == "icecat"*"gnulinux"*"tar.bz2" ]]; then
  18. BROWSER=icecat
  19. echo "installing Icecat"
  20. elif [[ $(basename $1) == "tor-browser-linux"*"tar.xz" ]]; then
  21. BROWSER=tor-browser
  22. echo "installing Tor Browser"
  23. else
  24. echo "invalid tarball. see
  25. https://www.gnu.org/software/gnuzilla/
  26. https://www.torproject.org/download/download.html"
  27. exit 0
  28. fi
  29. # create directories
  30. [[ -d ~/.local ]] || mkdir ~/.local
  31. [[ -d ~/.local/bin ]] || mkdir ~/.local/bin
  32. [[ -d ~/.local/lib ]] || mkdir ~/.local/lib
  33. [[ -d ~/.local/share ]] || mkdir ~/.local/share
  34. [[ -d ~/.local/share/applications ]] || mkdir ~/.local/share/applications
  35. # add ~/.local/bin to PATH
  36. if ! echo $PATH | grep $HOME/.local/bin; then
  37. echo 'PATH="$HOME/.local/bin:$PATH"' >> $HOME/.profile
  38. fi
  39. # install
  40. mkdir ~/.local/lib/$BROWSER
  41. tar xf $1 --directory ~/.local/lib/$BROWSER --strip-components=1
  42. if [[ $BROWSER = icecat ]]; then
  43. ln -s ~/.local/lib/icecat/icecat ~/.local/bin/icecat
  44. cp icecat.desktop ~/.local/share/applications/icecat.desktop
  45. sed -i "s|Icon=icecat|Icon=$HOME/.local/lib/icecat/browser/chrome/icons/default/default128.png|" ~/.local/share/applications/icecat.desktop
  46. elif [[ $BROWSER = tor-browser ]]; then
  47. ln -s ~/.local/lib/tor-browser/Browser/start-tor-browser ~/.local/bin/tor-browser
  48. ln -s ~/.local/lib/tor-browser/start-tor-browser.desktop ~/.local/share/applications/tor-browser.desktop
  49. fi