Files
setup-zig/check-mirrors.sh
T
mlugg b92374239f Add workflow to check mirrors are functional
This Actions workflow will run twice every day. It checks ziglang.org
for the latest `master` build, downloads it from ziglang.org and runs it
through sha512sum, and does the same for each mirror. If the download
from the mirror fails, or the sha512sum output differs, it sends me
personally a notification via an external webhook.
2024-09-13 11:16:37 +01:00

29 lines
778 B
Bash
Executable File

#!/bin/sh
temp_path="$(mktemp)"
zig_version="$(curl -sSL 'https://ziglang.org/download/index.json' | jq -r '.master.version')"
filename="zig-linux-x86_64-$zig_version.tar.xz"
curl -L "https://ziglang.org/builds/$filename" >"$temp_path"
correct_sum="$(sha512sum "$temp_path")"
jq '.[] | .[0] + " " + .[1]' -r <mirrors.json | while read -r mirror_url mirror_name; do
curl -L "$mirror_url/$filename" >"$temp_path"
download_status="$?"
mirror_sum="$(sha512sum "$temp_path")"
if [ "$download_status" -eq 0 ]; then
if [ "$mirror_sum" = "$correct_sum" ]; then
continue
fi
fi
curl -s \
-F user="$PUSHOVER_USER" -F token="$PUSHOVER_TOKEN" \
-F message="Zig download mirror '$mirror_name' is down" \
https://api.pushover.net/1/messages.json
done
rm "$temp_path"