v_upd_db_bases_disk 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. # info: updating disk usage for all databaes
  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 web 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) disk_usage=$(get_disk_db_mysql); ret_val="$?" ;;
  42. pgsql) disk_usage=$(get_disk_db_pgsql); ret_val="$?" ;;
  43. esac
  44. # Updating disk value in config
  45. if [ "$ret_val" -eq '0' ]; then
  46. update_db_base_value '$U_DISK' "$disk_usage"
  47. fi
  48. done
  49. #----------------------------------------------------------#
  50. # Vesta #
  51. #----------------------------------------------------------#
  52. # Recalculating user disk space
  53. disk_size=$(get_usr_disk)
  54. update_user_value "$user" '$U_DISK' "$disk_size"
  55. # Logging
  56. log_event 'system' "$V_EVENT"
  57. exit $OK