v_add_web_domain_stat 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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_FUNC/shared_func.sh
  14. source $V_FUNC/domain_func.sh
  15. #----------------------------------------------------------#
  16. # Verifications #
  17. #----------------------------------------------------------#
  18. # Checking arg number
  19. check_args '3' "$#" 'user domain type'
  20. # Checking argument format
  21. format_validation 'user' 'domain'
  22. # Checking web system is enabled
  23. is_system_enabled 'web'
  24. check_func_result $?
  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. aliases=$(get_web_domain_value '$ALIAS')
  42. aliases_idn=$(idn -t --quiet -a "$aliases")
  43. # Adding statistic config
  44. cat $V_WEBTPL/$type.tpl |\
  45. sed -e "s/%ip%/$ip/g" \
  46. -e "s/%port%/$port/g" \
  47. -e "s/%domain_idn%/$domain_idn/g" \
  48. -e "s/%domain%/$domain/g" \
  49. -e "s/%user%/$user/g" \
  50. -e "s/%home%/${V_HOME////\/}/g" \
  51. -e "s/%alias%/${aliases//,/ }/g" \
  52. -e "s/%alias_idn%/${aliases_idn//,/ }/g" \
  53. > $V_HOME/$user/conf/$type.$domain.conf
  54. #----------------------------------------------------------#
  55. # Vesta #
  56. #----------------------------------------------------------#
  57. # Adding command to pipe
  58. echo "$V_BIN/v_upd_web_domain_stat $user $domain" >> $V_QUEUE/stats.pipe
  59. # Adding stats in config
  60. update_web_domain_value '$STATS' "$type"
  61. # Logging
  62. log_history "$V_EVENT" "v_del_web_domain_stat $user $domain"
  63. log_event 'system' "$V_EVENT"
  64. exit $OK