diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-05-30 13:41:09 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-05-30 13:43:25 +0300 |
commit | fbea83e22332724c7bff2f0a67dde810476f004b (patch) | |
tree | bebc165d9f6876cf156580d71c1a990e800cfb7a /lib | |
parent | d669127d2efaf9969b081fbaff47ff8938388750 (diff) | |
download | beam-fbea83e22332724c7bff2f0a67dde810476f004b.tar.gz beam-fbea83e22332724c7bff2f0a67dde810476f004b.tar.bz2 |
Implement mail notification.
* backup.in (backup): New function.
Send mail notification if backup_notify_email is not empty.
* lib/beam/common.in (mail_report): New function.
* beam.conf: Provide examples for the new variables.
* beam.in: Fix typos.
* doc/beam.conf.5in: Document new variables.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/beam/common.in | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/beam/common.in b/lib/beam/common.in index 49b41eb..c23baf5 100644 --- a/lib/beam/common.in +++ b/lib/beam/common.in @@ -133,3 +133,44 @@ wtf() { shift echo " $s $@" } + +# mail_report FILE +mail_report() { + if [ -z "$backup_sender_email" ]; then + backup_sender_email=root@$(hostname) + fi + case $backup_sender_email in + "<"*) ;; + *) backup_sender_email="<$backup_sender_email>" + esac + if [ -n "$backup_sender_personal" ]; then + case $backup_sender_personal in + \"*) ;; + *) backup_sender_personal="\"$backup_sender_personal\"" + esac + backup_sender_personal="$backup_sender_personal " + fi + if [ -z "$backup_report_subject" ]; then + backup_report_subject="Backup of $(hostname) on $(date)" + fi + test -n "$backup_report_signature" && + echo "$backup_report_signature" >> $report + (cat - <<EOF +From: ${backup_sender_personal}$backup_sender_email +To: $backup_notify_email +Subject: $backup_report_subject +X-Beam-Items: $backup_items +X-Beam-Round: $round +X-Beam-Level: $level +EOF + if [ -n "$backup_report_headers" ]; then + echo "$backup_report_headers" + fi + echo "" + if [ -n "$backup_report_intro" ]; then + echo "$backup_report_intro" + fi + cat $report +) | \ + ${backup_mailer_program:-/usr/sbin/sendmail -oi -t -F $backup_sender_email} +} |