|
| 1 | +#!/bin/bash |
| 2 | +# info: enable GeoIP2 in Awstats |
| 3 | +# |
| 4 | +# This function enables GeoIP2 location lookup for |
| 5 | +# IP addresses that are listed in awstats. |
| 6 | + |
| 7 | +#----------------------------------------------------------# |
| 8 | +# Variable&Function # |
| 9 | +#----------------------------------------------------------# |
| 10 | + |
| 11 | +# Includes |
| 12 | +# shellcheck source=/usr/local/hestia/func/main.sh |
| 13 | +source $HESTIA/func/main.sh |
| 14 | +# shellcheck source=/usr/local/hestia/conf/hestia.conf |
| 15 | +source $HESTIA/conf/hestia.conf |
| 16 | + |
| 17 | +#----------------------------------------------------------# |
| 18 | +# Verifications # |
| 19 | +#----------------------------------------------------------# |
| 20 | + |
| 21 | +#check if string already exists |
| 22 | +if grep "geoip2" $HESTIA/data/templates/web/awstats/awstats.tpl; then |
| 23 | + echo "Plugin allready enabled" |
| 24 | + exit 0 |
| 25 | +fi |
| 26 | + |
| 27 | +#----------------------------------------------------------# |
| 28 | +# Action # |
| 29 | +#----------------------------------------------------------# |
| 30 | + |
| 31 | +if [ -d /etc/awstats ]; then |
| 32 | + apt-get install make libssl-dev zlib1g-dev libdata-validate-ip-perl |
| 33 | + perl -MCPAN -f -e "GeoIP2::Database::Reader" |
| 34 | + sed -i '/LoadPlugin=\"geoip2_country \/pathto\/GeoLite2-Country.mmdb\"/s/^#//g;s/pathto/usr\/share\/GeoIP/g' /etc/awstats/awstats.conf |
| 35 | + echo "LoadPlugin=\"geoip2_country /usr/share/GeoIP/GeoLite2-Country.mmdb\"" >> $HESTIA/data/templates/web/awstats/awstats.tpl |
| 36 | + |
| 37 | + for user in $($BIN/v-list-sys-users plain); do |
| 38 | + $BIN/v-rebuild-web-domains $user no |
| 39 | + done |
| 40 | +fi |
| 41 | + |
| 42 | +#----------------------------------------------------------# |
| 43 | +# Hestia # |
| 44 | +#----------------------------------------------------------# |
| 45 | + |
| 46 | +# Logging |
| 47 | +log_history "Enabled GeoIP2 Awstats" '' 'admin' |
| 48 | +log_event "$OK" "$ARGUMENTS" |
| 49 | + |
| 50 | +exit 0 |
0 commit comments