myvesta/bin/v-delete-web-domain-stats
2012-11-09 18:26:32 +02:00

68 lines
1.9 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" )
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'user domain'
validate_format 'user' 'domain'
is_system_enabled "$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 $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