v-delete-database-host 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. source $HESTIA/func/main.sh
  18. source $HESTIA/func/db.sh
  19. source $HESTIA/conf/hestia.conf
  20. #----------------------------------------------------------#
  21. # Verifications #
  22. #----------------------------------------------------------#
  23. check_args '2' "$#" 'TYPE HOST'
  24. is_format_valid 'type' 'host'
  25. is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
  26. is_type_valid "$DB_SYSTEM" "$type"
  27. is_object_valid "../../conf/$type" 'HOST' "$host"
  28. is_dbhost_free
  29. # Perform verification if read-only mode is enabled
  30. check_hestia_demo_mode
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. # Deleting server
  35. sed -i "/HOST='$host' /d" $HESTIA/conf/$type.conf
  36. #----------------------------------------------------------#
  37. # Hestia #
  38. #----------------------------------------------------------#
  39. # Logging
  40. log_history "deleted $type database server $host" '' 'admin'
  41. log_event "$OK" "$ARGUMENTS"
  42. exit