dgzyk / phpvirtualbox

Automatically exported from code.google.com/p/phpvirtualbox
Other
0 stars 0 forks source link

vboxinit script for os x #543

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Has anyone worked on moving this script to be compatible with os x?

thanks,

Original issue reported on code.google.com by andyjh...@gmail.com on 11 Jun 2012 at 10:57

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
UPDATE:

iv written a very simple shell script which is run on startup of the Mac OS X 
Server. It launches both vboxwebsrv and then starts vm's before finishing. I 
hope someone else finds this usefull, this works perfectly with phpvirtualbox's 
'startup mode' option.

CODE:

#!/bin/sh

VBoxManage list vms | awk '{ print $NF }' | sed -e 's/[{}]//g' | while read 
UUID; do
    STARTUP=$(VBoxManage getextradata "$UUID" 'pvbx/startupMode')
    echo "$UUID: $STARTUP"

    if [ "$STARTUP" == "Value: auto" ]; then
            nohup VBoxManage startvm $UUID --type headless
            echo "$UUID: starting...";
        fi
cd /Applications/VirtualBox.app/Contents/MacOS
exec vboxwebsrv --background >/dev/null    
done

Original comment by andyjh...@gmail.com on 11 Jun 2012 at 3:26

GoogleCodeExporter commented 8 years ago
Hi,

Can this just be copied into /etc/init.d in OSX? What are the installation 
instructions for this script please?

Original comment by imooreya...@gmail.com on 26 Jun 2012 at 1:21

GoogleCodeExporter commented 8 years ago
It's not an init.d script, just save it and add it to your login items, someone 
with more knowledge can probably change it to a mac service :-)

Original comment by andyjh...@gmail.com on 26 Jun 2012 at 1:23

GoogleCodeExporter commented 8 years ago
Then it's not really an init script though because it requires you to log in :( 
Is that correct?

Original comment by imooreya...@gmail.com on 29 Jun 2012 at 4:52

GoogleCodeExporter commented 8 years ago
Unfortunately no it's not an init script, my initial question was IS THERE AN 
INIT SCRIPT, when I discovered there wasn't I wrote a quick bash script to do 
why I needed (start vms on login). It should be simple to modify this using 
Automator to make it a service which would run before login. 

Original comment by andyjh...@gmail.com on 29 Jun 2012 at 5:34

GoogleCodeExporter commented 8 years ago
Thank you so much for the script andy. It seems to be working great with my 
setup as well.
However, The autostart of my virtualbox guests doesnt work quite.

When running the script I get the UUID printed out with "no value set!".
The virtualmachine(s) doesnt autostart.
Any tips to what I can do? (Typing "VboxManage list vms" in terminal give me 
the UUID of the guest, so that part works nicely. I guess it must be a hickup 
with the if sentence in the script or something.

Original comment by tmidtbo@gmail.com on 3 Jul 2012 at 1:12

GoogleCodeExporter commented 8 years ago
You need to turn on the 'init' property in he phpvirtualbox config, it should 
say something like 'for use with the vbox.init script'

Original comment by andyjh...@gmail.com on 3 Jul 2012 at 4:04

GoogleCodeExporter commented 8 years ago
Ah of course, should have read the config better. I have enabled it now(removed 
the # sign in front of the "var $startStopConfig = true;"

However, I still have the same issue.

Did you overwrite the vboxinit file in your phpvirtualboxfolder with your 
script or did you do something extra?

Also another thing, I reckon we can also use the pause function when shutting 
down/rebooting our macs. (Like the one in vboxinit file)

Original comment by tmidtbo@gmail.com on 4 Jul 2012 at 9:58

GoogleCodeExporter commented 8 years ago
Once you've enabled that in the config you need to change the setting in the 
virtual machines 'settings panel' using phpvirtualbox. Yes you could also write 
a script for pausing but this didn't suit my purpose so I didn't :-)

Original comment by andyjh...@gmail.com on 4 Jul 2012 at 10:02

GoogleCodeExporter commented 8 years ago
Hm guess I need to have this in with a spoon, I cant find it under my settings 
panel(even with advanced config enabled).

Specifically where are you talking about?

(As long as I get this up and running, I will look into how to suspend the VMs 
before virtualbox host goes down on OSX and post here with (hopefully) a 
solution :)

Original comment by tmidtbo@gmail.com on 4 Jul 2012 at 11:02

GoogleCodeExporter commented 8 years ago
Never mind. I found the setting. (Enable advanced in phpvirtualbox config) 
General -> startup mode.

It also works :) (It did just manage to start one though, and not both of my 
VMs(both with startup mode are set to automatic now).

Original comment by tmidtbo@gmail.com on 4 Jul 2012 at 11:16

GoogleCodeExporter commented 8 years ago
hmm thats strange, did your console output show both as 'starting....' ?

Original comment by andyjh...@gmail.com on 4 Jul 2012 at 11:25

GoogleCodeExporter commented 8 years ago
Nope, only my Ubuntu Server is starting(which is the first item in the 
"VboxManage list vms" array).
The other VM is Windows 7. I double checked that both were in auto mode with 
the VboxManage getextradata "UUID" pvbx/startupMode in terminal as well.

Added a echo $UUID right after your "while read UUID; do" sentence and the 
result was that only one UUID was printed out in console. 

Did it another time, this time with echo "$UUID is alive and well" - and guess 
what, both were starting up :)

Seems my mac was in a bad mood for a second there.

Now, on to the suspend when shutting down/restarting the mac .... :)

Original comment by tmidtbo@gmail.com on 4 Jul 2012 at 11:56

GoogleCodeExporter commented 8 years ago
That's easy to implement the problem is getting the script to run BEFORE 
shutdown..

Original comment by andyjh...@gmail.com on 4 Jul 2012 at 12:31

GoogleCodeExporter commented 8 years ago
hello i have just finished my application for this the link is 
https://www.dropbox.com/s/4qiou3ehmatvsm9/run%20virtualbox%20webserv.app.zip

Original comment by brngat...@gmail.com on 5 Oct 2012 at 7:30

GoogleCodeExporter commented 8 years ago
Project moved to Sourceforge.net

https://sourceforge.net/projects/phpvirtualbox/

Original comment by imooreya...@gmail.com on 25 Jul 2013 at 4:54