v_upd_db_base_disk 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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); ret_val="$?" ;;
  38. pgsql) disk_usage=$(get_disk_db_pgsql); ret_val="$?" ;;
  39. esac
  40. # Checking ret_val
  41. if [ "$ret_val" -ne '0' ]; then
  42. exit $ret_val
  43. fi
  44. #----------------------------------------------------------#
  45. # Vesta #
  46. #----------------------------------------------------------#
  47. # Updating disk value in config
  48. update_db_base_value '$U_DISK' "$disk_usage"
  49. # Recalculating user disk space
  50. disk_size=$(get_usr_disk)
  51. update_user_value "$user" '$U_DISK' "$disk_size"
  52. # Logging
  53. log_event 'system' "$V_EVENT"
  54. exit $OK