v-list-sys-dovecot-config 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/bash
  2. # info: list dovecot config parameters
  3. # options: [FORMAT]
  4. #
  5. # The function for obtaining the list of dovecot 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. "config_path": "'$config_path'",
  18. "config_path1": "'$config_path1'",
  19. "config_path2": "'$config_path2'",
  20. "config_path3": "'$config_path3'",
  21. "config_path4": "'$config_path4'",
  22. "config_path5": "'$config_path5'",
  23. "config_path6": "'$config_path6'",
  24. "config_path7": "'$config_path7'",
  25. "config_path8": "'$config_path8'"
  26. }
  27. }'
  28. }
  29. # SHELL list function
  30. shell_list() {
  31. echo "config_path: $config_path"
  32. echo "config_path1: $config_path1"
  33. echo "config_path2: $config_path2"
  34. echo "config_path3: $config_path3"
  35. echo "config_path4: $config_path4"
  36. echo "config_path5: $config_path5"
  37. echo "config_path6: $config_path6"
  38. echo "config_path7: $config_path7"
  39. echo "config_path8: $config_path8"
  40. }
  41. # PLAIN list function
  42. plain_list() {
  43. echo -en "$config_path\t"
  44. echo -en "$config_path1\t"
  45. echo -en "$config_path2\t"
  46. echo -en "$config_path3\t"
  47. echo -en "$config_path4\t"
  48. echo -en "$config_path5\t"
  49. echo -en "$config_path6\t"
  50. echo -en "$config_path7\t"
  51. echo -e "$config_path8\t"
  52. }
  53. # CSV list function
  54. csv_list() {
  55. echo -n "config_path,config_path1,config_path2,config_path3,"
  56. echo "config_path4,config_path5,config_path6,config_path7,config_path8"
  57. echo -n "$config_path,$config_path1,$config_path2,$config_path3,"
  58. echo -n "$config_path4,$config_path5,$config_path6,$config_path7,"
  59. echo "$config_path8"
  60. }
  61. #----------------------------------------------------------#
  62. # Action #
  63. #----------------------------------------------------------#
  64. # Defining config path
  65. if [ -e '/etc/dovecot.conf' ]; then
  66. config_path='/etc/dovecot.conf'
  67. else
  68. config_path='/etc/dovecot/dovecot.conf'
  69. config_path1='/etc/dovecot/conf.d/10-auth.conf'
  70. config_path2='/etc/dovecot/conf.d/10-logging.conf'
  71. config_path3='/etc/dovecot/conf.d/10-mail.conf'
  72. config_path4='/etc/dovecot/conf.d/10-master.conf'
  73. config_path5='/etc/dovecot/conf.d/10-ssl.conf'
  74. config_path6='/etc/dovecot/conf.d/20-imap.conf'
  75. config_path7='/etc/dovecot/conf.d/20-pop3.conf'
  76. config_path8='/etc/dovecot/conf.d/auth-passwdfile.conf.ext'
  77. fi
  78. # Listing data
  79. case $format in
  80. json) json_list ;;
  81. plain) plain_list ;;
  82. csv) csv_list ;;
  83. shell) shell_list;;
  84. esac
  85. #----------------------------------------------------------#
  86. # Vesta #
  87. #----------------------------------------------------------#
  88. exit