Update mail command for git statuses.

This commit is contained in:
Darren 'Tadgy' Austin 2025-09-18 19:40:43 +00:00
commit 95972c6d3b

View file

@ -1,8 +1,18 @@
#!/bin/bash
# Default configuration.
CHECK_DIRS=('/')
EMAIL_TO=('sysadmin@slackware.uk')
EMAIL_FROM="${HOSTNAME%%.*} <noreply@slackware.uk>"
EMAIL_FROM="\"Server: ${HOSTNAME%%.*}\" <noreply@slackware.uk>"
# Allow /etc/default/warn-git-status to override default configuration.
[[ -e /etc/default/warn-git-status ]] && {
source /etc/default/warn-git-status || {
printf "%s: %s\\n" "${0##*/}" "failed reading /etc/default/warn-git-status" >&2
exit 1
}
}
OUTPUT_FILE="/tmp/${0##*/}-$$-$RANDOM"
# Remove the OUTPUT_FILE when done.
@ -22,8 +32,8 @@ done
# Send the message.
if [[ -n "${EMAIL_TO[*]}" ]]; then
mailx "${MAILX_ARGS[@]}" -S "from=$EMAIL_FROM" -s "Git statuses" "${EMAIL_TO[@]}" <<<"$(cat "$OUTPUT_FILE")" 2>/dev/null || {
printf "%s: %s\\n" "${0##*/}" "mailx command failed" >&2
mail -r "$EMAIL_FROM" -s "Git statuses" "${EMAIL_TO[@]}" <"$OUTPUT_FILE" >/dev/null 2>&1 || {
printf "%s: %s\\n" "${0##*/}" "mail command failed" >&2
exit 1
}
else