v-delete-database-host 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # info: delete database server
  3. # options: TYPE HOST
  4. # labels:
  5. #
  6. # example: v-delete-database-host pgsql localhost
  7. #
  8. # The function for deleting the database host from hestia configuration. It will
  9. # be deleted if there are no databases created on it only.
  10. #----------------------------------------------------------#
  11. # Variable&Function #
  12. #----------------------------------------------------------#
  13. # Argument definition
  14. type=$1
  15. host=$2
  16. # Includes
  17. # shellcheck source=/usr/local/hestia/func/main.sh
  18. source $HESTIA/func/main.sh
  19. # shellcheck source=/usr/local/hestia/func/db.sh
  20. source $HESTIA/func/db.sh
  21. # shellcheck source=/usr/local/hestia/conf/hestia.conf
  22. source $HESTIA/conf/hestia.conf
  23. #----------------------------------------------------------#
  24. # Verifications #
  25. #----------------------------------------------------------#
  26. check_args '2' "$#" 'TYPE HOST'
  27. is_format_valid 'type' 'host'
  28. is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
  29. is_type_valid "$DB_SYSTEM" "$type"
  30. is_object_valid "../../conf/$type" 'HOST' "$host"
  31. is_dbhost_free
  32. # Perform verification if read-only mode is enabled
  33. check_hestia_demo_mode
  34. #----------------------------------------------------------#
  35. # Action #
  36. #----------------------------------------------------------#
  37. # Deleting server
  38. sed -i "/HOST='$host' /d" $HESTIA/conf/$type.conf
  39. #----------------------------------------------------------#
  40. # Hestia #
  41. #----------------------------------------------------------#
  42. # Logging
  43. log_history "deleted $type database server $host" '' 'admin'
  44. log_event "$OK" "$ARGUMENTS"
  45. exit