X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_sendEmail;h=3a1200d898f66ee70f2c5782c61685d6e105ce39;hp=d5d4e006af83191beac0f869d303233e8bba2d69;hb=17dcbbebb871212f90b81bb97f8d1feb528bdc43;hpb=9175f9157f0d54b50ebf11d2036c20f50ffc6d9d diff --git a/bin/BackupPC_sendEmail b/bin/BackupPC_sendEmail index d5d4e00..3a1200d 100755 --- a/bin/BackupPC_sendEmail +++ b/bin/BackupPC_sendEmail @@ -1,4 +1,4 @@ -#!/bin/perl -T +#!/bin/perl #============================================================= -*-perl-*- # # BackupPC_sendEmail: send status emails to users and admins @@ -13,7 +13,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001 Craig Barratt +# Copyright (C) 2001-2003 Craig Barratt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -31,13 +31,14 @@ # #======================================================================== # -# Version 2.0.0_CVS, released 3 Feb 2003. +# Version 2.1.0, released 20 Jun 2004. # # See http://backuppc.sourceforge.net. # #======================================================================== use strict; +no utf8; use lib "/usr/local/BackupPC/lib"; use BackupPC::Lib; use BackupPC::FileZIO; @@ -59,8 +60,7 @@ use vars qw(%UserEmailInfo); do "$TopDir/log/UserEmailInfo.pl"; my %opts; -getopts("t", \%opts); -if ( @ARGV != 0 ) { +if ( !getopts("t", \%opts) || @ARGV != 0 ) { print("usage: $0 [-t]\n"); exit(1); } @@ -82,7 +82,8 @@ my $mesg = ""; my @badHosts = (); foreach my $host ( sort(keys(%Status)) ) { - next if ( $Status{$host}{reason} ne "backup failed" + next if ( ($Status{$host}{reason} ne "Reason_backup_failed" + && $Status{$host}{reason} ne "Reason_restore_failed") || $Status{$host}{error} =~ /^lost network connection to host/ ); push(@badHosts, "$host ($Status{$host}{error})"); } @@ -121,7 +122,7 @@ my @oldDirs = (); my @files = $d->read; $d->close; foreach my $host ( @files ) { - next if ( $host eq "." || $host eq ".." || defined($Status{$host}) ); + next if ( $host =~ /^\./ || defined($Status{$host}) ); push(@oldDirs, "$TopDir/pc/$host"); } if ( @oldDirs ) { @@ -139,10 +140,12 @@ EOF } if ( $mesg ne "" && $Conf{EMailAdminUserName} ne "" ) { + my $headers = $Conf{EMailHeaders}; + $headers .= "\n" if ( $headers !~ /\n$/ ); $mesg = <{$host}{user}; next if ( time - $UserEmailInfo{$user}{lastTime} < $Conf{EMailNotifyMinDays} * 24*3600 ); + next if ($Conf{XferMethod} eq "archive" ); my @Backups = $bpc->BackupInfoRead($host); my $numBackups = @Backups; if ( $numBackups == 0 ) { @@ -215,8 +219,8 @@ foreach my $host ( sort(keys(%Status)) ) { while ( 1 ) { my $s = $fh->readLine(); last if ( $s eq "" ); - if ( $s =~ /^Error reading file.*\.pst : ERRDOS - ERRlock/ - || $s =~ /^Error reading file.*\.pst\. Got 0 bytes/ ) { + if ( $s =~ /^\s*Error reading file.*\.pst : (ERRDOS - ERRlock|NT_STATUS_FILE_LOCK_CONFLICT)/ + || $s =~ /^\s*Error reading file.*\.pst\. Got 0 bytes/ ) { $badOutlook = 1; last; } @@ -283,6 +287,7 @@ if ( !$opts{t} ) { [\%UserEmailInfo], [qw(*UserEmailInfo)]); if ( open(HOST, ">", "$TopDir/log/UserEmailInfo.pl") ) { + binmode(HOST); print(HOST $dumpStr); close(HOST); } @@ -300,10 +305,12 @@ sub user2name sub sendUserEmail { my($user, $host, $mesg, $subj, $vars) = @_; - $vars->{user} = $user; - $vars->{host} = $host; - $vars->{domain} = $Conf{EMailUserDestDomain}; - $vars->{CgiURL} = $Conf{CgiURL}; + $vars->{user} = $user; + $vars->{host} = $host; + $vars->{headers} = $Conf{EMailHeaders}; + $vars->{headers} .= "\n" if ( $vars->{headers} !~ /\n$/ ); + $vars->{domain} = $Conf{EMailUserDestDomain}; + $vars->{CgiURL} = $Conf{CgiURL}; $subj =~ s/\$(\w+)/defined($vars->{$1}) ? $vars->{$1} : "\$$1"/eg; $vars->{subj} = $subj; $mesg =~ s/\$(\w+)/defined($vars->{$1}) ? $vars->{$1} : "\$$1"/eg;