v-list-sys-pgsql-config 1.6 KB

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