2022-11-03 08:39:42 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#set -eux
|
|
|
|
|
2022-11-03 09:48:53 +00:00
|
|
|
RECIPIENTS="saunders@openworlds.info"
|
|
|
|
#witchescauldron@openworlds.info"
|
2022-11-03 08:39:42 +00:00
|
|
|
|
2022-11-03 09:48:53 +00:00
|
|
|
URLS=(
|
|
|
|
unite.openworlds.info
|
|
|
|
openworlds.info
|
|
|
|
pad.openworlds.info
|
|
|
|
visionon.tv
|
2022-11-03 10:20:47 +00:00
|
|
|
activism.openworlds.info
|
|
|
|
campaign.openworlds.info
|
|
|
|
#indymedia.openworlds.info
|
|
|
|
#roadstonowhere.openworlds.info
|
|
|
|
#indymedia.hs2rebellion.earth
|
2022-11-03 09:48:53 +00:00
|
|
|
)
|
|
|
|
# TODO: How to check these sensibly?
|
|
|
|
SERVICES=(
|
|
|
|
chat.openworlds.info
|
|
|
|
conference.openworlds.info
|
|
|
|
# Not much point checking the mail server
|
|
|
|
# as this script relies on it to send reports
|
2022-11-03 10:20:47 +00:00
|
|
|
# TODO: Separate local check just for this?
|
2022-11-03 09:48:53 +00:00
|
|
|
#mail.openworlds.info
|
|
|
|
)
|
|
|
|
|
2022-11-03 10:20:47 +00:00
|
|
|
send_mail() {
|
|
|
|
local -n error_list=$1
|
|
|
|
local error_string=""
|
|
|
|
|
|
|
|
for i in "${!error_list[@]}"; do
|
|
|
|
# Use bash's awful syntax to escape any / in the server string
|
|
|
|
code=${i//\//\\\/}
|
|
|
|
server=${error_list[$i]}
|
|
|
|
error_string+=" ${code}: ${server}\n"
|
|
|
|
done
|
|
|
|
|
|
|
|
cat mail_template \
|
|
|
|
| sed "s/{ERR_LIST}/${error_string}/g" \
|
|
|
|
| msmtp -a omn_server_watch ${RECIPIENTS}
|
|
|
|
}
|
|
|
|
|
2022-11-03 09:48:53 +00:00
|
|
|
declare -A FLAGGED
|
|
|
|
|
|
|
|
for uri in "${URLS[@]}"; do \
|
|
|
|
full_uri="https://${uri}"
|
|
|
|
echo -n "Checking: ${full_uri} ... ";
|
|
|
|
stat="$(curl -s -o /dev/null -w "%{http_code}%{stdout}" ${full_uri})"
|
|
|
|
echo "${stat}"
|
|
|
|
|
2022-11-03 10:20:47 +00:00
|
|
|
# All other HTTP responses should not technically be errors
|
|
|
|
if ((${stat} >= 400 && ${stat} <= 599)); then
|
2022-11-03 09:48:53 +00:00
|
|
|
FLAGGED[${full_uri}]=${stat}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2022-11-03 10:20:47 +00:00
|
|
|
send_mail FLAGGED
|