v-list-web-templates-proxy 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. # info: listing proxy templates
  3. # options: [FORMAT]
  4. #
  5. # The function for obtaining the list of proxy templates available to a user.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. format=${1-shell}
  11. # Includes
  12. source $VESTA/func/main.sh
  13. source $VESTA/conf/vesta.conf
  14. # Json function
  15. json_list_wtpl() {
  16. t_counter=$(echo "$templates" | wc -w)
  17. i=1
  18. echo '['
  19. for template in $templates; do
  20. if [ "$i" -lt "$t_counter" ]; then
  21. echo -e "\t\"$template\","
  22. else
  23. echo -e "\t\"$template\""
  24. fi
  25. (( ++i))
  26. done
  27. echo "]"
  28. }
  29. # Shell function
  30. shell_list_wtpl() {
  31. if [ -z "$nohead" ]; then
  32. echo "Templates"
  33. echo "----------"
  34. fi
  35. for template in $templates; do
  36. echo "$template"
  37. done
  38. }
  39. #----------------------------------------------------------#
  40. # Action #
  41. #----------------------------------------------------------#
  42. # Proxy templates
  43. if [ -z "$PROXY_SYSTEM" ]; then
  44. exit
  45. fi
  46. templates=$(ls -t $WEBTPL/$PROXY_SYSTEM |\
  47. cut -f1 -d . |\
  48. grep -v proxy_ip |\
  49. sort -u )
  50. # Listing domains
  51. case $format in
  52. json) json_list_wtpl ;;
  53. plain) nohead=1; shell_list_wtpl ;;
  54. shell) shell_list_wtpl ;;
  55. *) check_args '1' '0' '[FORMAT]'
  56. esac
  57. #----------------------------------------------------------#
  58. # Vesta #
  59. #----------------------------------------------------------#
  60. exit