-
-
Save hwdsl2/fdc6f76a0bcd441cb933 to your computer and use it in GitHub Desktop.
IPTables GeoIP database monthly update script and cron job
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 | |
# /root/GeoIP_update.sh | |
ls /opt/src/xtables-addons-* >/dev/null 2>&1 | |
[ $? -ne 0 ] && { echo "Error: xtables-addons source folder not found."; exit 1; } | |
cd /opt/src/xtables-addons-* | |
cd geoip | |
./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; } | |
./xt_geoip_build GeoIPCountryWhois.csv | |
mkdir -p /usr/share/xt_geoip/ | |
cp -rf {BE,LE} /usr/share/xt_geoip/ |
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 | |
MAILTO=root | |
HOME=/ | |
25 4 5,10 * * root /root/GeoIP_update.sh >/dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment