Do not hard code the log file

We log to file only if WATCHDOG_LOG is set, otherwise we output to
stdout as usual.
main
mj-saunders 2022-11-03 17:09:54 +04:00
parent 2ae1e0eb5b
commit f20a4344d5
1 changed files with 8 additions and 6 deletions

View File

@ -5,6 +5,8 @@
# Any servers in URLS that yield a bad response are collated and sent via email
# to all RECIPIENTS.
#
# If WATCHDOG_LOG is set, all output will be redirected there.
#
# Dependencies
# - curl: Polling the servers
# - msmtp: Sending email; requires separate configuration
@ -12,8 +14,6 @@
#set -eux
LOG_FILE="/media/workshop/Projects/openmedianetwork/.omn_watchdog.log"
RECIPIENTS=(
saunders@openworlds.info
witchescauldron@openworlds.info
@ -44,10 +44,12 @@ main()
{
declare -A FLAGGED
rotate_log LOG_FILE
# Redirect all output to LOG_FILE but preserve a link to stdout should we
# still want to use it
exec 3>&1 1>>${LOG_FILE} 2>&1
if [ -n "${WATCHDOG_LOG}" ]; then
rotate_log WATCHDOG_LOG
# Redirect all output to WATCHDOG_LOG but preserve a link to stdout should we
# still want to use it
exec 3>&1 1>>${WATCHDOG_LOG} 2>&1
fi
echo ">> $(date)"
echo "== Checking:"