v-list-sys-webmail 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. # info: listing available webmail clients
  3. # options: [FORMAT]
  4. # labels: hestia mail
  5. #
  6. # example: v-list-sys-webmail
  7. #
  8. # List available webmail clients
  9. #----------------------------------------------------------#
  10. # Variable&Function #
  11. #----------------------------------------------------------#
  12. # Argument definition
  13. format=${1-shell}
  14. # Includes
  15. source $HESTIA/func/main.sh
  16. source $HESTIA/conf/hestia.conf
  17. # JSON list function
  18. json_list() {
  19. i=1
  20. objects=$(echo -e "${WEBMAIL_SYSTEM//,/\\n}" |wc -l)
  21. echo '['
  22. for client in ${WEBMAIL_SYSTEM//,/ };do
  23. if [ "$i" -ne "$objects" ]; then
  24. echo -e "\t\"$client\","
  25. else
  26. echo -e "\t\"$client\""
  27. fi
  28. (( ++i))
  29. done
  30. echo ']'
  31. }
  32. # SHELL list function
  33. shell_list() {
  34. echo "Webmail Client"
  35. echo "--------"
  36. for client in ${WEBMAIL_SYSTEM//,/ };do
  37. echo "$client"
  38. done
  39. }
  40. # PLAIN list function
  41. plain_list() {
  42. for client in ${WEBMAIL_SYSTEM//,/ };do
  43. echo "$client"
  44. done
  45. }
  46. # CSV list function
  47. csv_list() {
  48. echo "CLIENT"
  49. for client in ${WEBMAIL_SYSTEM//,/ };do
  50. echo "$client"
  51. done
  52. }
  53. #----------------------------------------------------------#
  54. # Action #
  55. #----------------------------------------------------------#
  56. # Listing data
  57. case $format in
  58. json) json_list ;;
  59. plain) plain_list ;;
  60. csv) csv_list ;;
  61. shell) shell_list ;;
  62. esac
  63. #----------------------------------------------------------#
  64. # Hestia #
  65. #----------------------------------------------------------#
  66. exit