I wrote a script that suspends all my VirtualBox machines, and put a line in
/etc/rc.local.shutdown, but it doesn't seem to work,
su - XX -c /XX
When I'm booting the next time, VirtualBox tells me the machine was
Aborted, so the script wasn't executed. (Launching that script manually works for me)
P.S I already enabled
The problem seems more complicated than I thought, in my
.bashrc, if it's running on
tty3, it executes
startx, so when systemd decide to shutdown/reboot, it whould kill
VBoxSVC process and other stuff when X Session dies.
I also tried to hack the source code of
xfsm-shutdown-helper, make a fake
systemctl that execute my script first, none of the above works.