mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-28 05:46:36 +08:00
fix(agent): commit GeoLite2 mmdb as build fallback
Vendor GeoLite2-Country.mmdb in the repository so agent builds still work when the remote download is unavailable. Update the fetch script and agent Dockerfile to prefer a fresh download and fall back to the committed database file.
This commit is contained in:
@@ -6,11 +6,20 @@ TARGET="${ROOT}/internal/apps/agent/geoipdata/GeoLite2-Country.mmdb"
|
||||
URL="${GEOIP_MMDB_URL:-https://raw.githubusercontent.com/Loyalsoldier/geoip/release/GeoLite2-Country.mmdb}"
|
||||
|
||||
mkdir -p "$(dirname "$TARGET")"
|
||||
curl -fsSL -o "$TARGET" "$URL"
|
||||
|
||||
if [ ! -s "$TARGET" ]; then
|
||||
echo "downloaded GeoIP database is empty: $TARGET" >&2
|
||||
if curl -fsSL -o "${TARGET}.tmp" "$URL"; then
|
||||
mv "${TARGET}.tmp" "$TARGET"
|
||||
echo "GeoIP database downloaded: $TARGET"
|
||||
elif [ -s "$TARGET" ]; then
|
||||
rm -f "${TARGET}.tmp"
|
||||
echo "GeoIP download failed, using committed database: $TARGET"
|
||||
else
|
||||
rm -f "${TARGET}.tmp"
|
||||
echo "GeoIP database missing and download failed: $URL" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "GeoIP database ready: $TARGET"
|
||||
if [ ! -s "$TARGET" ]; then
|
||||
echo "GeoIP database is empty: $TARGET" >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user