myvesta/bin/v-delete-web-domain-stats
2013-10-09 00:50:08 +03:00

71 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# info: delete web domain statistics
# options: USER DOMAIN
#
# The function of deleting site's system of statistics. Its type is
# automatically chooses from client's configuration file.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
# Includes
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining statistic type
get_domain_values 'web'
# Defining statistic dir
stats_dir="$HOMEDIR/$user/web/$domain/stats"
# Deleting dir content
rm -rf $stats_dir/*
# Deleting config
rm -f /etc/awstats/$STATS.$domain_idn.conf
rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Deleting pipe command
sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe
# Update config
update_object_value 'web' 'DOMAIN' "$domain" '$STATS' ''
# Logging
log_history "disabled web log analyzer for $domain"
log_event "$OK" "$EVENT"
exit