Closed system when I close Virtual

Discussions related to using VirtualBox on Linux hosts.
Post Reply
KeRkYBoN
Posts: 3
Joined: 21. Aug 2008, 15:59

Closed system when I close Virtual

Post by KeRkYBoN »

HI All,
do I run commands chained to the closing event of virtualmachine?

virtual --------> real system
[on poweroff ] -----> [shoutdown -now]
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Post 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.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
KeRkYBoN
Posts: 3
Joined: 21. Aug 2008, 15:59

Post 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
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Post 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.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post 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:
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
KeRkYBoN
Posts: 3
Joined: 21. Aug 2008, 15:59

Post 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
Post Reply