v-delete-web-domain-stats 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. # info: delete web domain statistics
  3. # options: user domain
  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 defenition
  11. user=$1
  12. domain=$(idn -t --quiet -u "$2" )
  13. # Includes
  14. source $VESTA/conf/vesta.conf
  15. source $VESTA/func/main.sh
  16. source $VESTA/func/domain.sh
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. check_args '2' "$#" 'user domain'
  21. validate_format 'user' 'domain'
  22. is_system_enabled "$WEB_SYSTEM"
  23. is_object_valid 'user' 'USER' "$user"
  24. is_object_unsuspended 'user' 'USER' "$user"
  25. is_object_valid 'web' 'DOMAIN' "$domain"
  26. is_object_unsuspended 'web' 'DOMAIN' "$domain"
  27. is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS'
  28. #----------------------------------------------------------#
  29. # Action #
  30. #----------------------------------------------------------#
  31. # Defining statistic type
  32. get_domain_values 'web'
  33. # Defining statistic dir
  34. stats_dir="$HOMEDIR/$user/web/$domain/stats"
  35. # Deleting dir content
  36. rm -rf $stats_dir/*
  37. # Deleting config
  38. rm -f /etc/awstats/$STATS.$domain.conf
  39. rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf
  40. #----------------------------------------------------------#
  41. # Vesta #
  42. #----------------------------------------------------------#
  43. # Deleting pipe command
  44. sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe
  45. # Update config
  46. update_object_value 'web' 'DOMAIN' "$domain" '$STATS' ''
  47. # Logging
  48. log_history "disabled web log analyzer for $domain"
  49. log_event "$OK" "$EVENT"
  50. exit