File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,14 +12,32 @@ set -o errexit || exit $?
1212HERE=$( dirname " $0 " )
1313cd " ${HERE} "
1414
15+ GEOIP_FILE=" IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP"
16+ GEOIP_URL=" https://github.com/OpenRA/GeoIP-Database/releases/download/monthly/IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP"
17+ TIMEOUT_SECONDS=30
18+
1519# Database does not exist or is older than 30 days.
16- if [ -z " $( find . -path ./IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP -mtime -30 -print) " ]; then
17- rm -f IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP || :
18- echo " Downloading IP2Location GeoIP database."
20+ if [ -z " $( find . -path ./${GEOIP_FILE} -mtime -30 -print) " ]; then
21+ rm -f " ${GEOIP_FILE} " || :
22+ echo " Downloading IP2Location GeoIP database (timeout: ${TIMEOUT_SECONDS} s)..."
23+
24+ DOWNLOAD_SUCCESS=0
25+
1926 if command -v curl > /dev/null 2>&1 ; then
20- curl -s -L -O https://github.com/OpenRA/GeoIP-Database/releases/download/monthly/IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP || echo " Warning: Download failed"
21- else
22- wget -cq https://github.com/OpenRA/GeoIP-Database/releases/download/monthly/IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP || echo " Warning: Download failed"
27+ if curl --connect-timeout ${TIMEOUT_SECONDS} --max-time $(( TIMEOUT_SECONDS * 2 )) -s -L -o " ${GEOIP_FILE} " " ${GEOIP_URL} " 2> /dev/null; then
28+ DOWNLOAD_SUCCESS=1
29+ fi
30+ elif command -v wget > /dev/null 2>&1 ; then
31+ if wget --timeout=${TIMEOUT_SECONDS} -q -O " ${GEOIP_FILE} " " ${GEOIP_URL} " 2> /dev/null; then
32+ DOWNLOAD_SUCCESS=1
33+ fi
34+ fi
35+
36+ if [ " ${DOWNLOAD_SUCCESS} " -eq 0 ]; then
37+ echo " Warning: GeoIP database download failed or timed out."
38+ echo " Server will run without GeoIP country lookup."
39+ echo " You can manually download from: ${GEOIP_URL} "
40+ rm -f " ${GEOIP_FILE} " || :
2341 fi
2442fi
2543# changeCR2LF
You can’t perform that action at this time.
0 commit comments