v-list-database-types 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. # info: list supported database types
  3. # options: [FORMAT]
  4. #
  5. # The function for obtaining the list of database types.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. format=${1-shell}
  11. # Includes
  12. source $VESTA/func/main.sh
  13. source $VESTA/conf/vesta.conf
  14. # JSON list function
  15. json_list() {
  16. objects=$(echo "${DB_SYSTEM//,/ }" |wc -w)
  17. i=1
  18. echo '['
  19. for type in ${DB_SYSTEM//,/ }; do
  20. echo -n ' "'$type'"'
  21. if [ "$i" -lt "$objects" ]; then
  22. echo ','
  23. else
  24. echo
  25. fi
  26. ((i++))
  27. done
  28. echo "]"
  29. }
  30. # SHELL list function
  31. shell_list() {
  32. echo -e "TYPE\n----"
  33. echo "$DB_SYSTEM" |sed -e "s/,/\n/"
  34. }
  35. # PLAIN list function
  36. plain_list() {
  37. for type in ${DB_SYSTEM//,/ }; do
  38. echo "$type"
  39. done
  40. }
  41. # CSV list function
  42. csv_list() {
  43. echo "TYPE"
  44. for type in ${DB_SYSTEM//,/ }; do
  45. echo "$type"
  46. done
  47. }
  48. #----------------------------------------------------------#
  49. # Action #
  50. #----------------------------------------------------------#
  51. # Listing data
  52. case $format in
  53. json) json_list ;;
  54. plain) plain_list ;;
  55. csv) csv_list ;;
  56. shell) shell_list;;
  57. esac
  58. #----------------------------------------------------------#
  59. # Vesta #
  60. #----------------------------------------------------------#
  61. exit