v_delete_db_base 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_CONF/vesta.conf
  12. source $V_FUNC/shared.func
  13. source $V_FUNC/db.func
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. # Checking arg number
  18. check_args '2' "$#" 'user db_name'
  19. # Checking argument format
  20. format_validation 'user' 'database'
  21. # Checking db system is enabled
  22. is_system_enabled 'db'
  23. # Checking user
  24. is_user_valid
  25. # Checking user is active
  26. is_user_suspended
  27. # Checking db existance
  28. is_db_valid
  29. # Checking db is active
  30. is_db_suspended
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. # Get some variables we do not have now
  35. db_user=$(get_db_value '$USER')
  36. host=$(get_db_value '$HOST')
  37. type=$(get_db_value '$TYPE')
  38. # Switching on db type
  39. case $type in
  40. mysql) del_db_mysql ;;
  41. pgsql) del_db_pgsql ;;
  42. esac
  43. #----------------------------------------------------------#
  44. # Vesta #
  45. #----------------------------------------------------------#
  46. # Decreasing db value
  47. decrease_db_value
  48. # Decreasing domain value
  49. decrease_user_value "$user" '$U_DATABASES'
  50. # Deleting vesta db record
  51. del_db_vesta
  52. # Logging
  53. log_event 'system' "$V_EVENT"
  54. exit