2021-02-22 14:30:11 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
DIR=$(cd "$(dirname "$0")" && pwd)
|
|
|
|
TMP=$(mktemp -d)
|
|
|
|
|
2023-06-01 15:32:11 +02:00
|
|
|
DB_PATH="/var/lib/location/database.db"
|
|
|
|
|
|
|
|
# In case it exists as a dead symlink.
|
2023-08-30 14:40:44 +02:00
|
|
|
if [ -h "$DB_PATH" ]; then
|
2023-06-01 15:32:11 +02:00
|
|
|
unlink "$DB_PATH"
|
2023-08-30 14:40:44 +02:00
|
|
|
elif [ -e "$DB_PATH" ]; then
|
|
|
|
rm -f "$DB_PATH"
|
2023-06-01 15:32:11 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
curl -o "$DB_PATH.xz" "https://location.ipfire.org/databases/1/location.db.xz"
|
|
|
|
xz -d "$DB_PATH.xz"
|
2021-02-22 14:30:11 +01:00
|
|
|
location dump "$TMP/geoip-dump.txt"
|
|
|
|
|
|
|
|
OLDDIR=$(pwd)
|
|
|
|
cd "$DIR/geoip-db-tool/"
|
2023-08-04 16:04:36 +02:00
|
|
|
cargo build --release --target-dir "target"
|
2021-02-22 14:30:11 +01:00
|
|
|
cd "$OLDDIR"
|
|
|
|
|
|
|
|
"$DIR/geoip-db-tool/target/release/geoip-db-tool" -i "$TMP/geoip-dump.txt"
|