v-delete-database-host 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. # info: delete database server
  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. # Includes
  14. source $VESTA/func/main.sh
  15. source $VESTA/func/db.sh
  16. source $VESTA/conf/vesta.conf
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. check_args '2' "$#" 'TYPE HOST'
  21. validate_format 'type' 'host'
  22. is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
  23. is_type_valid "$DB_SYSTEM" "$type"
  24. is_object_valid "../../conf/$type" 'HOST' "$host"
  25. is_dbhost_free
  26. #----------------------------------------------------------#
  27. # Action #
  28. #----------------------------------------------------------#
  29. # Deleting server
  30. sed -i "/HOST='$host' /d" $VESTA/conf/$type.conf
  31. #----------------------------------------------------------#
  32. # Vesta #
  33. #----------------------------------------------------------#
  34. # Logging
  35. log_history "deleted $type database server $host" '' 'admin'
  36. log_event "$OK" "$EVENT"
  37. exit