Skip to content

Instantly share code, notes, and snippets.

@N1v0k
Created November 14, 2016 11:43
Show Gist options
  • Save N1v0k/22b278a7121d7d7909e89efd1f9b232d to your computer and use it in GitHub Desktop.
Save N1v0k/22b278a7121d7d7909e89efd1f9b232d to your computer and use it in GitHub Desktop.
Autostart Virtualbox VM with host
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