diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/generate-mirror-mail.pl | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/bin/generate-mirror-mail.pl b/bin/generate-mirror-mail.pl index 6c290d9..037669e 100755 --- a/bin/generate-mirror-mail.pl +++ b/bin/generate-mirror-mail.pl @@ -38,23 +38,25 @@ my %templates = ( 'subject' => '[{$mirror_name}] Arch Linux mirror out of sync', 'template' => 'Hi, -Your mirror seems to be out of sync since {$last_sync}, could you please +Your mirror seems to be out of sync since {$out_of_sync{last_sync}}, could you please investigate? -{$mirror_urls} +{$mirror_url} +{$out_of_sync{mirror_urls}} Thanks, Florian ', }, 'connection-failed' => { - 'subject' => '[{$mirror_name}] Arch Linux mirror not accessible{$OUT = ", ".join("/", @affected_protocols) if @affected_protocols > 0;}', + 'subject' => '[{$mirror_name}] Arch Linux mirror not accessible{$OUT = ", ".join("/", @{$connection_failed{protocols}}) if @{$connection_failed{protocols}} > 0;}', 'template' => 'Hi, -We\'re having trouble connecting to your mirror{$OUT = " via ".join(", ", @affected_protocols) if @affected_protocols > 0;}, could you +We\'re having trouble connecting to your mirror{$OUT = " via ".join(", ", @{$connection_failed{protocols}}) if @{$connection_failed{protocols}} > 0;}, could you please check what\'s going on? -{$mirror_urls} +{$mirror_url} +{$connection_failed{mirror_urls}} Thanks, Florian @@ -165,27 +167,30 @@ while (<STDIN>) { my $to = $json->{admin_email}; $to .= ",".$json->{alternate_email} if $json->{alternate_email} ne ""; + my %values = ( + out_of_sync => { + last_sync => join(", ", map {time2str("%Y-%m-%d", $_)} @last_sync), + mirror_urls => join("\n", map {${$_}{details_link}} @out_of_sync), + }, + connection_failed => { + mirror_urls => join("\n", map {${$_}{details_link}} @connection_failed), + }, + mirror_name => $mirror_name, + mirror_url => $url, + ); + + my @protocols = map {${$_}{protocol}} @connection_failed; + if (scalar(@protocols) != scalar(@{$json->{urls}})) { + $values{connection_failed}->{protocols} = \@protocols; + } + + if (@out_of_sync) { - my %values = ( - last_sync => join(", ", map {time2str("%Y-%m-%d", $_)} @last_sync), - mirror_urls => join("\n", $url, map {${$_}{details_link}} @out_of_sync), - mirror_name => $mirror_name, - ); send_template_mail($to, $templates{"out-of-sync"}{"subject"}, $templates{"out-of-sync"}{"template"}, \%values); $sent_mail = 1; } if (@connection_failed) { - my %values = ( - mirror_urls => join("\n", $url, map {${$_}{details_link}} @connection_failed), - mirror_name => $mirror_name, - ); - - my @protocols = map {${$_}{protocol}} @connection_failed; - if (scalar(@protocols) != scalar(@{$json->{urls}})) { - $values{affected_protocols} = \@protocols; - } - send_template_mail($to, $templates{"connection-failed"}{"subject"}, $templates{"connection-failed"}{"template"}, \%values); $sent_mail = 1; } |