v_upd_db_base_disk 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. # info: updating disk usage for databae
  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 web 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. # Get some variables we do not have now
  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) disk_usage=$(get_disk_db_mysql) ;;
  38. pgsql) disk_usage=$(get_disk_db_pgsql) ;;
  39. esac
  40. #----------------------------------------------------------#
  41. # Vesta #
  42. #----------------------------------------------------------#
  43. # Updating disk value in config
  44. update_db_base_value '$U_DISK' "$disk_usage"
  45. # Recalculating user disk space
  46. disk_size=$(get_usr_disk)
  47. update_user_value "$user" '$U_DISK' "$disk_size"
  48. # Logging
  49. log_event 'system' "$V_EVENT"
  50. exit $OK