v_del_db_base 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. # info: Deleting data base
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user="$1"
  8. database="$2"
  9. # Importing variables
  10. source $VESTA/conf/vars.conf
  11. source $V_FUNC/shared_func.sh
  12. source $V_FUNC/db_func.sh
  13. #----------------------------------------------------------#
  14. # Verifications #
  15. #----------------------------------------------------------#
  16. # Checking arg number
  17. check_args '2' "$#" 'user db_name'
  18. # Checking argument format
  19. format_validation 'user' 'database'
  20. # Checking db system is enabled
  21. is_system_enabled 'db'
  22. # Checking user
  23. is_user_valid
  24. # Checking user is active
  25. is_user_suspended
  26. # Checking db existance
  27. is_db_valid
  28. # Checking db is active
  29. is_db_suspended
  30. #----------------------------------------------------------#
  31. # Action #
  32. #----------------------------------------------------------#
  33. # Get some variables we do not have now
  34. db_user=$(get_db_value '$USER')
  35. host=$(get_db_value '$HOST')
  36. type=$(get_db_value '$TYPE')
  37. # Switching on db type
  38. case $type in
  39. mysql) del_db_mysql ;;
  40. pgsql) del_db_pgsql ;;
  41. esac
  42. #----------------------------------------------------------#
  43. # Vesta #
  44. #----------------------------------------------------------#
  45. # Decreasing db value
  46. decrease_db_value
  47. # Decreasing domain value
  48. decrease_user_value "$user" '$U_DATABASES'
  49. # Deleting vesta db record
  50. del_db_vesta
  51. # Logging
  52. log_event 'system' "$V_EVENT"
  53. exit $OK