install.sh.OLD 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #! /bin/sh
  2. # - Take new tar file as argument DONE
  3. # - Verify argument is valid DONE
  4. # - Verify script is running as sudo DONE
  5. # - Move existing firefox to firefox.OLD DONE
  6. # - create directory for new installation DONE
  7. # - unpack tar file to new location DONE
  8. # - Optional, verify desktop file extsts
  9. helpFunction()
  10. {
  11. echo " "
  12. echo "Provides convenient means to install a new Firefox tar file."
  13. echo "Pass new tar file as argument and this script will handle backing up the current installation and unpacking the new installation."
  14. echo "This script will prompt before deleting a previous archive."
  15. echo "Must run with root privileges."
  16. echo " "
  17. echo "Usage: $0 [filename]"
  18. echo " "
  19. }
  20. ## Take input and verify file and root user##
  21. filename=$1
  22. if [ "$filename" = "-h" ] || [ "$filename" = "--help" ]; then
  23. helpFunction
  24. exit 0
  25. fi
  26. if ! [ -f "$filename" ]; then
  27. echo "$1 not found."
  28. helpFunction
  29. exit 1
  30. fi
  31. if [ -z "$filename" ]
  32. then
  33. echo " "
  34. echo "No filename given. Aborting."
  35. helpFunction
  36. exit 1
  37. fi
  38. if [ "$USER" != "root" ]; then
  39. echo "Must be running as root to install new software. Use sudo or root user"
  40. helpFunction
  41. exit 1
  42. fi
  43. echo "$1 file found"
  44. ## Move existing folder to .OLD and delete existing .OLD if needed ##
  45. echo "Checking for old installations"
  46. if [ -d "/opt/firefox.OLD" ]; then
  47. read -p "firefox.OLD already exists? Should I delete it? ENTER to continue or CTRL+C to abort." input
  48. fi
  49. echo "Deleting existing firefox.OLD folder"
  50. rm -rf /opt/firefox.OLD
  51. echo "Moving Existing firefox to firefox.OLD"
  52. mv /opt/firefox /opt/firefox.OLD
  53. echo "Making new firefox directory"
  54. mkdir /opt/firefox
  55. echo "unpacking "$filename" to /opt/firefox"
  56. tar -xjvf "$filename" -C "/opt/"
  57. # ensure symlink is set
  58. ln -fs /opt/firefox/firefox /usr/local/bin/firefox