diff --git a/notify.pl b/notify.pl index a7d99da..a885fda 100755 --- a/notify.pl +++ b/notify.pl @@ -31,6 +31,7 @@ use POSIX qw(strftime); # get function and function_variable (vmid) from arguments my $function = $ARGV[0] || "empty"; my $function_variable = $ARGV[1] || "empty"; +my $message = $ARGV[2] || "empty"; # define the prices for the different components of the VM my $base_price = '64'; @@ -144,8 +145,16 @@ sub mailout { open(my $fh, '<', $template); open my $fh_email, "|-", "/usr/sbin/sendmail -t"; printf $fh_email "To: %s\n", $_email; - while (my $row = <$fh>) { + TEMPLATE: while (my $row = <$fh>) { chomp $row; + if ($row =~ m/MESSAGE/) { + if ($message ne "empty") { + $row =~ s/MESSAGE/$message\n/g; + } else { + next TEMPLATE; + } + } + $row =~ s/FIRSTNAME/$_firstname/g; $row =~ s/VMID/$_instance/g; $row =~ s/SERVER/$conf{'conf'}{'SERVER'}/g; diff --git a/templates/email-deployed.txt b/templates/email-deployed.txt index 0f25982..988bab0 100644 --- a/templates/email-deployed.txt +++ b/templates/email-deployed.txt @@ -7,16 +7,17 @@ Hi FIRSTNAME, Welcome to OpenBSD Amsterdam! Your VM has been deployed. +MESSAGE You are on host: SERVER.DOMAIN Your VM name: VMID -Your IPv4 address: IPV4 -Your IPv4 subnet: IPV4NETMASK -Your IPv4 gateway: IPV4GW +IPv4 address: IPV4 +IPv4 subnet: IPV4NETMASK +IPv4 gateway: IPV4GW -Your IPv6 address: IPV6 -Your IPv6 subnet: 64 -Your IPv6 gateway: IPV6GW +IPv6 address: IPV6 +IPv6 subnet: 64 +IPv6 gateway: IPV6GW You should be able to ssh into your VM.