install.sh 2.5 KB

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