v-delete-sys-filemanager 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. # shellcheck source=/usr/local/hestia/func/main.sh
  15. source $HESTIA/func/main.sh
  16. # shellcheck source=/usr/local/hestia/conf/hestia.conf
  17. source $HESTIA/conf/hestia.conf
  18. user='admin'
  19. FM_INSTALL_DIR="$HESTIA/web/fm"
  20. COMPOSER_BIN="$HOMEDIR/$user/.composer/composer"
  21. #----------------------------------------------------------#
  22. # Verifications #
  23. #----------------------------------------------------------#
  24. # Checking root permissions
  25. if [ "x$(id -u)" != 'x0' ]; then
  26. echo "Error: Script can be run executed only by root"
  27. exit 10
  28. fi
  29. # Ensure that $HESTIA (/usr/local/hestia/) and other variables are valid.
  30. if [ -z "$HESTIA" ]; then
  31. HESTIA="/usr/local/hestia"
  32. fi
  33. if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
  34. echo "Error: Hestia environment vars not present"
  35. exit 2
  36. fi
  37. # Perform verification if read-only mode is enabled
  38. check_hestia_demo_mode
  39. # Check if File Manager components are installed
  40. if [ "$MODE" != "force" ] && [ ! -e "$FM_INSTALL_DIR" ]; then
  41. echo "ERROR: File Manager components are not installed."
  42. exit 1
  43. fi
  44. if [ "$MODE" != "force" ] && [ "$FILE_MANGER" = "false" ]; then
  45. echo "ERROR: File Manager is not enabled."
  46. exit 1
  47. fi
  48. #----------------------------------------------------------#
  49. # Action #
  50. #----------------------------------------------------------#
  51. rm --recursive --force "$FM_INSTALL_DIR"
  52. $BIN/v-change-sys-config-value 'FILE_MANAGER' 'false'
  53. if [ "$MODE" != "quiet" ]; then
  54. echo "File Manager has been removed from the system."
  55. fi
  56. #----------------------------------------------------------#
  57. # Logging #
  58. #----------------------------------------------------------#
  59. log_history "file manager uninstalled" '' 'admin'
  60. log_event "$OK" "$ARGUMENTS"