myvesta/bin/v-change-web-domain-stats

109 lines
3.0 KiB
Plaintext
Raw Permalink Normal View History

2013-01-19 23:07:26 +02:00
#!/bin/bash
# info: change web domain statistics
# options: USER DOMAIN TYPE
#
# The function of deleting site's system of statistics. Its type is
# automatically chooses from client's configuration file.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
2015-11-06 17:38:58 +02:00
# Argument definition
2013-01-19 23:07:26 +02:00
user=$1
domain=$2
2017-03-05 23:34:07 +01:00
domain_idn=$2
2013-01-19 23:07:26 +02:00
type=$3
# Includes
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
source $VESTA/conf/vesta.conf
2013-01-19 23:07:26 +02:00
# Additional argument formatting
format_domain
format_domain_idn
2013-01-19 23:07:26 +02:00
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'USER DOMAIN TYPE'
2016-06-09 17:05:41 +03:00
is_format_valid 'user' 'domain'
2013-05-29 13:16:09 +03:00
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
2013-01-19 23:07:26 +02:00
is_type_valid "$STATS_SYSTEM" "$type"
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'
# Comparing stats types
if [ "$STATS" == $type ]; then
2016-06-09 17:05:41 +03:00
log_event "$OK" "$ARGUMENTS"
2013-01-19 23:07:26 +02:00
exit 0
fi
# 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
# Adding statistic config
2016-06-09 17:05:41 +03:00
prepare_web_domain_values
2013-04-03 23:18:51 +03:00
cat $WEBTPL/$type/$type.tpl |\
2013-01-19 23:07:26 +02:00
sed -e "s/%ip%/$ip/g" \
-e "s/%web_port%/$WEB_PORT/g" \
-e "s/%web_system%/$WEB_SYSTEM/g" \
2013-01-19 23:07:26 +02:00
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
-e "s/%rgroups%/$WEB_RGROUPS/g" \
-e "s/%proxy_system%/$PROXY_SYSTEM/g" \
2013-01-19 23:07:26 +02:00
-e "s/%proxy_port%/$PROXY_PORT/g" \
-e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
-e "s/%domain_idn%/$domain_idn/g" \
-e "s/%domain%/$domain/g" \
-e "s/%user%/$user/g" \
-e "s/%home%/${HOMEDIR////\/}/g" \
-e "s/%alias%/${aliases//,/ }/g" \
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \
> $HOMEDIR/$user/conf/web/$type.$domain.conf
2013-01-21 21:25:54 +02:00
if [ "$type" == 'awstats' ]; then
rm -f /etc/awstats/$type.$domain_idn.conf
2013-01-21 21:25:54 +02:00
ln -s $HOMEDIR/$user/conf/web/$type.$domain.conf \
/etc/awstats/$type.$domain_idn.conf
else
mkdir -p /var/lib/webalizer
2013-01-21 21:25:54 +02:00
fi
2013-01-19 23:07:26 +02:00
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Update config
update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type"
# Logging
log_history "changed web log stats for $domain to $type"
2016-06-09 17:05:41 +03:00
log_event "$OK" "$ARGUMENTS"
2013-01-19 23:07:26 +02:00
# Build stats
exec $BIN/v-update-web-domain-stat $user $domain
exit