Skip to content

Commit

Permalink
aii/ks: support for sending mail in el9 using correct s-nail format
Browse files Browse the repository at this point in the history
Current mailx options used in aii doesn't seem to send mail when s-nail is used,
provide correct options when s-nail binary exists.
  • Loading branch information
Abdul Karim authored and jrha committed Sep 5, 2024
1 parent 2da3a37 commit 5a28aee
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions aii-ks/src/main/perl/ks.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,9 @@ sub kspostreboot_header

my $mailx_smtp = "";
$mailx_smtp .= " smtp=$tree->{mail}->{smtp}" if $tree->{mail}->{smtp};
# support for s-nail on el9
my $snail_smtp = "";
$snail_smtp .= " -Smta=smtp://$tree->{mail}->{smtp}" if $tree->{mail}->{smtp};

print <<EOF;
#!/bin/bash
Expand All @@ -1099,7 +1102,11 @@ fail() {
echo "Quattor installation on $fqdn failed: \\\$1"
subject="[\\`date +'%x %R %z'\\`] Quattor installation on $fqdn failed: \\\$1"
if [ -x /usr/bin/mailx ]; then
env MAILRC=/dev/null from=root\@$fqdn $mailx_smtp mailx -s "\\\$subject" $rootmail <<End_of_mailx
mailx_options="from=root\@$fqdn $mailx_smtp mailx"
if [ -x /usr/bin/s-nail ]; then
mailx_options="mailx -:/ -Sfrom=root\@$fqdn $snail_smtp"
fi
env MAILRC=/dev/null \\\$mailx_options -s "\\\$subject" $rootmail <<End_of_mailx
\\`cat $logfile\\`
------------------------------------------------------------
Expand Down Expand Up @@ -1132,7 +1139,11 @@ success() {
subject="[\\`date +'%x %R %z'\\`] Quattor installation on $fqdn succeeded"
if [ -x /usr/bin/mailx ]; then
env MAILRC=/dev/null from=root\@$fqdn $mailx_smtp mailx -s "\\\$subject" $rootmail <<End_of_mailx
mailx_options="from=root\@$fqdn $mailx_smtp mailx"
if [ -x /usr/bin/s-nail ]; then
mailx_options="mailx -:/ -Sfrom=root\@$fqdn $snail_smtp"
fi
env MAILRC=/dev/null \\\$mailx_options -s "\\\$subject" $rootmail <<End_of_mailx
Node $fqdn successfully installed.
Expand Down

0 comments on commit 5a28aee

Please sign in to comment.