v-delete-sys-filemanager 2.3 KB

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