0

Sorry for my English, I used a translation tool

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

[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

Another that starts them

/home/scripts/script.start.sh

#!/bin/bash
echo "Starting VMs...."
export DISPLAY=:1
/usr/bin/vboxmanage startvm VM1 --type gui
/usr/bin/vboxmanage startvm VM2 --type gui

And another that turns them off

/home/scripts/script.stop.sh

#!/bin/sh -
export DISPLAY=:1
echo "Apagando VMs...."
/usr/bin/VBoxManage controlvm VM1 acpipowerbutton
/usr/bin/VBoxManage controlvm VM2 acpipowerbutton

The script works on host power on, but it doesn't turn them off in time, the host shuts down before the VMs, I don't know how to delay the host shutdown

Any suggestions or another way to do this?

cube3
  • 1

0 Answers0