Skip to content

Commit

Permalink
Add support for s-nail to replace mailx.
Browse files Browse the repository at this point in the history
* This resolves issue #679

Signed-off-by: Madison Kelly <[email protected]>
  • Loading branch information
digimer-bot committed Jul 16, 2024
1 parent 66eed94 commit 6d6de37
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
23 changes: 2 additions & 21 deletions Anvil/Tools.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ sub _set_paths
lvrename => "/usr/sbin/lvrename",
lvs => "/usr/sbin/lvs",
lvscan => "/usr/sbin/lvscan",
mailx => "/usr/bin/mailx",
mailx => "/usr/bin/mailx", ### Deprecated, remove with EL8
man => "/usr/bin/man",
md5sum => "/usr/bin/md5sum",
'mkdir' => "/usr/bin/mkdir",
Expand Down Expand Up @@ -1305,6 +1305,7 @@ sub _set_paths
rm => "/usr/bin/rm",
rpm => "/usr/bin/rpm",
rsync => "/usr/bin/rsync",
's-nail' => "/usr/bin/s-nail",
scancore => "/usr/sbin/scancore",
sed => "/usr/bin/sed",
setsid => "/usr/bin/setsid", # See: https://serverfault.com/questions/1105733/virsh-command-hangs-when-script-runs-in-the-background
Expand Down Expand Up @@ -1426,28 +1427,8 @@ Anvil::Tools->new() passed something other than a hash reference.
Failed to find the requested file in C<< Anvil::Tools::Storage->find >> and 'fatal' was set.
=head1 Requirements
The following packages are required on EL7.
* C<expect>
* C<httpd>
* C<mailx>
* C<perl-Test-Simple>
* C<policycoreutils-python>
* C<postgresql>
* C<syslinux>
* C<perl-XML-Simple>
=head1 Recommended Packages
The following packages provide non-critical functionality.
* C<subscription-manager>
=cut


# This catches SIGINT and SIGTERM and fires out an email before shutting down.
sub catch_sig
{
Expand Down
12 changes: 8 additions & 4 deletions Anvil/Tools/Email.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package Anvil::Tools::Email;
#
# This module contains methods used to manage the local postfix server and handle and dispatch email via
# mailx.
# s-nail.
#

### TODO: By default, a recipient receives all alerts at their default level. Later, we'll add an
Expand Down Expand Up @@ -34,7 +34,7 @@ my $THIS_FILE = "Email.pm";
Anvil::Tools::Email
Provides all methods used to manage the local C<< postfix >> server and handle and dispatch email via C<< mailx >>
Provides all methods used to manage the local C<< postfix >> server and handle and dispatch email via C<< s-nail >>
=head1 SYNOPSIS
Expand Down Expand Up @@ -638,7 +638,7 @@ Reply-To: ".$reply_to."
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { problem => $problem }});

# Call mailx to read it in
# Call s-nail (if available, otherwise try mailx) to read it in
if ($problem)
{
# Something went wrong
Expand All @@ -647,7 +647,11 @@ Reply-To: ".$reply_to."
else
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0542", variables => { to => $to }});
my $shell_call = $anvil->data->{path}{exe}{mailx}." -t < ".$file_name;
my $shell_call = $anvil->data->{path}{exe}{'s-nail'}." -t < ".$file_name;
if ((not -e $anvil->data->{path}{exe}{'s-nail'}) && (-e $anvil->data->{path}{exe}{mailx}))
{
$shell_call = $anvil->data->{path}{exe}{mailx}." -t < ".$file_name;
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});

my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $shell_call });
Expand Down
2 changes: 1 addition & 1 deletion tools/anvil-manage-alerts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ sub handle_test_alert
if ($alert_uuid)
{
print $anvil->Words->string({key => "message_0306", variables => { level => $say_level }})."\n";
$anvil->Email->send_alerts();
$anvil->Email->send_alerts({debug => 2});
}
else
{
Expand Down

0 comments on commit 6d6de37

Please sign in to comment.