v_suspend_db_bases 1.7 KB

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