v_delete_db_host 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # info: delete database serve
  3. # options: type host
  4. #
  5. # The function for deleting the database host from vesta configuration. It will
  6. # be deleted if there are no databases created on it only.
  7. #----------------------------------------------------------#
  8. # Variable&Function #
  9. #----------------------------------------------------------#
  10. # Argument defenition
  11. type=$1
  12. host=$2
  13. # Importing variables
  14. source $VESTA/conf/vesta.conf
  15. source $VESTA/func/shared.sh
  16. source $VESTA/func/db.sh
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. # Checking arg number
  21. check_args '2' "$#" 'type host'
  22. # Checking argument format
  23. validate_format 'host'
  24. # Checking db system is enabled
  25. is_system_enabled 'DB_SYSTEM'
  26. # Checking db type
  27. is_type_valid "$DB_SYSTEM" "$type"
  28. # Checking host existance
  29. is_db_host_valid
  30. # Checking db host users
  31. is_db_host_free
  32. #----------------------------------------------------------#
  33. # Action #
  34. #----------------------------------------------------------#
  35. # Deleting host from conf
  36. del_dbhost_vesta
  37. #----------------------------------------------------------#
  38. # Vesta #
  39. #----------------------------------------------------------#
  40. # Logging
  41. log_event "$OK" "$EVENT"
  42. exit