v-delete-sys-filemanager 2.1 KB

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