v-delete-sys-filemanager 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. # info: remove file manager functionality from Hestia Control Panel
  3. # options: [FULL]
  4. # labels: hestia
  5. #
  6. # example: v-delete-sys-filemanager
  7. #
  8. # The function removes the File Manager and its entry points
  9. #----------------------------------------------------------#
  10. # Variable&Function #
  11. #----------------------------------------------------------#
  12. MODE=$1
  13. # Includes
  14. source $HESTIA/func/main.sh
  15. source $HESTIA/conf/hestia.conf
  16. user='admin'
  17. FM_INSTALL_DIR="$HESTIA/web/fm"
  18. FM_V="7.4.1"
  19. COMPOSER_BIN="$HOMEDIR/$user/.composer/composer"
  20. #----------------------------------------------------------#
  21. # Verifications #
  22. #----------------------------------------------------------#
  23. # Checking root permissions
  24. if [ "x$(id -u)" != 'x0' ]; then
  25. echo "Error: Script can be run executed only by root"
  26. exit 10
  27. fi
  28. # Ensure that $HESTIA (/usr/local/hestia/) and other variables are valid.
  29. if [ -z "$HESTIA" ]; then
  30. HESTIA="/usr/local/hestia"
  31. fi
  32. if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
  33. echo "Error: Hestia environment vars not present"
  34. exit 2
  35. fi
  36. # Perform verification if read-only mode is enabled
  37. check_hestia_demo_mode
  38. # Check if File Manager components are installed
  39. if [ "$MODE" != "force" ] && [ ! -e "$FM_INSTALL_DIR" ]; then
  40. echo "ERROR: File Manager components are not installed."
  41. exit 1
  42. fi
  43. if [ "$MODE" != "force" ] && [ "$FILE_MANGER" = "false" ]; then
  44. echo "ERROR: File Manager is not enabled."
  45. exit 1
  46. fi
  47. #----------------------------------------------------------#
  48. # Action #
  49. #----------------------------------------------------------#
  50. rm --recursive --force "$FM_INSTALL_DIR"
  51. $BIN/v-change-sys-config-value 'FILE_MANAGER' 'false'
  52. if [ "$MODE" != "quiet" ]; then
  53. echo "File Manager has been removed from the system."
  54. fi
  55. #----------------------------------------------------------#
  56. # Logging #
  57. #----------------------------------------------------------#
  58. log_history "file manager uninstalled" '' 'admin'
  59. log_event "$OK" "$ARGUMENTS"