Created
November 14, 2016 11:43
-
-
Save N1v0k/22b278a7121d7d7909e89efd1f9b232d to your computer and use it in GitHub Desktop.
Autostart Virtualbox VM with host
This file contains hidden or 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
sudo nano /etc/init.d/StartVM && sudo chmod +x /etc/init.d/StartVM && sudo update-rc.d StartVM defaults 99 01 | |
#! /bin/sh | |
# Start VirtualBox @boot | |
# /etc/init.d/StartVM | |
# | |
#Edit these variables! | |
VMUSER=user | |
VMNAME=VM1 | |
VMNAME2=Test | |
case "$1" in | |
start) | |
echo "Starting VirtualBox VM ..." | |
sudo -u $VMUSER VBoxHeadless --startvm $VMNAME & | |
sudo -u $VMUSER VBoxHeadless --startvm $VMNAME2 & | |
;; | |
stop) | |
echo "Saving state of Virtualbox VM ..." | |
sudo -u $VMUSER VBoxManage controlvm $VMNAME savestate | |
sudo -u $VMUSER VBoxManage controlvm $VMNAME2 savestate | |
;; | |
*) | |
echo "Usage: /etc/init.d/StartVM {start|stop}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment