v-list-sys-pgsql-config 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. # shellcheck source=/usr/local/hestia/func/main.sh
  16. source $HESTIA/func/main.sh
  17. # JSON list function
  18. json_list() {
  19. echo '{
  20. "CONFIG": {
  21. "pg_hba_path": "'$pg_hba_path'",
  22. "config_path": "'$config_path'"
  23. }
  24. }'
  25. }
  26. # SHELL list function
  27. shell_list() {
  28. echo "config_path: $config_path"
  29. echo "pg_hba_path: $pg_hba_path"
  30. }
  31. # PLAIN list function
  32. plain_list() {
  33. echo -e "$config_path\t$pg_hba_path"
  34. }
  35. # CSV list function
  36. csv_list() {
  37. echo "config_path,pg_hba_path"
  38. echo "$config_path,$pg_hba_path"
  39. }
  40. #----------------------------------------------------------#
  41. # Action #
  42. #----------------------------------------------------------#
  43. # Defining config path
  44. config_path=$(find /etc/postgresql /var/lib/pgsql/data -name \
  45. postgresql.conf 2>/dev/null)
  46. pg_hba_path=$(find /etc/postgresql /var/lib/pgsql/data -name \
  47. pg_hba.conf 2>/dev/null)
  48. # Listing data
  49. case $format in
  50. json) json_list ;;
  51. plain) plain_list ;;
  52. csv) csv_list ;;
  53. shell) shell_list;;
  54. esac
  55. #----------------------------------------------------------#
  56. # Hestia #
  57. #----------------------------------------------------------#
  58. exit