Created
February 5, 2022 10:00
-
-
Save gerardag/9c2295ce6cfef3e368fb1e5c4516feee to your computer and use it in GitHub Desktop.
Auto-start VirtualBox VMs (headless) after reboot on Mac OSX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
First of all get your username and machine name using the following commands | |
$ whoami | |
$ VBoxManage list vms | |
After that, locate (or create) the following file and open it: | |
$ cat /Users/[your-username]/Library/LaunchAgents/org.virtualbox.launch.[your-machine-name].plist | |
Once opened, paste the following content: | |
--> | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>org.virtualbox.launch.[your-machine-name]</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/Applications/VirtualBox.app/Contents/MacOS/VBoxManage</string> | |
<string>startvm</string> | |
<string>[your-machine-name]</string> | |
<string>--type</string> | |
<string>headless</string> | |
</array> | |
<key>RunAtLoad</key> | |
<true/> | |
</dict> | |
</plist> | |
<!-- | |
Save the file and you can test if the script works using the below command: | |
$ launchctl load /Users/[your-username]/Library/LaunchAgents/org.virtualbox.launch.[your-machine-name].plist | |
--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment