v_add_web_domain_stat 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/bash
  2. # info: adding stats for domain
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user=$1
  8. domain=$(idn -t --quiet -u "$2" )
  9. domain_idn=$(idn -t --quiet -a "$domain")
  10. type=$3
  11. # Importing variables
  12. source $VESTA/conf/vars.conf
  13. source $V_CONF/vesta.conf
  14. source $V_FUNC/shared.func
  15. source $V_FUNC/domain.func
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. # Checking arg number
  20. check_args '3' "$#" 'user domain type'
  21. # Checking argument format
  22. format_validation 'user' 'domain'
  23. # Checking web system is enabled
  24. is_system_enabled 'web'
  25. # Checking user
  26. is_user_valid "$user"
  27. # Checking user is active
  28. is_user_suspended
  29. # Checking domain exist
  30. is_web_domain_valid
  31. # Checking domain is not suspened
  32. is_domain_suspended 'web'
  33. # Checking statistic type
  34. is_type_valid 'stat' "$type"
  35. # Check statistic is not added
  36. is_web_domain_key_empty '$STATS'
  37. #----------------------------------------------------------#
  38. # Action #
  39. #----------------------------------------------------------#
  40. # Parse aliases
  41. get_web_domain_values
  42. # Preparing domain values for the template substitution
  43. upd_web_domain_values
  44. # Adding statistic config
  45. cat $V_WEBTPL/$type.tpl |\
  46. sed -e "s/%ip%/$ip/g" \
  47. -e "s/%web_port%/$WEB_PORT/g" \
  48. -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
  49. -e "s/%proxy_port%/$PROXY_PORT/g" \
  50. -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
  51. -e "s/%domain_idn%/$domain_idn/g" \
  52. -e "s/%domain%/$domain/g" \
  53. -e "s/%user%/$user/g" \
  54. -e "s/%home%/${V_HOME////\/}/g" \
  55. -e "s/%alias%/${aliases//,/ }/g" \
  56. -e "s/%alias_idn%/${aliases_idn//,/ }/g" \
  57. > $V_HOME/$user/conf/$type.$domain.conf
  58. #----------------------------------------------------------#
  59. # Vesta #
  60. #----------------------------------------------------------#
  61. # Adding command to pipe
  62. echo "$V_BIN/v_upd_web_domain_stat $user $domain" >> $V_QUEUE/stats.pipe
  63. # Adding stats in config
  64. update_web_domain_value '$STATS' "$type"
  65. # Logging
  66. log_history "$V_EVENT" "v_del_web_domain_stat $user $domain"
  67. log_event 'system' "$V_EVENT"
  68. exit