Created
May 13, 2015 10:14
-
-
Save datiti/b3825ec7cec002eec089 to your computer and use it in GitHub Desktop.
Update GeoIP database for xtables geoip module of iptables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# /usr/local/sbin/GeoIP_update | |
# | |
# Update geoip databases for xtables geoip module of iptables | |
# Last updated: 20150513 | |
# | |
XTABLESADDONS=/usr/lib/xtables-addons/ | |
XTABLEGEOIPDIR=/usr/share/xt_geoip/ | |
# the temporary directory to store geoip database | |
GEOIPDBDIR=/somedirectory | |
# goto geoip dir and download databases | |
cd ${GEOIPDBIR} | |
${XTABLESADDONS}/xt_geoip_dl | |
[ ! -f "./GeoIPCountryWhois.csv" ] && { echo "Error: GeoIPCountryWhois.csv file not found."; exit 1; } | |
[ ! -s "./GeoIPCountryWhois.csv" ] && { echo "Error: GeoIPCountryWhois.csv file is empty."; exit 1; } | |
# update xtables geoip databases | |
mkdir -p ${XTABLEGEOIPDIR} | |
${XTABLESADDONS}/xt_geoip_build -D ${XTABLEGEOIPDIR} GeoIPCountryWhois.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/cron.d/update_GeoIP | |
# Global variables | |
SHELL=/bin/bash | |
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin | |
[email protected] | |
HOME=/root | |
# To be executed as root at 4:25am each 5th and 10th day of month | |
25 4 5,10 * * root /usr/local/sbin/GeoIP_update | |
#25 4 5,10 * * root /usr/local/sbin/GeoIP_update >/dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment