deleted: cronjob-update-packages-list.new deleted: cronjob-updatedb-mirrors renamed: rsync-notify-upload -> notify-rsync-upload modified: colour-changelog modified: cronjob-clean-php modified: cronjob-dehydrated modified: cronjob-fix-log-acls modified: cronjob-rotate-logs-today-symlink modified: cronjob-update-mirrors-search-db modified: cronjob-update-packages-list modified: cronjob-warn-git-status modified: cronjob-warn-smtp-queue modified: do-backup modified: dovecot-service-checksuspended modified: firewall-initscript modified: git-auto-merge modified: mirror modified: mirror-new-slackware-release.gpg modified: mirror-wrapper modified: notify-rsync-upload modified: sbosrcarch-wrapper
40 lines
1.2 KiB
Bash
Executable file
40 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
# Send an email with the status of the SMTP queue on the system.
|
|
|
|
# Default configuration.
|
|
# This can be overridden in /etc/default/warn-smtp-queue.
|
|
EMAIL_TO=('sysadmin@slackware.uk')
|
|
EMAIL_FROM="\"Server: ${HOSTNAME%%.*}\" <noreply@slackware.uk>"
|
|
|
|
# Allow /etc/default/warn-smtp-queue to override default configuration.
|
|
[[ -e /etc/default/warn-smtp-queue ]] && {
|
|
# shellcheck disable=SC1091
|
|
source /etc/default/warn-smtp-queue || {
|
|
printf "%s: %s\\n" "${0##*/}" "failed reading /etc/default/warn-smtp-queue" >&2
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
# Don't do anything unless 'mailq' is installed.
|
|
hash mailq 2>/dev/null && {
|
|
# Prevent a race with other cron jobs that produce emails.
|
|
sleep $(( 10 + (RANDOM % 30) ))
|
|
|
|
# Get the queue
|
|
TMP_OUTPUT="$(mailq)"
|
|
|
|
[[ -z "$TMP_OUTPUT" ]] && exit 0
|
|
|
|
# Send the message.
|
|
if [[ -n "$EMAIL_FROM" ]] && [[ -n "${EMAIL_TO[*]}" ]]; then
|
|
mail -r "$EMAIL_FROM" -s "Mail queue" "${EMAIL_TO[@]}" <<<"$TMP_OUTPUT" >/dev/null 2>&1 || {
|
|
printf "%s: %s\\n" "${0##*/}" "mail command failed" >&2
|
|
exit 1
|
|
}
|
|
else
|
|
printf "%s: %s\\n" "${0##*/}" "no sender and/or recipient configured for mail delivery" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
exit 0
|