Просмотр исходного кода

Merge pull request #817 from hestiacp/awstats-geoip

Awstats geoip
Raphael Schneeberger 5 лет назад
Родитель
Сommit
40726a4703
2 измененных файлов с 47 добавлено и 0 удалено
  1. 1 0
      CHANGELOG.md
  2. 46 0
      install/upgrade/manual/install_awstats_geoip.sh

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
 - Added support for configuring individual TTL per DNS record. Thanks to @jaapmarcus!
 - Added support for Ubuntu Server 20.04 LTS.
 - Added the ability to set the php cli version per user (using alias).
+- Added support for resolving ip addresses based on geoip database for Awstats 
 
 ### Bugfixes
 - Disable Apache2 Server Status Module by default.

+ 46 - 0
install/upgrade/manual/install_awstats_geoip.sh

@@ -0,0 +1,46 @@
+#!/bin/bash
+# info: enable GeoIP Awstats 
+#
+# The function enables resolving IP addresses  with the use of GeoIP database
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/conf/hestia.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+#check if string already exists
+if grep "geoip" $HESTIA/data/templates/web/awstats/awstats.conf; 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.conf
+    echo "LoadPlugin=\"geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat\"" >> $HESTIA/data/templates/web/awstats/awstats.conf
+    $HESTIA/bin/v-update-web-templates "yes"
+fi
+
+#----------------------------------------------------------#
+#                       Hestia                             #
+#----------------------------------------------------------#
+
+# Logging
+log_history "Enabled GeoIP Awstats" '' 'admin'
+log_event "$OK" "$ARGUMENTS"
+
+exit 0