Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions scripts/vm/thornsec.vm.control.stopVM
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,27 @@ stopVm() {
(( pullPlug-- ));
sleep 1;
done;
if sudo -u vboxuser_"${vm}" VBoxManage showvminfo "${vm}" --machinereadable | grep running
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use vmRunning "${vm}" here as per L25 - if vmRunning doesn't do what you need, gimme a pull request :)

Merry Christmas, btw.

then
exit 0
else
printf "...no need!\n\n";
sudo -u vboxuser_"${vm}" VBoxManage controlvm "${vm}" acpipowerbutton;
fi;

if vmRunning "${vm}" && [ ${pullPlug} -eq 0 ]; then
printf "15 seconds has elapsed.\nPulling the plug.\n\n";
sudo -u vboxuser_"${vm}" VBoxManage controlvm "${vm}" poweroff;
wait $!;
echo "Attempting holding down the (virtual) powerbutton"
sudo -u vboxuser_"${vm}" VBoxManage controlvm "${vm}" poweroff
sleep 30
fi
##
## We actually want to do a pgrep on the VMS and kill -9 it before we discard the state, but this is like totally and emergency thing if the VM will netiher start nor turn off
## if sudo -u vboxuser_"${vm}" VBoxManage showvminfo "${vm}" --machinereadable | grep poweroff
##then
## exit 0
##else
## echo "Bugger, okay pulling the (virtual) power cord"
## sudo -u vboxuser_"${vm}" VBoxManage discardstate "${vm}"
##fi
##else
## printf "...no need!\n\n";
## sudo -u vboxuser_"${vm}" VBoxManage controlvm "${vm}" acpipowerbutton;
##fi;

return $?;
}
Expand Down