v-change-web-domain-stats 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/bash
  2. # info: change web domain statistics
  3. # options: USER DOMAIN TYPE
  4. #
  5. # The function of deleting site's system of statistics. Its type is
  6. # automatically chooses from client's configuration file.
  7. #----------------------------------------------------------#
  8. # Variable&Function #
  9. #----------------------------------------------------------#
  10. # Argument definition
  11. user=$1
  12. domain=$2
  13. type=$3
  14. # Includes
  15. source $VESTA/func/main.sh
  16. source $VESTA/func/domain.sh
  17. source $VESTA/conf/vesta.conf
  18. # Additional argument formatting
  19. format_domain
  20. format_domain_idn
  21. #----------------------------------------------------------#
  22. # Verifications #
  23. #----------------------------------------------------------#
  24. check_args '3' "$#" 'USER DOMAIN TYPE'
  25. is_format_valid 'user' 'domain'
  26. is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
  27. is_type_valid "$STATS_SYSTEM" "$type"
  28. is_object_valid 'user' 'USER' "$user"
  29. is_object_unsuspended 'user' 'USER' "$user"
  30. is_object_valid 'web' 'DOMAIN' "$domain"
  31. is_object_unsuspended 'web' 'DOMAIN' "$domain"
  32. is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS'
  33. #----------------------------------------------------------#
  34. # Action #
  35. #----------------------------------------------------------#
  36. # Defining statistic type
  37. get_domain_values 'web'
  38. # Comparing stats types
  39. if [ "$STATS" == $type ]; then
  40. log_event "$OK" "$ARGUMENTS"
  41. exit 0
  42. fi
  43. # Defining statistic dir
  44. stats_dir="$HOMEDIR/$user/web/$domain/stats"
  45. # Deleting dir content
  46. rm -rf $stats_dir/*
  47. # Deleting config
  48. rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf
  49. # Adding statistic config
  50. prepare_web_domain_values
  51. cat $WEBTPL/$type/$type.tpl |\
  52. sed -e "s/%ip%/$ip/g" \
  53. -e "s/%web_port%/$WEB_PORT/g" \
  54. -e "s/%web_system%/$WEB_SYSTEM/g" \
  55. -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
  56. -e "s/%rgroups%/$WEB_RGROUPS/g" \
  57. -e "s/%proxy_system%/$PROXY_SYSTEM/g" \
  58. -e "s/%proxy_port%/$PROXY_PORT/g" \
  59. -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
  60. -e "s/%domain_idn%/$domain_idn/g" \
  61. -e "s/%domain%/$domain/g" \
  62. -e "s/%user%/$user/g" \
  63. -e "s/%home%/${HOMEDIR////\/}/g" \
  64. -e "s/%alias%/${aliases//,/ }/g" \
  65. -e "s/%alias_idn%/${aliases_idn//,/ }/g" \
  66. > $HOMEDIR/$user/conf/web/$type.$domain.conf
  67. if [ "$type" == 'awstats' ]; then
  68. rm -f /etc/awstats/$type.$domain_idn.conf
  69. ln -s $HOMEDIR/$user/conf/web/$type.$domain.conf \
  70. /etc/awstats/$type.$domain_idn.conf
  71. else
  72. mkdir -p /var/lib/webalizer
  73. fi
  74. #----------------------------------------------------------#
  75. # Vesta #
  76. #----------------------------------------------------------#
  77. # Update config
  78. update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type"
  79. # Logging
  80. log_history "changed web log stats for $domain to $type"
  81. log_event "$OK" "$ARGUMENTS"
  82. # Build stats
  83. exec $BIN/v-update-web-domain-stat $user $domain
  84. exit