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 2025e17
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 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
12 changes: 10 additions & 2 deletions aii-ks/src/test/perl/kickstart_postreboot.t
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ fail() {
echo "Quattor installation on x.y failed: \$1"
subject="[\`date +'%x %R %z'\`] Quattor installation on x.y failed: \$1"
if [ -x /usr/bin/mailx ]; then
env MAILRC=/dev/null from=root@x.y smtp=smtp.example.com mailx -s "\$subject" root@example.com <<End_of_mailx
mailx_options="from=root@x.y smtp=smtp.example.com mailx"
if [ -x /usr/bin/s-nail ]; then
mailx_options="mailx -:/ -Sfrom=root@x.y -Smta=smtp://smtp.example.com"
fi
env MAILRC=/dev/null \$mailx_options -s "\$subject" root@example.com <<End_of_mailx
\`cat /root/ks-post-reboot.log\`
------------------------------------------------------------
Expand Down Expand Up @@ -80,7 +84,11 @@ success() {
subject="[\`date +'%x %R %z'\`] Quattor installation on x.y succeeded"
if [ -x /usr/bin/mailx ]; then
env MAILRC=/dev/null from=root@x.y smtp=smtp.example.com mailx -s "\$subject" root@example.com <<End_of_mailx
mailx_options="from=root@x.y smtp=smtp.example.com mailx"
if [ -x /usr/bin/s-nail ]; then
mailx_options="mailx -:/ -Sfrom=root@x.y -Smta=smtp://smtp.example.com"
fi
env MAILRC=/dev/null \$mailx_options -s "\$subject" root@example.com <<End_of_mailx
Node x.y successfully installed.
Expand Down

0 comments on commit 2025e17

Please sign in to comment.