#!/bin/sh # # VBoxLauncher - luis peralta # http://www.ziritione.org . /etc/rc.common # Set this to the user who created the VMs USER=peralta PROPERTY="launchatboot" StartService() { UUIDS=`sudo -i -u $USER /usr/bin/VBoxManage list vms|grep "^UUID:"|cut -d" " -f 13` for uuid in $UUIDS do ConsoleMessage "launching $uuid vm" sudo -i -u $USER /usr/bin/VBoxManage guestproperty get $uuid $PROPERTY > /dev/null && sudo -i -b -u $USER /usr/bin/VBoxHeadless -startvm $uuid > /dev/null done } StopService() { UUIDS=`sudo -i -u $USER /usr/bin/VBoxManage list runningvms|tail +5` for uuid in $UUIDS do sudo -i -u $USER /usr/bin/VBoxManage controlvm "$uuid" poweroff > /dev/null ConsoleMessage "$uuid stopped" done } RestartService() { StopService StartService } RunService "$1"