v_add_web_domain_stat 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/bin/bash
  2. # info: add log analyzer to generate domain statitics
  3. # options: user domain type
  4. #
  5. # The call is used for enabling log analyzer system to a domain. At this time
  6. # two types of these system is supported - awstats and webalizer. For viewing
  7. # the domain statistics use http://domain.tld/vstats/ link. Access this page
  8. # is not protected by default. If you want to secure it with passwords you
  9. # should use v_add_web_domain_stat_auth script.
  10. #----------------------------------------------------------#
  11. # Variable&Function #
  12. #----------------------------------------------------------#
  13. # Argument defenition
  14. user=$1
  15. domain=$(idn -t --quiet -u "$2" )
  16. domain_idn=$(idn -t --quiet -a "$domain")
  17. type=$3
  18. # Importing variables
  19. source $VESTA/conf/vars.conf
  20. source $V_CONF/vesta.conf
  21. source $V_FUNC/shared.func
  22. source $V_FUNC/domain.func
  23. #----------------------------------------------------------#
  24. # Verifications #
  25. #----------------------------------------------------------#
  26. # Checking arg number
  27. check_args '3' "$#" 'user domain type'
  28. # Checking argument format
  29. format_validation 'user' 'domain'
  30. # Checking web system is enabled
  31. is_system_enabled 'web'
  32. # Checking user
  33. is_user_valid "$user"
  34. # Checking user is active
  35. is_user_suspended
  36. # Checking domain exist
  37. is_web_domain_valid
  38. # Checking domain is not suspened
  39. is_domain_suspended 'web'
  40. # Checking statistic type
  41. is_type_valid 'stat' "$type"
  42. # Check statistic is not added
  43. is_web_domain_key_empty '$STATS'
  44. #----------------------------------------------------------#
  45. # Action #
  46. #----------------------------------------------------------#
  47. # Parse aliases
  48. get_web_domain_values
  49. # Preparing domain values for the template substitution
  50. upd_web_domain_values
  51. # Adding statistic config
  52. cat $V_WEBTPL/$type.tpl |\
  53. sed -e "s/%ip%/$ip/g" \
  54. -e "s/%web_port%/$WEB_PORT/g" \
  55. -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
  56. -e "s/%proxy_port%/$PROXY_PORT/g" \
  57. -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
  58. -e "s/%domain_idn%/$domain_idn/g" \
  59. -e "s/%domain%/$domain/g" \
  60. -e "s/%user%/$user/g" \
  61. -e "s/%home%/${V_HOME////\/}/g" \
  62. -e "s/%alias%/${aliases//,/ }/g" \
  63. -e "s/%alias_idn%/${aliases_idn//,/ }/g" \
  64. > $V_HOME/$user/conf/$type.$domain.conf
  65. #----------------------------------------------------------#
  66. # Vesta #
  67. #----------------------------------------------------------#
  68. # Adding command to pipe
  69. echo "$V_BIN/v_update_web_domain_stat $user $domain" >> $V_QUEUE/stats.pipe
  70. # Adding stats in config
  71. update_web_domain_value '$STATS' "$type"
  72. # Logging
  73. log_history "$V_EVENT" "v_delete_web_domain_stat $user $domain"
  74. log_event 'system' "$V_EVENT"
  75. exit