Skip to content

Commit

Permalink
fix text parsing of return codes
Browse files Browse the repository at this point in the history
  • Loading branch information
rodecker committed Dec 24, 2024
1 parent b88ce54 commit ec1f24e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions roles/inframail/templates/ring-aptsummary
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,17 @@ sub process_file {
my $host;
foreach my $line (@lines) {

if ($line =~ m/^Subject:\s+(\[reboot required\])?\s*unattended-upgrades result for (.+)/) {
$host = $2;
}
if ($line =~ m/^Unattended upgrade returned: (.+)/) {
return unless ($host);
$upgrade_result{$host} = $1;
if ($upgrade_result{$host} ne 'True') {
if ($line =~ m/^Subject:\s+.*unattended-upgrades result for (.+):\s(.+)/) {
$host = $1;
$upgrade_result{$host} = $2;
if ($upgrade_result{$host} ne 'SUCCESS') {
$sendmail = 1;
$mail_log{$host} = \@lines;
}
}
if ($line =~ m/^Warning: A reboot is required/) {
return unless ($host);
if ($upgrade_result{$host} eq 'True') {
if ($upgrade_result{$host} eq 'SUCCESS') {
$upgrade_result{$host} = 'Reboot';
}
}
Expand All @@ -77,7 +74,7 @@ sub send_mail {
}
$body .= "Succeeded:\n";
foreach my $host (sort keys %upgrade_result) {
if ($upgrade_result{$host} eq 'True') {
if ($upgrade_result{$host} eq 'SUCCESS') {
$body .= "\t$host\n";
} elsif ($upgrade_result{$host} eq 'Reboot') {
$body .= "\t$host (R)\n";
Expand Down

0 comments on commit ec1f24e

Please sign in to comment.