v_update_db_base_disk 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_CONF/vesta.conf
  12. source $V_FUNC/shared.func
  13. source $V_FUNC/db.func
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. # Checking arg number
  18. check_args '2' "$#" 'user db_name'
  19. # Checking argument format
  20. format_validation 'user' 'database'
  21. # Checking web system is enabled
  22. is_system_enabled 'db'
  23. # Checking user
  24. is_user_valid
  25. # Checking db existance
  26. is_db_valid
  27. # Checking db is active
  28. is_db_suspended
  29. #----------------------------------------------------------#
  30. # Action #
  31. #----------------------------------------------------------#
  32. # Get some variables we do not have now
  33. db_user=$(get_db_value '$USER')
  34. host=$(get_db_value '$HOST')
  35. type=$(get_db_value '$TYPE')
  36. # Switching on db type
  37. case $type in
  38. mysql) disk_usage=$(get_disk_db_mysql); ret_val="$?" ;;
  39. pgsql) disk_usage=$(get_disk_db_pgsql); ret_val="$?" ;;
  40. esac
  41. # Checking ret_val
  42. if [ "$ret_val" -ne '0' ]; then
  43. exit $ret_val
  44. fi
  45. #----------------------------------------------------------#
  46. # Vesta #
  47. #----------------------------------------------------------#
  48. # Updating disk value in config
  49. update_db_base_value '$U_DISK' "$disk_usage"
  50. # Recalculating user disk space
  51. disk_size=$(get_usr_disk)
  52. update_user_value "$user" '$U_DISK' "$disk_size"
  53. # Logging
  54. log_event 'system' "$V_EVENT"
  55. exit