| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #!/bin/bash
- # info: add log analyzer to generate domain statitics
- # options: user domain type
- #
- # The call is used for enabling log analyzer system to a domain. At this time
- # two types of these system is supported - awstats and webalizer. For viewing
- # the domain statistics use http://domain.tld/vstats/ link. Access this page
- # is not protected by default. If you want to secure it with passwords you
- # should use v_add_web_domain_stat_auth script.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Argument defenition
- user=$1
- domain=$(idn -t --quiet -u "$2" )
- domain_idn=$(idn -t --quiet -a "$domain")
- type=$3
- # Importing variables
- source $VESTA/conf/vars.conf
- source $V_CONF/vesta.conf
- source $V_FUNC/shared.func
- source $V_FUNC/domain.func
- #----------------------------------------------------------#
- # Verifications #
- #----------------------------------------------------------#
- # Checking arg number
- check_args '3' "$#" 'user domain type'
- # Checking argument format
- format_validation 'user' 'domain'
- # Checking web system is enabled
- is_system_enabled 'web'
- # Checking user
- is_user_valid "$user"
- # Checking user is active
- is_user_suspended
- # Checking domain exist
- is_web_domain_valid
- # Checking domain is not suspened
- is_domain_suspended 'web'
- # Checking statistic type
- is_type_valid 'stat' "$type"
- # Check statistic is not added
- is_web_domain_key_empty '$STATS'
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Parse aliases
- get_web_domain_values
- # Preparing domain values for the template substitution
- upd_web_domain_values
- # Adding statistic config
- cat $V_WEBTPL/$type.tpl |\
- sed -e "s/%ip%/$ip/g" \
- -e "s/%web_port%/$WEB_PORT/g" \
- -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
- -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%/${V_HOME////\/}/g" \
- -e "s/%alias%/${aliases//,/ }/g" \
- -e "s/%alias_idn%/${aliases_idn//,/ }/g" \
- > $V_HOME/$user/conf/$type.$domain.conf
- #----------------------------------------------------------#
- # Vesta #
- #----------------------------------------------------------#
- # Adding command to pipe
- echo "$V_BIN/v_update_web_domain_stat $user $domain" >> $V_QUEUE/stats.pipe
- # Adding stats in config
- update_web_domain_value '$STATS' "$type"
- # Logging
- log_history "$V_EVENT" "v_delete_web_domain_stat $user $domain"
- log_event 'system' "$V_EVENT"
- exit
|