forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv_add_web_domain_stats
More file actions
executable file
·83 lines (65 loc) · 2.65 KB
/
v_add_web_domain_stats
File metadata and controls
executable file
·83 lines (65 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/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
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'user domain type'
validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM"
is_type_valid "$STATS_SYSTEM" "$type"
is_object_valid 'user' 'USER' "$user" "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_empty 'web' 'DOMAIN' "$domain" '$STATS'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Parse aliases
get_domain_values 'web'
# Preparing domain values for the template substitution
upd_web_domain_values
# Adding statistic config
cat $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%/${HOMEDIR////\/}/g" \
-e "s/%alias%/${aliases//,/ }/g" \
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \
> $HOMEDIR/$user/conf/web/$type.$domain.conf
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Schedule statistic processing
echo "$BIN/v_update_web_domain_stat $user $domain" >> $V_QUEUE/stats.pipe
# Update config
update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type"
# Logging
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit