forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_awstats_geoip.sh
More file actions
executable file
·50 lines (40 loc) · 1.69 KB
/
install_awstats_geoip.sh
File metadata and controls
executable file
·50 lines (40 loc) · 1.69 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
#!/bin/bash
# info: enable GeoIP Awstats
#
# This function enables GeoIP location lookup for
# IP addresses that are listed in awstats.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Includes
# shellcheck source=/usr/local/hestia/func/main.sh
source $HESTIA/func/main.sh
# shellcheck source=/usr/local/hestia/conf/hestia.conf
source $HESTIA/conf/hestia.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
#check if string already exists
if grep "geoip" $HESTIA/data/templates/web/awstats/awstats.tpl; then
echo "Plugin allready enabled"
exit 0
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
if [ -d /etc/awstats ]; then
perl -MCPAN -f -e "install Geo::IP::PurePerl"
perl -MCPAN -f -e "install Geo::IP"
sed -i '/LoadPlugin=\"geoip GEOIP_STANDARD \/usr\/share\/GeoIP\/GeoIP.dat\"/s/^#//g' /etc/awstats/awstats.conf
echo "LoadPlugin=\"geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat\"" >> $HESTIA/data/templates/web/awstats/awstats.tpl
for user in $($BIN/v-list-sys-users plain); do
$BIN/v-rebuild-web-domains $user no
done
fi
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
# Logging
log_history "Enabled GeoIP Awstats" '' 'admin'
log_event "$OK" "$ARGUMENTS"
exit 0