v_suspend_db_base 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # info: Suspending databse
  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 db existance
  25. is_db_valid
  26. # Checking db is active
  27. is_db_suspended
  28. #----------------------------------------------------------#
  29. # Action #
  30. #----------------------------------------------------------#
  31. # Define database variables
  32. db_user=$(get_db_value '$USER')
  33. host=$(get_db_value '$HOST')
  34. type=$(get_db_value '$TYPE')
  35. # Switching on db type
  36. case $type in
  37. mysql) suspend_db_mysql ;;
  38. pgsql) suspend_db_pgsql ;;
  39. esac
  40. #----------------------------------------------------------#
  41. # Vesta #
  42. #----------------------------------------------------------#
  43. # Updating db value
  44. update_db_base_value '$SUSPEND' 'yes'
  45. # Logging
  46. log_event 'system' "$V_EVENT"
  47. exit $OK