In mirror-wrapper, compress the logs /after/ they are emailed.

This commit is contained in:
Darren 'Tadgy' Austin 2026-05-21 19:30:34 +01:00
commit 2eb0c75bdc

View file

@ -62,17 +62,19 @@ mkdir -p -m 750 "$LOGSDIR" 2>/dev/null || {
"$COMMAND" "$@" >"$LOGSDIR/$LOGFILE" 2>&1
ERR="$?"
# Compress the log to save some space.
xz -9 "$LOGSDIR/$LOGFILE" 2>/dev/null || printf "%s: %s\\n" "${0##*/}" "failed to compress '$LOGSDIR/$LOGFILE'" >&2
# Tell the sysadmin what went on.
if (( "$ERR" == 0 )); then
# Only email a mirroring report if it's not the hourly Slackware tree only run.
# The size of the log file determines if it gets emailed.
(( $(stat --printf="%s" "$LOGSDIR/$LOGFILE") > MIN_LOGFILE_SIZE )) && notify "report"
exit "$?"
ERR="$?"
else
# Mirroring failed, tell the admin.
notify "failure" || [[ -x /opt/bin/pushover-client ]] && /opt/bin/pushover-client "mirroring" -p -1 -s "Mirroring failure" -m "Check log in email"
exit 1
ERR="1"
fi
# Compress the log to save some space.
xz -9 "$LOGSDIR/$LOGFILE" 2>/dev/null || printf "%s: %s\\n" "${0##*/}" "failed to compress '$LOGSDIR/$LOGFILE'" >&2
exit "$ERR"