-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathupdate-data.sh
More file actions
executable file
·26 lines (19 loc) · 880 Bytes
/
Copy pathupdate-data.sh
File metadata and controls
executable file
·26 lines (19 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(dirname "$0")"
ROOT_DIR="${SCRIPT_DIR}/.."
DATA_DIR="${ROOT_DIR}/data"
UA_REGEXES_URL="https://raw.githubusercontent.com/ua-parser/uap-core/master/regexes.yaml"
SPAMMERS_URL="https://raw.githubusercontent.com/matomo-org/referrer-spam-list/refs/heads/master/spammers.txt"
for tool in curl yq zstd; do
if ! command -v "$tool" >/dev/null 2>&1; then
printf 'missing required tool: %s\n' "$tool" >&2
exit 1
fi
done
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT
curl -fsSL "$UA_REGEXES_URL" -o "$tmp_dir/regexes.yaml"
yq '.' "$tmp_dir/regexes.yaml" | zstd --quiet --force -o "$DATA_DIR/ua_regexes.json.zstd"
curl -fsSL "$SPAMMERS_URL" | tr -d '\r' | zstd --quiet --force -o "$DATA_DIR/spammers.txt.zstd"
printf 'updated %s and %s\n' "$DATA_DIR/ua_regexes.json.zstd" "$DATA_DIR/spammers.txt.zstd"