From 4f2d7949f03e1c198bc888f2d05f421d35c57e21 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Mon, 9 Oct 2017 18:53:29 +0100 Subject: reinit the tree, so we can have metadata --- app-emulation/phpvirtualbox/files/vboxinit-initd | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app-emulation/phpvirtualbox/files/vboxinit-initd (limited to 'app-emulation/phpvirtualbox/files') diff --git a/app-emulation/phpvirtualbox/files/vboxinit-initd b/app-emulation/phpvirtualbox/files/vboxinit-initd new file mode 100644 index 000000000000..891137a2d267 --- /dev/null +++ b/app-emulation/phpvirtualbox/files/vboxinit-initd @@ -0,0 +1,39 @@ +#!/sbin/openrc-run + +description="Controls VirtualBox sessions" + +. /etc/conf.d/vboxwebsrv + +su_command="su - ${VBOXWEBSRV_USER} -c" + +depend() { + need localmount + after bootmisc +} + +start() { + einfo "Starting VirtualBox machines" + eindent + MACHINES=$($su_command "VBoxManage list vms | awk '{ print \$NF }' | sed -e 's/[{}]//g'") + for UUID in $MACHINES; do + STARTUP=$($su_command "VBoxManage getextradata $UUID 'pvbx/startupMode'" | awk '{ print $NF }') + VMNAME=$($su_command "VBoxManage showvminfo $UUID | sed -n '0,/^Name:/s/^Name:[ \t]*//p'") + if [ "${STARTUP}" == "auto" ]; then + ebegin "Starting machine ${VMNAME}" + $su_command "VBoxManage startvm $UUID --type headless" &>> /var/log/vboxinit.log + eend $? + fi + done +} + +stop() { + einfo "Saving VirtualBox machines" + eindent + MACHINES=$($su_command "VBoxManage list runningvms | awk '{ print \$NF }' | sed -e 's/[{}]//g'") + for UUID in $MACHINES; do + VMNAME=$($su_command "VBoxManage showvminfo $UUID | sed -n '0,/^Name:/s/^Name:[ \t]*//p'") + ebegin "Stopping machine ${VMNAME}" + $su_command "VBoxManage controlvm $UUID savestate" &>> /var/log/vboxinit.log + eend $? + done +} -- cgit v1.2.3