v_list_db_base 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # info: listing data base
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user="$1"
  8. database="$2"
  9. format="${3-shell}"
  10. # Importing variables
  11. source $VESTA/conf/vars.conf
  12. source $V_FUNC/shared_func.sh
  13. source $V_FUNC/db_func.sh
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. # Checking args
  18. check_args '2' "$#" 'user db_name [format]'
  19. # Checking argument format
  20. format_validation 'user' 'database'
  21. # Checking user
  22. is_user_valid
  23. # Checking database exist
  24. is_db_valid
  25. #----------------------------------------------------------#
  26. # Action #
  27. #----------------------------------------------------------#
  28. # Defining config
  29. conf="$V_USERS/$user/db.conf"
  30. # Defining fileds to select
  31. fields='$DB $USER $HOST $TYPE $U_DISK $SUSPEND $DATE'
  32. # Listing database
  33. case $format in
  34. json) db_json_single_list ;;
  35. shell) db_shell_single_list | column -t ;;
  36. *) check_args '2' "0" 'user database [format]'
  37. esac
  38. #----------------------------------------------------------#
  39. # Vesta #
  40. #----------------------------------------------------------#
  41. # Logging
  42. log_event 'system' "$V_EVENT"
  43. exit $OK