FreeBSD Bugzilla – Attachment 251794 Details for
Bug 280062
emulators/virtualbox-ose{,-legacy}: add vboxinit start/stop script for VMs which is controlled from phpvirtualbox
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
add vboxinit patch
virtualbox-ose_vboxinit.diff (text/plain), 8.15 KB, created by
Vladimir Druzenko
on 2024-06-30 14:02:29 UTC
(
hide
)
Description:
add vboxinit patch
Filename:
MIME Type:
Creator:
Vladimir Druzenko
Created:
2024-06-30 14:02:29 UTC
Size:
8.15 KB
patch
obsolete
>diff --git a/emulators/virtualbox-ose-legacy/Makefile b/emulators/virtualbox-ose-legacy/Makefile >index 2bcb4488401e..c64848da2f03 100644 >--- a/emulators/virtualbox-ose-legacy/Makefile >+++ b/emulators/virtualbox-ose-legacy/Makefile >@@ -1,6 +1,6 @@ > PORTNAME= virtualbox-ose > PORTVERSION= 5.2.44 >-PORTREVISION?= 19 >+PORTREVISION?= 20 > CATEGORIES= emulators > MASTER_SITES= https://download.oracle.com/virtualbox/${PORTVERSION}/:src \ > LOCAL/bofh/emulators/virtualbox-ose-legacy:docs >@@ -159,7 +159,7 @@ PLIST_SUB+= QT="@comment " > .endif > > .if ${PORT_OPTIONS:MWEBSERVICE} >-USE_RC_SUBR+= vboxwebsrv >+USE_RC_SUBR+= vboxinit vboxwebsrv > VBOX_LINKS+= vboxwebsrv > VBOX_UTILS+= vboxwebsrv webtest > .endif >diff --git a/emulators/virtualbox-ose-legacy/files/vboxinit.in b/emulators/virtualbox-ose-legacy/files/vboxinit.in >new file mode 100644 >index 000000000000..13ec9614827d >--- /dev/null >+++ b/emulators/virtualbox-ose-legacy/files/vboxinit.in >@@ -0,0 +1,91 @@ >+#!/bin/sh >+ >+# PROVIDE: vboxinit >+# REQUIRE: LOGIN vboxnet vboxwebsrv sshd >+# KEYWORD: shutdown >+# >+# Add the following line to /etc/rc.conf[.local] to enable vboxinit >+# >+# vboxinit_enable (bool): Set to "NO" by default. >+# Set it to "YES" to enable vboxinit. >+# stop and faststop are always enabled. >+# vboxinit_user (str): Default user account to run with. >+# (default: %%VBOXUSER%%) >+# vboxinit_home (str): Default home directory to run with. >+# (default: home of user ${vboxinit_user} >+# vboxinit_stop (str): Default stop cmd for VBoxManage controlvm. >+# (default: savestate) >+# vboxinit_start_delay (int): Default startup delay in seconds. >+# (default: 0) >+# vboxinit_stop_delay (int): Default shutdown delay in seconds. >+# (default: 0) >+# >+# Set the "Startup Mode" to "Automatic" for the virtual machine in >+# phpvirtualbox to automatically start the virtual machine during OS boot. >+# >+ >+. /etc/rc.subr >+ >+name="vboxinit" >+rcvar="${name}_enable" >+ >+start_cmd="${name}_start" >+stop_cmd="${name}_stop" >+status_cmd="${name}_status" >+restart_cmd="${name}_restart" >+ >+vboxinit_start() >+{ >+ # Get a list of all machines with autorun enabled in phpvirtualbox >+ ${su_command} "${command} list vms | /usr/bin/tr -d '{}\"'" | while read VMNAME UUID; do >+ STARTUP=$(${su_command} "${command} getextradata ${UUID} 'pvbx/startupMode'" | /usr/bin/cut -d' ' -f2) >+ if [ "${STARTUP}" == "auto" ]; then >+ echo "${name}: starting machine ${VMNAME} ..." >+ ${su_command} "${command} startvm ${UUID} --type headless" >+ sleep "${vboxinit_start_delay}" >+ fi >+ done >+} >+ >+vboxinit_stop() >+{ >+ # Get all running machines >+ ${su_command} "${command} list runningvms | /usr/bin/tr -d '{}\"'" | while read VMNAME UUID; do >+ echo "${name}: stopping machine ${VMNAME} with action '${vboxinit_stop}' ..." >+ ${su_command} "${command} controlvm ${UUID} ${vboxinit_stop}" >+ sleep "${vboxinit_stop_delay}" >+ done >+} >+ >+vboxinit_status() >+{ >+ # List all running machines >+ ${su_command} "${command} list runningvms" >+} >+ >+vboxinit_restart() >+{ >+ vboxinit_stop >+ vboxinit_start >+} >+ >+load_rc_config $name >+ >+: ${vboxinit_enable="NO"} >+: ${vboxinit_user="%%VBOXUSER%%"} >+: ${vboxinit_home=$(/usr/sbin/pw usershow -7 -n "${vboxinit_user}" | /usr/bin/cut -d: -f6)} >+: ${vboxinit_stop="savestate"} >+: ${vboxinit_start_delay="0"} >+: ${vboxinit_stop_delay="0"} >+HOME=${vboxinit_home} >+USER=${vboxinit_user} >+export HOME USER >+ >+command="%%VBOXDIR%%/VBoxManage" >+su_command="/usr/bin/su -m ${vboxinit_user} -c" >+ >+if [ "x$1" = "xstop" ] || [ "x$1" = "xfaststop" ]; then >+ vboxinit_enable="YES" >+fi >+ >+run_rc_command "$1" >diff --git a/emulators/virtualbox-ose-nox11-legacy/Makefile b/emulators/virtualbox-ose-nox11-legacy/Makefile >index 33102a46f019..0406eecfc7aa 100644 >--- a/emulators/virtualbox-ose-nox11-legacy/Makefile >+++ b/emulators/virtualbox-ose-nox11-legacy/Makefile >@@ -1,4 +1,4 @@ >-PORTREVISION= 17 >+PORTREVISION= 18 > PKGNAMESUFFIX= -nox11-legacy > > OPTIONS_EXCLUDE= ALSA DBUS DEBUG GUESTADDITIONS DOCS NLS PULSEAUDIO >diff --git a/emulators/virtualbox-ose-nox11/Makefile b/emulators/virtualbox-ose-nox11/Makefile >index 028c53d1ce91..d2db9016af94 100644 >--- a/emulators/virtualbox-ose-nox11/Makefile >+++ b/emulators/virtualbox-ose-nox11/Makefile >@@ -1,4 +1,4 @@ >-PORTREVISION= 0 >+PORTREVISION= 1 > PKGNAMESUFFIX= -nox11 > > OPTIONS_EXCLUDE= ALSA DBUS DEBUG GUESTADDITIONS DOCS NLS PULSEAUDIO \ >diff --git a/emulators/virtualbox-ose/Makefile b/emulators/virtualbox-ose/Makefile >index dfacba9c10a0..498bcd9b2dc8 100644 >--- a/emulators/virtualbox-ose/Makefile >+++ b/emulators/virtualbox-ose/Makefile >@@ -1,6 +1,6 @@ > PORTNAME= virtualbox-ose > PORTVERSION= 6.1.50 >-PORTREVISION?= 2 >+PORTREVISION?= 3 > CATEGORIES= emulators > MASTER_SITES= https://download.virtualbox.org/virtualbox/${PORTVERSION}/:src \ > LOCAL/bofh/emulators/virtualbox-ose:docs >@@ -167,7 +167,7 @@ PLIST_SUB+= QT="@comment " > .endif > > .if ${PORT_OPTIONS:MWEBSERVICE} >-USE_RC_SUBR+= vboxwebsrv >+USE_RC_SUBR+= vboxinit vboxwebsrv > VBOX_LINKS+= vboxwebsrv > VBOX_UTILS+= vboxwebsrv webtest > .endif >@@ -282,6 +282,10 @@ post-patch: > ${WRKSRC}/LocalConfig.kmk > @${ECHO_CMD} 'VBOX_GCC_PEDANTIC_CXX = -Wshadow $$(VBOX_GCC_WARN) -Wno-long-long' >> \ > ${WRKSRC}/LocalConfig.kmk >+#.else >+# @${ECHO_CMD} 'VBOX_GCC_PEDANTIC_CXX = -Wno-dynamic-exception-spec \ >+# -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION' >> \ >+# ${WRKSRC}/LocalConfig.kmk > .endif > .if empty(PORT_OPTIONS:MX11) > @${ECHO} 'VBOX_WITH_VMSVGA3D =' >> ${WRKSRC}/LocalConfig.kmk >diff --git a/emulators/virtualbox-ose/files/vboxinit.in b/emulators/virtualbox-ose/files/vboxinit.in >new file mode 100644 >index 000000000000..13ec9614827d >--- /dev/null >+++ b/emulators/virtualbox-ose/files/vboxinit.in >@@ -0,0 +1,91 @@ >+#!/bin/sh >+ >+# PROVIDE: vboxinit >+# REQUIRE: LOGIN vboxnet vboxwebsrv sshd >+# KEYWORD: shutdown >+# >+# Add the following line to /etc/rc.conf[.local] to enable vboxinit >+# >+# vboxinit_enable (bool): Set to "NO" by default. >+# Set it to "YES" to enable vboxinit. >+# stop and faststop are always enabled. >+# vboxinit_user (str): Default user account to run with. >+# (default: %%VBOXUSER%%) >+# vboxinit_home (str): Default home directory to run with. >+# (default: home of user ${vboxinit_user} >+# vboxinit_stop (str): Default stop cmd for VBoxManage controlvm. >+# (default: savestate) >+# vboxinit_start_delay (int): Default startup delay in seconds. >+# (default: 0) >+# vboxinit_stop_delay (int): Default shutdown delay in seconds. >+# (default: 0) >+# >+# Set the "Startup Mode" to "Automatic" for the virtual machine in >+# phpvirtualbox to automatically start the virtual machine during OS boot. >+# >+ >+. /etc/rc.subr >+ >+name="vboxinit" >+rcvar="${name}_enable" >+ >+start_cmd="${name}_start" >+stop_cmd="${name}_stop" >+status_cmd="${name}_status" >+restart_cmd="${name}_restart" >+ >+vboxinit_start() >+{ >+ # Get a list of all machines with autorun enabled in phpvirtualbox >+ ${su_command} "${command} list vms | /usr/bin/tr -d '{}\"'" | while read VMNAME UUID; do >+ STARTUP=$(${su_command} "${command} getextradata ${UUID} 'pvbx/startupMode'" | /usr/bin/cut -d' ' -f2) >+ if [ "${STARTUP}" == "auto" ]; then >+ echo "${name}: starting machine ${VMNAME} ..." >+ ${su_command} "${command} startvm ${UUID} --type headless" >+ sleep "${vboxinit_start_delay}" >+ fi >+ done >+} >+ >+vboxinit_stop() >+{ >+ # Get all running machines >+ ${su_command} "${command} list runningvms | /usr/bin/tr -d '{}\"'" | while read VMNAME UUID; do >+ echo "${name}: stopping machine ${VMNAME} with action '${vboxinit_stop}' ..." >+ ${su_command} "${command} controlvm ${UUID} ${vboxinit_stop}" >+ sleep "${vboxinit_stop_delay}" >+ done >+} >+ >+vboxinit_status() >+{ >+ # List all running machines >+ ${su_command} "${command} list runningvms" >+} >+ >+vboxinit_restart() >+{ >+ vboxinit_stop >+ vboxinit_start >+} >+ >+load_rc_config $name >+ >+: ${vboxinit_enable="NO"} >+: ${vboxinit_user="%%VBOXUSER%%"} >+: ${vboxinit_home=$(/usr/sbin/pw usershow -7 -n "${vboxinit_user}" | /usr/bin/cut -d: -f6)} >+: ${vboxinit_stop="savestate"} >+: ${vboxinit_start_delay="0"} >+: ${vboxinit_stop_delay="0"} >+HOME=${vboxinit_home} >+USER=${vboxinit_user} >+export HOME USER >+ >+command="%%VBOXDIR%%/VBoxManage" >+su_command="/usr/bin/su -m ${vboxinit_user} -c" >+ >+if [ "x$1" = "xstop" ] || [ "x$1" = "xfaststop" ]; then >+ vboxinit_enable="YES" >+fi >+ >+run_rc_command "$1"
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 280062
:
251794
|
251795
|
251796
|
251797
|
251798
|
251799