v_suspend_db_bases 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. # info: suspend databases
  3. # options: user
  4. #
  5. # The function for suspending of all databases of a single user.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. user=$1
  11. # Importing variables
  12. source $VESTA/conf/vars.conf
  13. source $V_CONF/vesta.conf
  14. source $V_FUNC/shared.func
  15. source $V_FUNC/db.func
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. # Checking arg number
  20. check_args '1' "$#" 'user'
  21. # Checking argument format
  22. format_validation 'user'
  23. # Checking db system is enabled
  24. is_system_enabled 'db'
  25. # Checking user
  26. is_user_valid
  27. #----------------------------------------------------------#
  28. # Action #
  29. #----------------------------------------------------------#
  30. # Defining config
  31. conf="$V_USERS/$user/db.conf"
  32. # Defining fileds to select
  33. field='$DB'
  34. # Defining search string
  35. search_string="SUSPEND='no'"
  36. # Parsing unsuspeneded domains
  37. databases=$(db_clear_search)
  38. for database in $databases; do
  39. # Define database variables
  40. db_user=$(get_db_value '$USER')
  41. host=$(get_db_value '$HOST')
  42. type=$(get_db_value '$TYPE')
  43. # Switching on db type
  44. case $type in
  45. mysql) suspend_db_mysql ;;
  46. pgsql) suspend_db_pgsql ;;
  47. esac
  48. # Updating db value
  49. update_db_base_value '$SUSPEND' 'yes'
  50. done
  51. #----------------------------------------------------------#
  52. # Vesta #
  53. #----------------------------------------------------------#
  54. # Logging
  55. log_event 'system' "$V_EVENT"
  56. exit