v-list-sys-pgsql-config 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. # info: list postgresql config parameters
  3. # options: [FORMAT]
  4. #
  5. # The function for obtaining the list of postgresql config parameters.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. format=${1-shell}
  11. # Includes
  12. source $VESTA/func/main.sh
  13. # JSON list function
  14. json_list() {
  15. echo '{
  16. "CONFIG": {
  17. "pg_hba_path": "'$pg_hba_path'",
  18. "config_path": "'$config_path'"
  19. }
  20. }'
  21. }
  22. # SHELL list function
  23. shell_list() {
  24. echo "config_path: $config_path"
  25. echo "pg_hba_path: $pg_hba_path"
  26. }
  27. # PLAIN list function
  28. plain_list() {
  29. echo -e "$config_path\t$pg_hba_path"
  30. }
  31. # CSV list function
  32. csv_list() {
  33. echo "config_path,pg_hba_path"
  34. echo "$config_path,$pg_hba_path"
  35. }
  36. #----------------------------------------------------------#
  37. # Action #
  38. #----------------------------------------------------------#
  39. # Defining config path
  40. config_path=$(find /etc/postgresql /var/lib/pgsql/data -name \
  41. postgresql.conf 2>/dev/null)
  42. pg_hba_path=$(find /etc/postgresql /var/lib/pgsql/data -name \
  43. pg_hba.conf 2>/dev/null)
  44. # Listing data
  45. case $format in
  46. json) json_list ;;
  47. plain) plain_list ;;
  48. csv) csv_list ;;
  49. shell) shell_list;;
  50. esac
  51. #----------------------------------------------------------#
  52. # Vesta #
  53. #----------------------------------------------------------#
  54. exit