I am running multiple VMs (Virtualbox 5 and 6) on Debian 8 and **I need the VMs to shut down or savetate before the host is turned off by the UPS shutdown signal** (Or Poweroff buton or shutdown command).
I have created a script that starts the VMs as a service
/etc/systemd/system/vncservice.service
Code: Select all
[Unit]
Description=VBox Virtual Machine %i Service
Requires=systemd-modules-load.service
After=systemd-modules-load.service
[Service]
User=usuario
Group=vboxusers
ExecStart=/home/scripts/script.start.sh
ExecStop=/home/scripts/script.stop.sh
RemainAfterExit=true
KillMode=none
[Install]
WantedBy=multi-user.target
/home/scripts/script.start.sh
Code: Select all
#!/bin/bash
echo "Starting VMs...."
export DISPLAY=:1
/usr/bin/vboxmanage startvm VM1 --type gui
/usr/bin/vboxmanage startvm VM2 --type gui
/home/scripts/script.stop.sh
Code: Select all
#!/bin/sh -
export DISPLAY=:1
echo "Apagando VMs...."
/usr/bin/VBoxManage controlvm VM1 acpipowerbutton
/usr/bin/VBoxManage controlvm VM2 acpipowerbutton
Any suggestions or another way to do this?