dogi / ole--vagrant-community

0 stars 19 forks source link

boot vm on boot on mac #11

Closed xinglunxu closed 8 years ago

xinglunxu commented 8 years ago

Add installvagrantboot.sh under macosx. This file will run the necessary configuration to make the mac system auto boot the vm machine on boot.

Since it is my first time writing a formal script, it might look ugly.

A few things to mention: a). This file need to be run as root user. So if it is run manually, do sudo sh installvagrantboot.sh

b). I used sudo -u ${LOGNAME} vboxmanage startvm $VMNAME --type headless instead of sudo -u ${LOGNAME} vagrant reload $VMNAME because it seems that the "vagrant reload" command fail to target the vm by using its name, "community" in this case. Not sure if this matter.

WARNING!!!: Since I use the vboxmanage interface instead of the vagrant interface, after the virtual machine is successfully turned on, the "vagrant global-status" will still see the machine as "poweroff". You can use command "vboxmanage list runningvms" to check the current running vm or just try to run the App link on firefox to see if it work.

c). After running this script file, instead of literally restarting the mac system for testing, run the following command. sudo launchctl load /Library/LaunchDaemons/com.vagrantboot.test.plist If this fail, then run the following. sudo launchctl unload /Library/LaunchDaemons/com.vagrantboot.test.plist sudo launchctl load /Library/LaunchDaemons/com.vagrantboot.test.plist

d). This script will generate stdo.txt and stde.txt files on the same folder to receive general and error messages correspondingly.

So if things go wrong, look inside these two files to get the error message.