summaryrefslogtreecommitdiff
path: root/app-emulation/phpvirtualbox/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2018-07-14 21:03:06 +0100
committerV3n3RiX <venerix@redcorelinux.org>2018-07-14 21:03:06 +0100
commit8376ef56580626e9c0f796d5b85b53a0a1c7d5f5 (patch)
tree7681bbd4e8b05407772df40a4bf04cbbc8afc3fa /app-emulation/phpvirtualbox/files
parent30a9caf154332f12ca60756e1b75d2f0e3e1822d (diff)
gentoo resync : 14.07.2018
Diffstat (limited to 'app-emulation/phpvirtualbox/files')
-rw-r--r--app-emulation/phpvirtualbox/files/vboxinit-initd39
1 files changed, 39 insertions, 0 deletions
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
+}