Page 1 of 1

Closed system when I close Virtual

Posted: 21. Aug 2008, 16:08
by KeRkYBoN
HI All,
do I run commands chained to the closing event of virtualmachine?

virtual --------> real system
[on poweroff ] -----> [shoutdown -now]

Posted: 21. Aug 2008, 16:10
by Sasquatch
You want to turn off your computer when you turn off the VM? Use a script that checks the VM state, if it's off, let it turn off your Host. This is not so hard to find with Google. There are plenty of example scripts for this.

Posted: 22. Aug 2008, 11:19
by KeRkYBoN
I write this....

what you think?
You can improve this?

Code: Select all

#!/bin/sh
#Start VirtualBox and Close System under shutdown virtual
su - >user< -c startx
su - >user< -c VBoxSDL -fullscreen -vm winlite >/home/>user</.VirtualBox/Machines/winlite/Logs/VBoxSDL.log 2>&1 &
while true
do
        if [ \"$( ps -fu >user< | grep /usr/lib/virtualbox/VirtualBox)\" = \"\" ]
        then
            shutdown now -h
            exit
        fi

        sleep 5
done

Posted: 22. Aug 2008, 12:29
by Sasquatch
Looks alright. Could use some improvement, but I don't have the proper knowledge for it yet. Test it and see if it works. If it does, you're done.

Posted: 22. Aug 2008, 17:07
by TerryE
Here is an excellent post. I forgot what the URL was but found it by doing a google /bin/sh startup site:forums.virtualbox.org. There is an awful lot of good stuff in the forum you look:

Posted: 25. Aug 2008, 12:20
by KeRkYBoN
I had already read
and I took inspiration for some new idea
but I would like to close this system with the control of the process with this while loop