From 596eff218d061671fe7c579f98159271bda124d5 Mon Sep 17 00:00:00 2001 From: mischa Date: Mon, 11 Jan 2021 22:15:01 +0100 Subject: [PATCH] added TIME options --- notify.pl | 6 ++++++ templates/email-deployed.txt | 1 + templates/email-notify.txt | 5 ++++- templates/email-stopped.txt | 1 + vms/vm01.txt | 2 +- vms/vm02.txt | 2 +- vms/vm03.txt | 2 +- 7 files changed, 15 insertions(+), 4 deletions(-) diff --git a/notify.pl b/notify.pl index 172e181..6efd5ab 100755 --- a/notify.pl +++ b/notify.pl @@ -233,6 +233,8 @@ sub notify { my $_tmpl = $conf{'conf'}{'TEMPLATES'}; my $_server = $conf{'conf'}{'SERVER'}; my $template = "$_tmpl/email-notify.txt"; + my $server_number = $1 if $_server =~ /([0-9]+)/; + my $oddeven = $server_number % 2; for my $vm_name (sort keys %vms) { my $_date = $vms{$vm_name}{'date'}; @@ -257,6 +259,10 @@ sub notify { $row =~ s/IP$/$ipaddress/g; $row =~ s/VMID/$vm_name/g; $row =~ s/SERVER/$_server/g; + if ($row =~ /TIME\((.*)\)/) { + my @TIMES = split(/,/, $1); + $row =~ s/TIME\(.*\)/$TIMES[$oddeven]/g; + } print $fh_email "$row\n"; } close $fh_email; diff --git a/templates/email-deployed.txt b/templates/email-deployed.txt index 44b436f..0c90471 100644 --- a/templates/email-deployed.txt +++ b/templates/email-deployed.txt @@ -1,5 +1,6 @@ From: admin Subject: OpenBSD Amsterdam +Content-Type: text/plain; charset=utf-8 Hi NAME, diff --git a/templates/email-notify.txt b/templates/email-notify.txt index d7fbaa2..740449a 100644 --- a/templates/email-notify.txt +++ b/templates/email-notify.txt @@ -1,10 +1,13 @@ From: admin Subject: OpenBSD Amsterdam - maintenance +Content-Type: text/plain; charset=utf-8 Hi NAME, You have a VM (VMID) running on SERVER. -We will sysupgrade SERVER from OpenBSD 6.6 to OpenBSD 6.7. +We will sysupgrade SERVER from OpenBSD 6.8 to OpenBSD 6.9. + +This will happen on 2021-xx-xx @ TIME(11:30,16:00). Mischa diff --git a/templates/email-stopped.txt b/templates/email-stopped.txt index 230dfdb..07154f6 100644 --- a/templates/email-stopped.txt +++ b/templates/email-stopped.txt @@ -1,5 +1,6 @@ From: admin Subject: OpenBSD Amsterdam VM not running +Content-Type: text/plain; charset=utf-8 Hi NAME, diff --git a/vms/vm01.txt b/vms/vm01.txt index 00fb8e8..20f329e 100644 --- a/vms/vm01.txt +++ b/vms/vm01.txt @@ -5,7 +5,7 @@ date="2018/11/02" payment="70" donated="" name="Test1 User" -email="mischa@high5.nl" +email="vm01@high5.nl" sshkey="ssh-ed25519 AAAAC3NzDITE5AAAAik7Lmiq4l4gCoYCLkJ9wlqpNhR1gUnP5EnXJXzvMVl" hostname="deploytest1" username="deploytest1" diff --git a/vms/vm02.txt b/vms/vm02.txt index 715781b..36533d7 100644 --- a/vms/vm02.txt +++ b/vms/vm02.txt @@ -2,7 +2,7 @@ date="2018/07/02" payment="70" donated="" name="Test2 User" -email="devtest19@openbsd.amsterdam" +email="vm02@high5.nl" sshkey="ssh-ed25519 AAAAC3NzDI1NTE5AaaaIK7lMIQ4L4GcOyclKj9WLQPnHrGuP5ExjxZVmvLn" hostname="deploytest2" username="deploytest2" diff --git a/vms/vm03.txt b/vms/vm03.txt index 63a76f6..bd4c4cc 100644 --- a/vms/vm03.txt +++ b/vms/vm03.txt @@ -2,7 +2,7 @@ date="2020/07/21" payment="60" donated="" name="Test3" -email="devtest19@openbsd.amsterdam" +email="vm03@high5.nl" sshkey="ssh-ed25519 AAAAC3NzDI1NTE5AaaaIK7lMIQ4L4GcOyclKj9WLQPnHrGuP5ExjxZVmvLn" hostname="deploytest3" username="deploytest3"