summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormischa <mischa@rx.high5.nl>2020-10-24 12:48:36 +0200
committermischa <mischa@rx.high5.nl>2020-10-24 12:48:36 +0200
commit01a6e79812273103af7a0979b8e07b44bdcbd7e4 (patch)
tree5cfbd82dca04d8c4da75f19ffd947bc81881e636
parentf98ed45f36f87109f25340f99ba443d528ea5709 (diff)
added more IP information to the notification email
-rw-r--r--email-deployed.txt11
-rwxr-xr-xnotify.pl18
-rw-r--r--vms/vm01.txt1
3 files changed, 22 insertions, 8 deletions
diff --git a/email-deployed.txt b/email-deployed.txt
index 4ffe590..44b436f 100644
--- a/email-deployed.txt
+++ b/email-deployed.txt
@@ -5,8 +5,15 @@ Hi NAME,
Welcome to OpenBSD Amsterdam! Your VM has been deployed.
-Your IPv4: IP
+You are on host: SERVER.openbsd.amsterdam
Your VM name: VMID
-Your host: SERVER.openbsd.amsterdam
+
+Your IPv4 address: IPV4
+Your IPv4 subnet: IPV4NETMASK
+Your IPv4 gateway: IPV4GW
+
+Your IPv6 address: IPV6
+Your IPv6 subnet: 64
+Your IPv6 gateway: IPV6GW
Mischa
diff --git a/notify.pl b/notify.pl
index 8c39f2c..d1bec3b 100755
--- a/notify.pl
+++ b/notify.pl
@@ -73,6 +73,8 @@ sub deployed {
my $_tmpl = $conf{'conf'}{'TEMPLATES'};
my $_server = $conf{'conf'}{'SERVER'};
my $template = "$_tmpl/email-deployed.txt";
+ my $_ip4netmask = $conf{'conf'}{'NETMASK'};
+ my $_ip4gw = $conf{'conf'}{'ROUTER'};
for my $vm_name (sort keys %vms) {
my $_date = $vms{$vm_name}{'date'};
@@ -86,7 +88,9 @@ sub deployed {
if ($function_variable =~ /empty/) { print "No VMID provided\n"; last; }
if ($function_variable =~ /$vm_name/) {
(my $_firstname, my $_lastname) = split(/ /, $_name, 2);
- my $ipaddress = qx(grep -A2 $vm_name $_etc/dhcpd.conf | awk '/fixed-address/{print \$2}' | tr -d ';\n');
+ my $ip4address = qx(grep -A2 $vm_name $_etc/dhcpd.conf | awk '/fixed-address/{print \$2}' | tr -d ';\n');
+ my $ip6address = qx(grep -A3 $vm_name $_etc/dhcpd.conf | awk '/fixed-address-ipv6/{print \$2}' | tr -d ';\n');
+ (my $ip6gw = $ip6address) =~ s/::.*/::1/;
open(my $fh, '<', $template);
open my $fh_email, "|-", "/usr/sbin/sendmail -t";
@@ -94,13 +98,17 @@ sub deployed {
while (my $row = <$fh>) {
chomp $row;
$row =~ s/NAME/$_firstname/g;
- $row =~ s/IP$/$ipaddress/g;
+ $row =~ s/IPV4$/$ip4address/g;
+ $row =~ s/IPV4NETMASK$/$_ip4netmask/g;
+ $row =~ s/IPV4GW$/$_ip4gw/g;
+ $row =~ s/IPV6$/$ip6address/g;
+ $row =~ s/IPV6GW$/$ip6gw/g;
$row =~ s/VMID/$vm_name/g;
$row =~ s/SERVER/$_server/g;
print $fh_email "$row\n";
}
close $fh_email;
- print "NOTIFIED: $_date, $_payment, $_name, $_email, $_hostname, $_server ($vm_name), $ipaddress\n";
+ print "NOTIFIED: $_date, $_payment, $_name, $_email, $_hostname, $_server ($vm_name), $ip4address\n";
}
}
}
@@ -163,12 +171,12 @@ sub renewal {
my $year = strftime("%Y", localtime);
my $month = strftime("%m", localtime);
- #my $total_donated = qx(ftp -Vo- https://obsda.ms/index.html | grep "donated to OpenBSD" | awk -F';' '{print \$4}' | awk '{printf \$1}');
+ #my $total_donated = qx(ftp -Vo- https://obsda.ms/index.html | grep "donated to the OpenBSD" | awk -F';' '{print \$4}' | awk '{printf \$1}');
#my $total_vms = qx(ftp -Vo- https://obsda.ms/index.html | grep "deployed" | awk -F '>' '{print \$3}' | awk '{printf \$1}');
#my $total_hosts = qx(ftp -Vo- https://obsda.ms/servers.html | grep -c ">Server " | tr -d '\n');
my $response = HTTP::Tiny->new->get('https://openbsd.amsterdam/index.html');
- my $total_donated = $1 if $response->{'content'} =~ /([0-9,]+) donated to OpenBSD/;
+ my $total_donated = $1 if $response->{'content'} =~ /([0-9,]+) donated to the OpenBSD/;
my $total_vms = $1 if $response->{'content'} =~ /([0-9,]+) VMs deployed/;
$response = HTTP::Tiny->new->get('https://openbsd.amsterdam/servers.html');
my $total_hosts = () = $response->{'content'} =~ /(\>Server )/g;
diff --git a/vms/vm01.txt b/vms/vm01.txt
index 1a21551..be49a2b 100644
--- a/vms/vm01.txt
+++ b/vms/vm01.txt
@@ -1,6 +1,5 @@
mac="fe:e1:ab:dd:73:a4"
ip="192.168.1.1"
-instance="superduper1"
owner="testuser1"
date="2018/09/02"
payment="70"