v-list-web-templates-proxy 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 defenition
  10. format=${1-shell}
  11. # Includes
  12. source $VESTA/conf/vesta.conf
  13. source $VESTA/func/main.sh
  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. templates=$(ls -t $WEBTPL/$PROXY_SYSTEM |\
  44. cut -f1 -d . |\
  45. grep -v proxy_ip |\
  46. sort -u )
  47. # Listing domains
  48. case $format in
  49. json) json_list_wtpl ;;
  50. plain) nohead=1; shell_list_wtpl ;;
  51. shell) shell_list_wtpl ;;
  52. *) check_args '1' '0' '[FORMAT]'
  53. esac
  54. #----------------------------------------------------------#
  55. # Vesta #
  56. #----------------------------------------------------------#
  57. exit