From nobody Tue Jul 09 21:31:33 2024 X-Original-To: dev-commits-ports-main@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 4WJZ1f0nxFz5R7Hm; Tue, 09 Jul 2024 21:31:34 +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 4WJZ1d4rkyz52rd; Tue, 9 Jul 2024 21:31:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720560693; 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=1ocKW4lyoGazZDgQRYVrY+mtjU69Y4ozRZm7tLWAmk0=; b=HEIX4JAzwcmZrZamllA4JKR7lNh4Ue+LacEtRZjiUBN0WEAsbMSqJMXjRZz9vTILAhlXt3 rkp2nA/xf7k75UFYNOiKMJtDBRsDBi+8qmPgn8Q6PbMtXKlhAC/OsZwIXfXIkJ5Ub1uHQS KzpciMbNkyWCyhyfYJPRzSy/67tJVrGKR9aNwVgJt7JCewKtdkL3TmYLWhCyBf3sHoiGdT pdFv9mF5X3Pjf+s3iDe/V+ynHnnqsuDfyNIgAPECL3BI5FhgcIEdt1o/9SdASVe5al/NiL 6JnsZ68tUFAu9YTjJVEWzDOVdUOwcPk+AsNlZXImzo7ntwEyT6nalY1+HYOgwQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720560693; a=rsa-sha256; cv=none; b=Kypto+BO0YGPX3fylyFDYqnnAfw5mEa/9ULSNPVHjOxLm3bK0ZAb0HucIIKI2Qk+o4Jpuv RdP71rtwhjoiGj3uZyquaY4i7/25sO00Poa7VDBqKubvfDN4c/hV8acAoQdki9poOXRMD8 6KoDM1o87WMMO/XwAg3nzGCysjcZxx5fKvL1qSKp4IYXlAY4hlGOOGsMTJgZgdbXQNQeZR LWkXB0YZ+uMbJ7LjxCN8t2UKuCaZJ9wx0mOCNaO2ETzq8K+Rjo41YHs1GLrRGmGxwi6ELR yXuT20tRkcfrFqVyM7R727NNVEgbb9907wVp0qVvhLEh4NjtPQchbKrErfDJMA== 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=1720560693; 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=1ocKW4lyoGazZDgQRYVrY+mtjU69Y4ozRZm7tLWAmk0=; b=n17zw6mKMAzf4jsAngjEr2VLoHCcRaeUElKL1hisjsGHZ0YliKEQFLXiQed6rU5sexG0MT tr40YNX6Ni2DA8bCeWvObm7TUsXG5H7dd+h7EIThMvzidRCUYjKJwvfOLH3qhugPWJUkEE KTNJmtXLXgi5aBvMo7AM2E7HMOenY6BMDbuIDHnNX3D7HFXBoCoOlyjLF7q/UHuzO7TBK1 F9fzQhU0uWNWmNlJd8FHYeXgIKlOxWuDTtblKPQ+yb99G3FY+7FZNW9Y61ftJ1uaEy0KmI +2ANL1GgDnXk9Hmjr2ROBbsVn5NfDSnIavkVJ811/s/H7dCUMmg1D/06m7SpJw== 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 4WJZ1d4SKGzqs3; Tue, 9 Jul 2024 21:31:33 +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 469LVX8j074984; Tue, 9 Jul 2024 21:31:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 469LVXps074981; Tue, 9 Jul 2024 21:31:33 GMT (envelope-from git) Date: Tue, 9 Jul 2024 21:31:33 GMT Message-Id: <202407092131.469LVXps074981@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Vladimir Druzenko Subject: git: b9b090f62a08 - main - emulators/virtualbox-ose{,-nox11}-legacy: add vboxinit start/stop script for VMs which is controlled from phpvirtualbox List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-ports-main@freebsd.org Sender: owner-dev-commits-ports-main@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/main X-Git-Reftype: branch X-Git-Commit: b9b090f62a08fe648332bd20af02deab794d0e03 Auto-Submitted: auto-generated The branch main has been updated by vvd: URL: https://cgit.FreeBSD.org/ports/commit/?id=b9b090f62a08fe648332bd20af02deab794d0e03 commit b9b090f62a08fe648332bd20af02deab794d0e03 Author: Vladimir Druzenko AuthorDate: 2024-07-09 21:30:58 +0000 Commit: Vladimir Druzenko CommitDate: 2024-07-09 21:30:58 +0000 emulators/virtualbox-ose{,-nox11}-legacy: 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 --- emulators/virtualbox-ose-legacy/Makefile | 4 +- emulators/virtualbox-ose-legacy/files/vboxinit.in | 91 +++++++++++++++++++++++ emulators/virtualbox-ose-nox11-legacy/Makefile | 2 +- 3 files changed, 94 insertions(+), 3 deletions(-) diff --git a/emulators/virtualbox-ose-legacy/Makefile b/emulators/virtualbox-ose-legacy/Makefile index 6fbc761566a2..4ce61c2bb073 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