Merge branch 'fix-changelogs' into 'main'
[tor.git] / scripts / maint / geoip / update_geoip.sh
blobc48f4b1b4531f1c38defa15eca4ae6dfdd5bb3c7
1 #!/bin/sh
3 set -e
5 DIR=$(cd "$(dirname "$0")" && pwd)
6 TMP=$(mktemp -d)
8 DB_PATH="/var/lib/location/database.db"
10 # In case it exists as a dead symlink.
11 if [ -h "$DB_PATH" ]; then
12 unlink "$DB_PATH"
13 elif [ -e "$DB_PATH" ]; then
14 rm -f "$DB_PATH"
17 curl -o "$DB_PATH.xz" "https://location.ipfire.org/databases/1/location.db.xz"
18 xz -d "$DB_PATH.xz"
19 location dump "$TMP/geoip-dump.txt"
21 OLDDIR=$(pwd)
22 cd "$DIR/geoip-db-tool/"
23 cargo build --release --target-dir "target"
24 cd "$OLDDIR"
26 "$DIR/geoip-db-tool/target/release/geoip-db-tool" -i "$TMP/geoip-dump.txt"