mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-28 05:46:36 +08:00
570b639e07
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.
25 lines
734 B
Bash
Executable File
25 lines
734 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
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")"
|
|
|
|
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
|
|
|
|
if [ ! -s "$TARGET" ]; then
|
|
echo "GeoIP database is empty: $TARGET" >&2
|
|
exit 1
|
|
fi |