Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Where to put script to shut down VBox VM's when shutting down Ubuntu

  1. #1
    Join Date
    Mar 2006
    Beans
    Hidden!

    [SOLVED!] Where to put script to shut down VBox VM's when shutting down Ubuntu

    I generally run a VM with XP on a separate desktop, and consistently forget I have it open when shutting down, which causes my laptop to freeze up.

    Writing a script is no great problem using:
    Code:
    VBoxManage controlvm XP poweroff
    but where do I put it so that it is run prior to the shutdown command?
    Last edited by Jose Catre-Vandis; February 23rd, 2009 at 10:27 PM. Reason: now SOLVED! - see post #27
    No longer participating......

  2. #2
    Join Date
    Jan 2008
    Beans
    1,395

    Re: Where to put script to shut down VBox VM's when shutting down Ubuntu

    Quote Originally Posted by Jose Catre-Vandis View Post
    I generally run a VM with XP on a separate desktop, and consistently forget I have it open when shutting down, which causes my laptop to freeze up.

    Writing a script is no great problem using:
    Code:
    VBoxManage controlvm XP poweroff
    but where do I put it so that it is run prior to the shutdown command?
    Im not great at scripting but the easiest way i can think of doing it would be:

    Code:
    VBoxManage controlvm XP poweroff
    
    sleep 20
    
    gnome-session-save --kill
    Put the code above it in a text file on your desktop and all it shutdown-script, then:

    Open a terminal

    Code:
    cd ~/Desktop
    Code:
    sudo chmod 777 /shutdown-script
    Code:
    sudo cp /shutdown-script /usr/bin/shutdown-script

    Now just run the command shutdown-script or add it to a launcher. Also i have only allowed 20 seconds till shutdown (for xp). You may need to alter this
    Last edited by Tomatz; February 1st, 2009 at 05:59 PM.
    Hmmm...

  3. #3
    Join Date
    Mar 2006
    Beans
    Hidden!

    Re: Where to put script to shut down VBox VM's when shutting down Ubuntu

    Thanks Tomatz

    It's not that part I have a problem with, I want to automate it as a part of the normal shut down routine (because I keep forgetting)

    We have a nice place for start up programs, but not for shut down scripts
    No longer participating......

  4. #4
    Join Date
    Jan 2008
    Beans
    1,395

    Re: Where to put script to shut down VBox VM's when shutting down Ubuntu

    The folder /etc/rc6.d holds all the scripts for shutdown BUT any script you make will have to watch for vbox to shutdown your guest OS before continuing with the host shutdown process. This could be problematic and is far beyond my experience.

    Maybe you should ask in the programing forum?
    Last edited by Tomatz; February 1st, 2009 at 07:22 PM.
    Hmmm...

  5. #5
    Join Date
    Mar 2006
    Beans
    Hidden!

    Re: Where to put script to shut down VBox VM's when shutting down Ubuntu

    bump?
    No longer participating......

  6. #6
    Join Date
    Mar 2006
    Location
    The Netherlands
    Beans
    82

    Re: Where to put script to shut down VBox VM's when shutting down Ubuntu

    You can use VBoxTool (see my sig) for controlled saving when the host goes down. It makes use of the init-system (as suggested above). It is doing much more, like autostarting sessions at boot, check the website if you'd like....

  7. #7
    Join Date
    Mar 2006
    Beans
    Hidden!

    Re: Where to put script to shut down VBox VM's when shutting down Ubuntu

    Thanks markba

    vboxtool is great, but I don't always want VMs to start when I boot up. Any way to block the autostart function? (I'll have a look in the scripts)
    No longer participating......

  8. #8
    Join Date
    Mar 2006
    Location
    The Netherlands
    Beans
    82

    Re: Where to put script to shut down VBox VM's when shutting down Ubuntu

    Blocking autostart is easy, just empty /etc/vboxtool/machines.conf: vboxtool will only autostart the sessions named in machines.conf. As an alternative, you can also comment them out by preceding the line by '#'.

    Autosave sessions does not depend on machines.conf, so even with an empty machines.conf, all sessions will be saved automatically on shutdown.
    Last edited by markba; February 18th, 2009 at 09:28 PM. Reason: typo

  9. #9
    Join Date
    Mar 2006
    Beans
    Hidden!

    Re: Where to put script to shut down VBox VM's when shutting down Ubuntu

    I'll need to rephrase what I said about vboxtool... it's a great idea....

    can't get it to work for love nor money.

    Won't start or stop or run any VM's with or without a GUI

    Not enough patience here this evening to perservere with it, but it has given me some ideas about how I can code to achieve what I want to do, using my original command.
    No longer participating......

  10. #10
    Join Date
    Mar 2006
    Location
    The Netherlands
    Beans
    82

    Re: Where to put script to shut down VBox VM's when shutting down Ubuntu

    Installation should not be that difficult, just follow these instructions: http://vboxtool.svn.sourceforge.net/...xt?view=markup

    But nevertheless, you can also implement your own solution, as allways: by studying code, you'll learn a lot. If you have any questions about vboxtool, just drop them here.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •