bin/http-status-note

17 lines
544 B
Plaintext
Raw Normal View History

2023-12-31 04:04:27 +01:00
#!/usr/bin/env bash
source /usr/local/etc/matrix-webhook-env
for url in "${site_urls[@]}"; do
status_code=$(curl -o /dev/null -s -w "%{http_code}" "$url")
if [ "$status_code" = 200 ] && ! [ "$status_code" == "302" ]; then
if ! /usr/local/bin/send-matrix-webhook "$room_id" "$url: ✅ UP"; then
echo "Error sending webhook to Matrix"
exit 1
fi
else if ! /usr/local/bin/send-matrix-webhook "$room_id" "$url: ❌ DOWN"; then
echo "Error sending webhook to Matrix"
exit 1
fi
done