Don't emit an error when there's no email sender and/or recipient.
This commit is contained in:
parent
51131002cf
commit
be4d10eeba
1 changed files with 3 additions and 6 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# Version: 0.2.0
|
||||
# Version: 0.2.1
|
||||
# Copyright (c) 2023-2026:
|
||||
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
|
||||
# Licensed under the terms of the GNU General Public License version 3.
|
||||
|
|
@ -17,15 +17,12 @@ EMAIL_TO=("Systems' Administrator <sysadmin@slackware.uk>")
|
|||
|
||||
# Functions
|
||||
notify() {
|
||||
if [[ -n "$EMAIL_FROM" ]] && (( "${#EMAIL_TO[@]}" != 0 )); then
|
||||
[[ -n "$EMAIL_FROM" ]] && (( "${#EMAIL_TO[@]}" != 0 )) && {
|
||||
printf "%s: %s\\n%s: %s\\n%s:\\n%s\\n" "Exit code" "$ERR" "Logfile" "$LOGSDIR/$LOGFILE.xz" "Output" "$(<"$LOGSDIR/$LOGFILE")" | mail -r "$EMAIL_FROM" -s "Mirroring $1" "${EMAIL_TO[@]}" >/dev/null 2>&1 || {
|
||||
printf "%s: %s\\n" "${0##*/}" "mail command failed" >&2
|
||||
return 1
|
||||
}
|
||||
else
|
||||
printf "%s: %s\\n" "${0##*/}" "no sender and/or recipient configured for mail delivery" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue