1. 개요
Update GeoIP Database file
2. Source Code
#!/bin/bash ############################################ # Update GeoIP database # # Date : 2017.12.11. # # Maker : L.T # ############################################ # Set variable FILE_LOC="/webhome/e-bio/public_html/wp-content/uploads/GeoIP.dat" # Check log LOGFILE="/var/log/geoip.log" if [ ! -f $LOGFILE ]; then sudo touch $LOGFILE sudo chown ubuntu.ubuntu $LOGFILE fi # Download GeoIP database file NOWTIME=`date +'[%F %T]'` echo "$NOWTIME Download DB" >> $LOGFILE wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz -O /tmp/GeoIP.dat.gz -o /tmp/geoip_get.log cat /tmp/geoip_get.log >> $LOGFILE rm /tmp/geoip_get.log if [ -f /tmp/GeoIP.dat.gz ]; then NOWTIME=`date +'[%F %T]'` echo "$NOWTIME unzip FILE" >> $LOGFILE /bin/gunzip -f -d /tmp/GeoIP.dat.gz fi # Copy dat file if [ -f /tmp/GeoIP.dat ]; then NOWTIME=`date +'[%F %T]'` echo "$NOWTIME copy FILE($FILE_LOC)" >> $LOGFILE sudo /bin/mv -f $FILE_LOC $FILE_LOC\.past sudo /bin/mv /tmp/GeoIP.dat $FILE_LOC sudo chown e-bio.www-data $FILE_LOC sudo chmod 755 $FILE_LOG NOWTIME=`date +'[%F %T]'` echo "$NOWTIME Complete!" >> $LOGFILE fi echo "==============================" >> $LOGFILE