v-list-database-types 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 defenition
  10. format=${1-shell}
  11. # Includes
  12. source $VESTA/func/main.sh
  13. source $VESTA/conf/vesta.conf
  14. # Json function
  15. json_list_dbtypes() {
  16. types=$(echo "${DB_SYSTEM//,/ }")
  17. t_counter=$(echo "$types" | wc -w)
  18. i=1
  19. echo '['
  20. for type in $types; do
  21. if [ "$i" -lt "$t_counter" ]; then
  22. echo -e "\t\"$type\","
  23. else
  24. echo -e "\t\"$type\""
  25. fi
  26. (( ++i))
  27. done
  28. echo "]"
  29. }
  30. # Shell function
  31. shell_list_dbtypes() {
  32. types=$(echo "${DB_SYSTEM//,/ }")
  33. if [ -z "$nohead" ]; then
  34. echo "TYPES"
  35. echo "----------"
  36. fi
  37. for type in $types; do
  38. echo "$type"
  39. done
  40. }
  41. #----------------------------------------------------------#
  42. # Action #
  43. #----------------------------------------------------------#
  44. # Listing domains
  45. case $format in
  46. json) json_list_dbtypes ;;
  47. plain) nohead=1; shell_list_dbtypes ;;
  48. shell) shell_list_dbtypes ;;
  49. *) check_args '1' '0' '[format]' ;;
  50. esac
  51. #----------------------------------------------------------#
  52. # Vesta #
  53. #----------------------------------------------------------#
  54. exit