v-list-sys-pgsql-config 1.6 KB

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