Skip to content

Commit a0d24d2

Browse files
author
Kristan Kenney
committed
Merge branch 'fix-awstats'
2 parents d489b4c + 54e9416 commit a0d24d2

File tree

3 files changed

+40
-33
lines changed

3 files changed

+40
-33
lines changed

bin/v-add-web-domain-stats

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ get_domain_values 'web'
5555

5656
# Adding statistic config
5757
prepare_web_domain_values
58+
59+
if [ -z "${aliases//,/ }" ]; then
60+
stats_alias="localhost"
61+
else
62+
stats_alias=${aliases_idn//,/ }
63+
fi
64+
5865
cat $WEBTPL/$type/$type.tpl |\
5966
sed -e "s|%ip%|$ip|g" \
6067
-e "s|%web_port%|$WEB_PORT|g" \
@@ -69,7 +76,7 @@ cat $WEBTPL/$type/$type.tpl |\
6976
-e "s|%user%|$user|g" \
7077
-e "s|%home%|$HOMEDIR|g" \
7178
-e "s|%alias%|${aliases//,/ }|g" \
72-
-e "s|%alias_idn%|${aliases_idn//,/ }|g" \
79+
-e "s|%alias_idn%|$stats_alias|g" \
7380
> $HOMEDIR/$user/conf/web/$domain/$type.conf
7481

7582
if [ "$type" == 'awstats' ]; then

bin/v-change-web-domain-stats

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ is_object_valid 'user' 'USER' "$user"
3838
is_object_unsuspended 'user' 'USER' "$user"
3939
is_object_valid 'web' 'DOMAIN' "$domain"
4040
is_object_unsuspended 'web' 'DOMAIN' "$domain"
41-
is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS'
4241

4342
# Perform verification if read-only mode is enabled
4443
check_hestia_demo_mode
@@ -48,50 +47,44 @@ check_hestia_demo_mode
4847
# Action #
4948
#----------------------------------------------------------#
5049

51-
# Defining statistic type
50+
# Parse aliases
5251
get_domain_values 'web'
5352

54-
# Comparing stats types
55-
if [ "$STATS" == $type ]; then
56-
log_event "$OK" "$ARGUMENTS"
57-
exit 0
58-
fi
59-
60-
# Defining statistic dir
61-
stats_dir="$HOMEDIR/$user/web/$domain/stats"
62-
63-
# Deleting dir content
64-
rm -rf $stats_dir/*
65-
6653
# Deleting config
67-
rm -f $HOMEDIR/$user/conf/web/$domain/$STATS.conf
54+
rm -f $HOMEDIR/$user/conf/web/$domain/$type.conf
6855

6956
# Adding statistic config
7057
prepare_web_domain_values
58+
59+
if [ -z "${aliases//,/ }" ]; then
60+
stats_alias="localhost"
61+
else
62+
stats_alias=${aliases_idn//,/ }
63+
fi
64+
7165
cat $WEBTPL/$type/$type.tpl |\
72-
sed -e "s/%ip%/$ip/g" \
73-
-e "s/%web_port%/$WEB_PORT/g" \
74-
-e "s/%web_system%/$WEB_SYSTEM/g" \
75-
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
76-
-e "s/%rgroups%/$WEB_RGROUPS/g" \
77-
-e "s/%proxy_system%/$PROXY_SYSTEM/g" \
78-
-e "s/%proxy_port%/$PROXY_PORT/g" \
79-
-e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
80-
-e "s/%domain_idn%/$domain_idn/g" \
81-
-e "s/%domain%/$domain/g" \
82-
-e "s/%user%/$user/g" \
83-
-e "s/%home%/${HOMEDIR////\/}/g" \
84-
-e "s/%alias%/${aliases//,/ }/g" \
85-
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \
86-
> $HOMEDIR/$user/conf/web/$type.$domain.conf
66+
sed -e "s|%ip%|$ip|g" \
67+
-e "s|%web_port%|$WEB_PORT|g" \
68+
-e "s|%web_system%|$WEB_SYSTEM|g" \
69+
-e "s|%web_ssl_port%|$WEB_SSL_PORT|g" \
70+
-e "s|%rgroups%|$WEB_RGROUPs|g" \
71+
-e "s|%proxy_system%|$PROXY_SYSTEM|g" \
72+
-e "s|%proxy_port%|$PROXY_PORT|g" \
73+
-e "s|%proxy_ssl_port%|$PROXY_SSL_PORT|g" \
74+
-e "s|%domain_idn%|$domain_idn|g" \
75+
-e "s|%domain%|$domain|g" \
76+
-e "s|%user%|$user|g" \
77+
-e "s|%home%|$HOMEDIR|g" \
78+
-e "s|%alias%|${aliases//,/ }|g" \
79+
-e "s|%alias_idn%|$stats_alias|g" \
80+
> $HOMEDIR/$user/conf/web/$domain/$type.conf
8781

8882
if [ "$type" == 'awstats' ]; then
8983
rm -f /etc/awstats/$type.$domain_idn.conf
90-
ln -s $HOMEDIR/$user/conf/web/$type.$domain.conf \
84+
ln -s $HOMEDIR/$user/conf/web/$domain/$type.conf \
9185
/etc/awstats/$type.$domain_idn.conf
9286
fi
9387

94-
9588
#----------------------------------------------------------#
9689
# Hestia #
9790
#----------------------------------------------------------#

web/edit/web/index.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@
244244
}
245245
}
246246
}
247+
if ((!empty($v_stats)) && ($_POST['v_stats'] == $v_stats) && (empty($_SESSION['error_msg']))) {
248+
// Update statistics configuration when changing domain aliases
249+
$v_stats = escapeshellarg($_POST['v_stats']);
250+
exec (HESTIA_CMD."v-change-web-domain-stats ".$v_username." ".escapeshellarg($v_domain)." ".$v_stats, $output, $return_var);
251+
check_return_code($return_var,$output);
252+
unset($output);
253+
}
247254
}
248255

249256
// Change backend template

0 commit comments

Comments
 (0)