Skip to content

Commit 37a8d47

Browse files
committed
Resolving Geoip
1 parent 9bd84c9 commit 37a8d47

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
# info: enable GeoIP Awstats
3+
#
4+
# The function enables resolving IP addresses with the use of GeoIP database
5+
6+
7+
#----------------------------------------------------------#
8+
# Variable&Function #
9+
#----------------------------------------------------------#
10+
11+
# Includes
12+
source $HESTIA/func/main.sh
13+
source $HESTIA/conf/hestia.conf
14+
15+
16+
#----------------------------------------------------------#
17+
# Verifications #
18+
#----------------------------------------------------------#
19+
20+
#check if string already exists
21+
if grep "geoip" $HESTIA/data/templates/web/awstats/awstats.conf; then
22+
echo "Plugin allready enabled"
23+
exit 0
24+
fi
25+
26+
#----------------------------------------------------------#
27+
# Action #
28+
#----------------------------------------------------------#
29+
30+
if [ -d /etc/awstats ]; then
31+
perl -MCPAN -f -e "install Geo::IP::PurePerl"
32+
perl -MCPAN -f -e "install Geo::IP"
33+
sed -i '/LoadPlugin=\"geoip GEOIP_STANDARD \/usr\/share\/GeoIP\/GeoIP.dat\"/s/^#//g' /etc/awstats.conf
34+
echo "LoadPlugin=\"geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat\"" >> $HESTIA/data/templates/web/awstats/awstats.conf
35+
$HESTIA/bin/v-update-web-templates "yes"
36+
fi
37+
38+
#----------------------------------------------------------#
39+
# Hestia #
40+
#----------------------------------------------------------#
41+
42+
# Logging
43+
log_history "Enabled GeoIP Awstats" '' 'admin'
44+
log_event "$OK" "$ARGUMENTS"
45+
46+
exit 0

0 commit comments

Comments
 (0)