You are not logged in.
Hi,
I need a very simple way to start a headless virtualbox vm on login, and cleanly save its state on system shutdown/reboot. I can't use solutions like vboxtool because my home directory is encrypted and only available after I login.
I have written a simple script to do what I need:
#!/bin/bash
if VBoxManage startvm --type headless archdev > /dev/null 2>&1; then
trap "VBoxManage controlvm archdev savestate > /dev/null 2>&1; exit" SIGINT SIGTERM
while true;
do
sleep 10h
done
fi
When I run this script in a interactive shell, all works as expected: It will successfully start the vm(archdev), and when I send SIGINT (using CTRL+C) it will cleanly save the vm state. The problem I'm facing is that when I start this script as a background process(sufix it with a '&') it will successfully start, but it will fail to cleanly save state on shutdown, since it seems to ignore signals send using 'kill' command(unless it is a SIGKILL). I highly appreciate an solution to this problem, by either explaining to me what is happening, or by providing an alternate one(as long it doesn't involve starting the vm with the system).
Thanks in advance.
Last edited by thiago (2011-09-04 14:54:44)
Offline
vboxmanage startvm --type headless VMNAME
put this to start at login
su -c 'vboxmanage controlvm VMNAME savestate' USERNAME
put this to /etc/rc.local.shutdown
O' rly ? Ya rly Oo
Offline
vboxmanage startvm --type headless VMNAME
put this to start at login
su -c 'vboxmanage controlvm VMNAME savestate' USERNAME
put this to /etc/rc.local.shutdown
Worked like a charm, thanks.
Offline
No problem, i m plesed to hear it suits you. Just a reminder to put [solved], before moderators do it
O' rly ? Ya rly Oo
Offline
No problem, i m plesed to hear it suits you. Just a reminder to put [solved], before moderators do it
Hey!
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline