v_add_web_domain_stat 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_domains'
  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. # Adding statistic config
  41. cat $V_WEBTPL/$type.tpl |\
  42. sed -e "s/%ip%/$ip/g" | \
  43. sed -e "s/%port%/$port/g" | \
  44. sed -e "s/%domain_idn%/$domain_idn/g" | \
  45. sed -e "s/%domain%/$domain/g" | \
  46. sed -e "s/%user%/$user/g" | \
  47. sed -e "s/%home%/${V_HOME////\/}/g" | \
  48. sed -e "s/%alias%/$domain_aliases/g" \
  49. >$V_HOME/$user/conf/$type.$domain.conf
  50. #----------------------------------------------------------#
  51. # Vesta #
  52. #----------------------------------------------------------#
  53. # Switching on command string for pipe
  54. case $type in
  55. webalizer) command="webalizer -c $V_HOME/$user/conf/$type.$domain.conf";;
  56. awstats ) command="" # FIXME awstats command;;
  57. esac
  58. # Adding command to pipe
  59. echo "$command" >> $V_QUEUE/stats.pipe
  60. # Adding stats in config
  61. update_web_domain_value '$STATS' "$type"
  62. # Logging
  63. log_history "$V_EVENT" "v_del_web_domain_stat $user $domain"
  64. log_event 'system' "$V_EVENT"
  65. exit $OK