From aaf95dbec81c13035afd16d3c8dc711076ddae4b Mon Sep 17 00:00:00 2001 From: mischa Date: Tue, 26 Oct 2021 09:30:17 +0200 Subject: [PATCH] changed relaunch.sh, added own notify template --- notify.pl | 4 ++-- relaunch.sh | 36 +++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/notify.pl b/notify.pl index ee918bc..dfadbc1 100755 --- a/notify.pl +++ b/notify.pl @@ -162,7 +162,7 @@ my @files = glob "$conf{'conf'}{'VMS'}/*.txt"; if ($function =~ /notify/) { mailout(\%conf, \%vms); -} elsif ($function =~ /(deployed|msg|thanx)/ and $function_variable !~ /empty/) { +} elsif ($function =~ /(deployed|redeployed|msg|thanx)/ and $function_variable !~ /empty/) { my %slice = %vms{$function_variable}; mailout(\%conf, \%slice); } elsif ($function =~ /(renewal|subscription|deprovision)/) { @@ -187,5 +187,5 @@ if ($function =~ /notify/) { } mailout(\%conf, \%vms); } else { - print "usage: " . basename($0) . " [stopped | renewal | notify | deprovision] | [deployed | msg | thanx] \n"; + print "usage: " . basename($0) . " [stopped | renewal | notify | deprovision] | [deployed | redeployed | msg | thanx] \n"; } diff --git a/relaunch.sh b/relaunch.sh index 5bf1da4..df8d272 100755 --- a/relaunch.sh +++ b/relaunch.sh @@ -29,17 +29,31 @@ if [[ ! -f "${VMS}/${1}.txt" ]]; then echo "unable to find ${VMS}/${1}" exit 1 fi -if [[ ! -f "${IMAGES}/${1}.qcow2" ]]; then - echo "unable to find ${IMAGES}/${1}.qcow2" - exit 1 -fi -/home/mischa/bin/deploy.pl +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 -/home/mischa/bin/notify.pl deployed ${1} -cp -v /home/mischa/templates/email-deployed.txt-orig /home/mischa/templates/email-deployed.txt +sleep 10 + +auto-deploy.exp ${1} +if [ $? != 0 ]; then + vmctl stop -f ${1} + rm -rf /var/vmm/${1}.qcow2 + pushover.pl -m "$(hostname -s) ${1} failed deploy" -p 1 + exit 1 +else + vmctl stop -f ${1} +fi + +deploy.pl +rcctl restart dhcpd +vmctl reload +sleep 10 + +auto-start.exp ${1} +if [ $? ]; then + echo + echo "SUCCES! - re-deployed ${1}" + notify.pl redeployed ${1} + pushover.pl -m "$(hostname -s) ${1} re-deployed" +fi