#!/bin/sh # # Use only with permission. # . /etc/rc.common USER=peralta PROPERTY="lauchatboot" StartService() { UUIDS=`sudo -i -u $USER /usr/bin/VBoxManage list vms|perl -ne 'if (/\{([0-9a-f-]+)\}/) {print "$1\n"}'` 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|perl -ne 'if (/\{([0-9a-f-]+)\}/) {print "$1\n"}'` 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"