Guest User

Untitled

a guest
Jul 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # firefox_upgrade - program to upgrade firefox quantum
  4.  
  5. error_exit()
  6. {
  7. echo "$1" 1>&2
  8. exit 1
  9. }
  10.  
  11. firefox_path=""
  12. firefox_file=""
  13.  
  14. # parsing path and filename
  15. if [ $# -ne 1 ]; then
  16. error_exit "usage: $0 firefox_quantum_path"
  17. else
  18. firefox_path="$1"
  19. firefox_file="${firefox_path##*/}"
  20. fi
  21.  
  22. # checking if input is a valid file
  23. if [ ! -f "$firefox_path" ]; then
  24. error_exit "Invalid file! Aborting."
  25. fi
  26.  
  27. # removing previous install, if existent
  28. firefox_bin="/opt/firefox"
  29. if [ -e "$firefox_bin" ]; then
  30. rm -rf $firefox_bin
  31. else
  32. echo "$firefox_bin doesn't exist."
  33. fi
  34.  
  35. # removing previous symlink, if existent
  36. firefox_link="/usr/bin/firefox-quantum"
  37. if [ -f "$firefox_link" ]; then
  38. rm $firefox_link
  39. else
  40. echo "$firefox_link doesn't exist."
  41. fi
  42.  
  43. # copying the tar to /opt
  44. rsync -ah --progress $firefox_path /opt/$firefox_file
  45.  
  46. # unpacking the tar if successfully changed directory
  47. if cd /opt; then
  48. tar -jxvf $firefox_file
  49. else
  50. error_exit "Could not change directory! Aborting."
  51. fi
  52.  
  53. # if unpack was successful, set permissions, create symlink, and remove tar
  54. if [ "$?" = "0" ]; then
  55. chmod 755 /opt/firefox
  56. ln -s /opt/firefox/firefox /usr/bin/firefox-quantum
  57. rm $firefox_file
  58. else
  59. error_exit "Could not extract file! Aborting."
  60. fi
  61. exit 0
Add Comment
Please, Sign In to add comment