v_list_db_bases 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # info: listing data bases
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user="$1"
  8. format="${2-shell}"
  9. limit="${3-1000}"
  10. offset="${4-1}"
  11. # Importing variables
  12. source $VESTA/conf/vars.conf
  13. source $V_FUNC/shared_func.sh
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. # Checking args
  18. check_args '1' "$#" 'user [format] [limit] [offset]'
  19. # Checking argument format
  20. format_validation 'user' 'limit' 'offset'
  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. fields='$DB $USER $HOST $TYPE $U_DISK $SUSPEND $DATE'
  30. # Listing databases
  31. case $format in
  32. json) v_json_list ;;
  33. shell) v_shell_list| column -t ;;
  34. *) check_args '1' "0" 'user [format] [limit] [offset]'
  35. esac
  36. #----------------------------------------------------------#
  37. # Vesta #
  38. #----------------------------------------------------------#
  39. # Logging
  40. log_event 'system' "$V_EVENT"
  41. exit $OK