install_awstats_geoip.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. # info: enable GeoIP Awstats
  3. #
  4. # The function enables resolving IP addresses with the use of GeoIP database
  5. #----------------------------------------------------------#
  6. # Variable&Function #
  7. #----------------------------------------------------------#
  8. # Includes
  9. source $HESTIA/func/main.sh
  10. source $HESTIA/conf/hestia.conf
  11. #----------------------------------------------------------#
  12. # Verifications #
  13. #----------------------------------------------------------#
  14. #check if string already exists
  15. if grep "geoip" $HESTIA/data/templates/web/awstats/awstats.tpl; then
  16. echo "Plugin allready enabled"
  17. exit 0
  18. fi
  19. #----------------------------------------------------------#
  20. # Action #
  21. #----------------------------------------------------------#
  22. if [ -d /etc/awstats ]; then
  23. perl -MCPAN -f -e "install Geo::IP::PurePerl"
  24. perl -MCPAN -f -e "install Geo::IP"
  25. sed -i '/LoadPlugin=\"geoip GEOIP_STANDARD \/usr\/share\/GeoIP\/GeoIP.dat\"/s/^#//g' /etc/awstats/awstats.conf
  26. echo "LoadPlugin=\"geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat\"" >> $HESTIA/data/templates/web/awstats/awstats.tpl
  27. for user in $($BIN/v-list-sys-users plain); do
  28. $BIN/v-rebuild-web-domains $user no
  29. done
  30. fi
  31. #----------------------------------------------------------#
  32. # Hestia #
  33. #----------------------------------------------------------#
  34. # Logging
  35. log_history "Enabled GeoIP Awstats" '' 'admin'
  36. log_event "$OK" "$ARGUMENTS"
  37. exit 0