From 35bfa8a28d16e276045fa583d5064eae849883c0 Mon Sep 17 00:00:00 2001 From: mischa Date: Mon, 5 Jul 2021 16:27:16 +0200 Subject: [PATCH] subscription logic changed for notify.pl --- mvvm.sh | 2 +- notify.pl | 2 +- relaunch.sh | 4 ++-- vms/vm01.txt | 2 +- vms/vm02.txt | 2 +- vms/vm03.txt | 2 +- vms/vm04.txt | 14 ++++++++++++++ 7 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 vms/vm04.txt diff --git a/mvvm.sh b/mvvm.sh index 45cff8d..2c09b62 100755 --- a/mvvm.sh +++ b/mvvm.sh @@ -53,5 +53,5 @@ if [ -f "/var/vmm/${1}.qcow2" ]; then echo -n "Size of qcow2: " ls -alh /var/vmm/${1}.qcow2 | awk '{print $5}' echo "rsync -ve 'ssh -p 31415 -i ~mischa/.ssh/id_ed25519' --rsync-path='doas rsync' /var/vmm/${1}.qcow2 mischa@${2}.obsda.ms:/var/vmm/${3}.qcow2" - rsync -ve 'ssh -p 31415 -i ~mischa/.ssh/id_ed25519' --rsync-path='doas rsync' /var/vmm/${1}.qcow2 mischa@${2}.obsda.ms:/var/vmm/${3}.qcow2 && pushover.pl -m "rsync ${3} done" + rsync -ve 'ssh -p 31415 -i ~mischa/.ssh/id_ed25519' --rsync-path='doas rsync' /var/vmm/${1}.qcow2 mischa@${2}.obsda.ms:/var/vmm/${3}.qcow2 && pushover.pl -m "rsync ${3} to ${2} done" fi diff --git a/notify.pl b/notify.pl index 6a67111..fa0a8c7 100755 --- a/notify.pl +++ b/notify.pl @@ -175,7 +175,7 @@ if ($function =~ /notify/) { if (defined $vms{$vm_name}{'subscription'} and $vms{$vm_name}{'subscription'} =~ /yes/) { delete $vms{$vm_name}; next; } } if ($function =~ /subscription/) { - if (defined $vms{$vm_name}{'subscription'} and $vms{$vm_name}{'subscription'} eq "") { delete $vms{$vm_name}; next; } + if (!defined $vms{$vm_name}{'subscription'} or $vms{$vm_name}{'subscription'} eq "" or $vms{$vm_name}{'subscription'} =~ /no/) { delete $vms{$vm_name}; next; } } } mailout(\%conf, \%vms); diff --git a/relaunch.sh b/relaunch.sh index d91fc1b..5bf1da4 100755 --- a/relaunch.sh +++ b/relaunch.sh @@ -34,12 +34,12 @@ if [[ ! -f "${IMAGES}/${1}.qcow2" ]]; then exit 1 fi -deploy.pl +/home/mischa/bin/deploy.pl rcctl restart dhcpd vmctl reload vmctl start ${1} sleep 30 echo "SUCCES! - deployed ${1}" cp -v /home/mischa/templates/email-deployed.txt-redeploy /home/mischa/templates/email-deployed.txt -notify.pl deployed ${1} +/home/mischa/bin/notify.pl deployed ${1} cp -v /home/mischa/templates/email-deployed.txt-orig /home/mischa/templates/email-deployed.txt diff --git a/vms/vm01.txt b/vms/vm01.txt index 3ac641f..5da96ce 100644 --- a/vms/vm01.txt +++ b/vms/vm01.txt @@ -1,7 +1,7 @@ mac="fe:e1:ab:dd:73:a4" ip="192.168.1.1" owner="testuser1" -date="2018/05/02" +date="2018/07/02" payment="70" donated="" name="Test1 User" diff --git a/vms/vm02.txt b/vms/vm02.txt index 4ffd5df..27e4586 100644 --- a/vms/vm02.txt +++ b/vms/vm02.txt @@ -1,4 +1,4 @@ -date="2018/02/02" +date="2018/07/02" payment="70" subscription="" donated="" diff --git a/vms/vm03.txt b/vms/vm03.txt index 12b6e44..3b506a9 100644 --- a/vms/vm03.txt +++ b/vms/vm03.txt @@ -1,4 +1,4 @@ -date="2020/02/21" +date="2020/07/21" payment="60" subscription="yes" donated="" diff --git a/vms/vm04.txt b/vms/vm04.txt new file mode 100644 index 0000000..34f947e --- /dev/null +++ b/vms/vm04.txt @@ -0,0 +1,14 @@ +date="2020/07/21" +payment="60" +subscription="no" +donated="" +name="Test3" +email="vm03@high5.nl" +sshkey="ssh-ed25519 AAAAC3NzDI1NTE5AaaaIK7lMIQ4L4GcOyclKj9WLQPnHrGuP5ExjxZVmvLn" +hostname="deploytest3" +username="deploytest3" +note="here be dragons!" +memory="512M" +disk2="" +format="qcow2" +referral=""