install.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #! /bin/bash
  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 Nextcloud AppImage file."
  13. echo "Pass new AppImage file as argument and this script will update the symlinks and verify installation."
  14. echo "Must run with root privileges."
  15. echo " "
  16. echo "Usage: sudo $0 [filename]"
  17. echo " "
  18. }
  19. ## Take input and verify file and root user##
  20. filename=$(basename $1) ##Take Basename in case file in cae user is in unusual directory when calling script.
  21. projectdir="/home/mike/Software/Nextcloud"
  22. imagepath="$projectdir/apps"
  23. executablelink="/usr/local/bin"
  24. desktoppath="/usr/local/share/applications"
  25. assetspath="$projectdir/assets"
  26. version="0.1"
  27. # Start Script #
  28. echo "Nextcloud Client Update Script v$version"
  29. # Check Arguments #
  30. if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
  31. helpFunction
  32. exit 0
  33. fi
  34. # Check if user-provided file is valid #
  35. if ! [ -f "$1" ]; then
  36. echo "$1 not found."
  37. helpFunction
  38. exit 1
  39. elif ! [ -f "$imagepath/$filename" ]; then
  40. echo "Moving $1 to $imagepath/"
  41. mv $1 $imagepath/
  42. echo "Done."
  43. fi
  44. if [ -z "$filename" ]
  45. then
  46. echo " "
  47. echo "No filename given. Aborting."
  48. helpFunction
  49. exit 1
  50. fi
  51. if [ "$USER" != "root" ]; then
  52. echo "Must be running as root to install new software. Use sudo or root user"
  53. helpFunction
  54. exit 1
  55. fi
  56. # Argument and file checking complete...#
  57. echo "Updating Nextcloud client..."
  58. # Ensure AppImage is Executable
  59. echo "Setting $filename as executable"
  60. sudo chmod +x $imagepath/$filename
  61. echo "Done."
  62. # Ensure symlink is set
  63. echo "Setting symlink /usr/local/bin/nextcloud/"
  64. ln -fs $imagepath/$filename $executablelink/nextcloud
  65. echo "Done."
  66. # Ensure Desktop file is set
  67. if ! [ -f "$projectdir/nextcloud.desktop" ]; then
  68. echo "WARNING: nextcloud.desktop file not found!"
  69. echo "WARNING: Desktop file not set!"
  70. exit 1
  71. fi
  72. echo "Setting nextcloud.desktop in /usr/local/share/applications and verifying permissions"
  73. ln -fs $projectdir/nextcloud.desktop $desktoppath/
  74. chmod +x $projectdir/nextcloud.desktop
  75. echo "Done."
  76. echo "Update Complete. Done."
  77. exit 0