aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2013-06-17 14:31:38 +0000
committerNicolas Vigier <boklm@mageia.org>2013-06-17 14:31:38 +0000
commit196dd77df000d216f408df22861fe3c3c93e0cac (patch)
tree8ccf1eae9388ccdc429b96a1045957ebab6f12d6
parent3e1e908de0904ee5cd5f7dfdd04987a2d09c4380 (diff)
downloadmgaadvisories-196dd77df000d216f408df22861fe3c3c93e0cac.tar
mgaadvisories-196dd77df000d216f408df22861fe3c3c93e0cac.tar.gz
mgaadvisories-196dd77df000d216f408df22861fe3c3c93e0cac.tar.bz2
mgaadvisories-196dd77df000d216f408df22861fe3c3c93e0cac.tar.xz
mgaadvisories-196dd77df000d216f408df22861fe3c3c93e0cac.zip
Rename send_report_mail sub to send_report
And display report logs to stdout if not configured to send report email.
-rw-r--r--lib/MGA/Advisories.pm32
-rwxr-xr-xmgaadv2
2 files changed, 18 insertions, 16 deletions
diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm
index 5130655..8c8bab2 100644
--- a/lib/MGA/Advisories.pm
+++ b/lib/MGA/Advisories.pm
@@ -40,7 +40,7 @@ sub report_log {
sub report_exit {
report_log($_[0]);
- send_report_mail({ error => $_[0] });
+ send_report({ error => $_[0] });
exit 1;
}
@@ -262,30 +262,32 @@ sub send_adv_mail {
}
}
-sub send_report_mail {
+sub send_report {
my ($advdb) = @_;
- return unless $config->{send_report_mail} eq 'yes';
- return unless $config->{mode} eq 'site';
return unless @report_logs;
my $template = Template->new(
INCLUDE_PATH => $config->{tmpl_dir},
);
- my $mailcontent;
+ my $reportcontent;
my $vars = {
config => $config,
advdb => $advdb,
report_logs => \@report_logs,
};
- process_template($template, 'report', $vars, \$mailcontent, 'txt');
- my $email = Email::Simple->create(
- header => [
- To => $config->{report_mail_to},
- From => $config->{report_mail_from},
- Subject => $advdb->{error} ? 'Advisories Error' : 'Advisories Update',
- ],
- body => $mailcontent
- );
- try_to_sendmail($email);
+ process_template($template, 'report', $vars, \$reportcontent, 'txt');
+ if ($config->{send_report_mail} eq 'yes' && $config->{mode} eq 'site') {
+ my $email = Email::Simple->create(
+ header => [
+ To => $config->{report_mail_to},
+ From => $config->{report_mail_from},
+ Subject => $advdb->{error} ? 'Advisories Error' : 'Advisories Update',
+ ],
+ body => $reportcontent
+ );
+ try_to_sendmail($email);
+ } else {
+ print $reportcontent;
+ }
}
sub dumpdb {
diff --git a/mgaadv b/mgaadv
index 3e6bdc1..afbe8dd 100755
--- a/mgaadv
+++ b/mgaadv
@@ -115,7 +115,7 @@ sub mksite {
MGA::Advisories::output_pages(\%advdb);
MGA::Advisories::dumpdb(\%advdb);
MGA::Advisories::send_adv_mail(\%advdb);
- MGA::Advisories::send_report_mail(\%advdb);
+ MGA::Advisories::send_report(\%advdb);
}
sub editor { $ENV{EDITOR} || $ENV{VISUAL} || '/usr/bin/editor' }