v-delete-web-domain-stats 2.0 KB

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