From nobody Sat Jul 20 09:38:57 2024 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WR1hK4ZxPz5RLHn; Sat, 20 Jul 2024 09:38:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WR1hK3zt2z4n2P; Sat, 20 Jul 2024 09:38:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721468337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3jhcT7XxETIMhnIAAK3zN8Oluw9CcDyarwYgkfFJrIw=; b=IIhSOZPoyk44Tx/ghogEqfnzcnYfDIURpwdennxpx4HdT+g0mwJo+mScweFF9wiDbc6lqj WA1OqmWogIlSC/IUchI0YYH6BS57NuHCpVJV3IfxnPlDcFPubpk6DG1xG+jVjgB+zOl71w OdiTNx+FLt5Y/3PMvr0LYUtuWr1e4ah0yJyVpMiy2K9BpAlpiiLdHugVl5JFJeiag5+Gc1 YelsfqvI/SkTJgFu4MVgxcmzvIHrj8bvLFNdPzNd64mYZb96dJhdZtQ7uLGIo/XaRPzL+G ynN2ALbrF9JoAgH6s/2JfCRA/QBH5IrtgvhC5Y4wGqkAOp0mnI2PN1ouU4YqkQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721468337; a=rsa-sha256; cv=none; b=Ue0qJUskeMr+Xng4Ob/OAXmX4bOxcDyaFn4caYyrlzCRxMel0FaPHc+PGcAX4127cUiIXD Pb1ygVmS3r9pF/tb7N2kT8Onvaq6+/ew1amq3qF2cDqv6OZzzM2fbjkri5onKH+MEd2m2y QwP+7pppiqW3QxF90SxToYfmJT3IoPrJB3T5TaUQrKAlMFJYHTXzX9fvQV/ppjJld5+Zml HF3LqYRBV7A23UfLjTJFGuajYvUtigPWmyP1Hw4P8Yf3MWeWGQd0OUpUGvXV8enskw/7CR 5BacMXLF537jDmPx+va1hWR/CESSSE926yz4ADtRY2VvU0Vz+WH7yQ99dUc4rw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721468337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3jhcT7XxETIMhnIAAK3zN8Oluw9CcDyarwYgkfFJrIw=; b=VVQ5EszlYkGhrjzlMHKZtqRoflvumaxvFunITTtB3zkw82NGgOfq8EYgnIzRy1LYGFCIxY 3FBZsdKm7ZJOoNQVZsw7V1Zz5M3LnCkTi30YyNyTutpeOsYXPehiD4H/uFPuHVzSojm5nd mDLre3UrUje1JA5lDAxiHoUtxXwz6X7cN4cASKAcz6SLP1r265M+fBh4WiEyN8dDJzdj8f fXR1KO7tgN11CvJ0dsVqDyzQCw5N2lWdoUo5cJfb8FWhefsDqdg1hXLhWzwQjgccwYQIpp ZVS3yT9+9Cshx+D7VqMJ8i1Iz8Nua84wkun7WB6OrJy3ghDveKA8So8aLTaayQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WR1hK2sMkz19y8; Sat, 20 Jul 2024 09:38:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46K9cvQR004002; Sat, 20 Jul 2024 09:38:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46K9cvqN003999; Sat, 20 Jul 2024 09:38:57 GMT (envelope-from git) Date: Sat, 20 Jul 2024 09:38:57 GMT Message-Id: <202407200938.46K9cvqN003999@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-branches@FreeBSD.org From: Vladimir Druzenko Subject: git: a7ad8c6ed66d - 2024Q3 - emulators/virtualbox-ose{,-nox11}: add vboxinit start/stop script for VMs which is controlled from phpvirtualbox List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-ports-all@freebsd.org Sender: owner-dev-commits-ports-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vvd X-Git-Repository: ports X-Git-Refname: refs/heads/2024Q3 X-Git-Reftype: branch X-Git-Commit: a7ad8c6ed66dba46703feed4c1df0b47b0ed7482 Auto-Submitted: auto-generated The branch 2024Q3 has been updated by vvd: URL: https://cgit.FreeBSD.org/ports/commit/?id=a7ad8c6ed66dba46703feed4c1df0b47b0ed7482 commit a7ad8c6ed66dba46703feed4c1df0b47b0ed7482 Author: Vladimir Druzenko AuthorDate: 2024-07-09 21:25:25 +0000 Commit: Vladimir Druzenko CommitDate: 2024-07-20 09:38:08 +0000 emulators/virtualbox-ose{,-nox11}: add vboxinit start/stop script for VMs which is controlled from phpvirtualbox Set the "Startup Mode" to "Automatic" for the virtual machine in phpvirtualbox to automatically start the virtual machine during OS boot. This script also stops virtual machines during reboot even if vboxinit_enable="YES" is not present in /etc/rc.conf. phpvirtualbox uses the "Web Service" (WEBSERVICE) to configure and manage virtual machines, so we install the script only when the WEBSERVICE option is enabled. PR: 280062 (cherry picked from commit d0deb35b6952e0d73c111c6534462dcbd5d77774) --- emulators/virtualbox-ose-nox11/Makefile | 2 +- emulators/virtualbox-ose/Makefile | 4 +- emulators/virtualbox-ose/files/vboxinit.in | 91 ++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-) 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..93cbd55a9d84 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 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"