From f8fe689a81f906d1b91bb3220acde2a4ecb14c5b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 6 May 2024 05:01:46 +0200 Subject: Adding upstream version 6.0.4-dfsg. Signed-off-by: Daniel Baumann --- .../darwin/VirtualBox/VBoxAutostartDarwin.sh | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 src/VBox/Installer/darwin/VirtualBox/VBoxAutostartDarwin.sh (limited to 'src/VBox/Installer/darwin/VirtualBox/VBoxAutostartDarwin.sh') diff --git a/src/VBox/Installer/darwin/VirtualBox/VBoxAutostartDarwin.sh b/src/VBox/Installer/darwin/VirtualBox/VBoxAutostartDarwin.sh new file mode 100755 index 00000000..e6370b2b --- /dev/null +++ b/src/VBox/Installer/darwin/VirtualBox/VBoxAutostartDarwin.sh @@ -0,0 +1,61 @@ +#!/bin/sh + +# +# Copyright (C) 2012-2019 Oracle Corporation +# +# This file is part of VirtualBox Open Source Edition (OSE), as +# available from http://www.virtualbox.org. This file is free software; +# you can redistribute it and/or modify it under the terms of the GNU +# General Public License (GPL) as published by the Free Software +# Foundation, in version 2 as it comes in the "COPYING" file of the +# VirtualBox OSE distribution. VirtualBox OSE is distributed in the +# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. +# + +# +# Wrapper for the per user autostart daemon. Gets a list of all users +# and starts the VMs. +# + +function vboxStartStopAllUserVms() +{ + # Go through the list and filter out all users without a shell and a + # non existing home. + for user in `dscl . -list /Users` + do + HOMEDIR=`dscl . -read /Users/${user} | grep NFSHomeDirectory | sed 's/NFSHomeDirectory: //g'` + USERSHELL=`dscl . -read /Users/${user} | grep UserShell | sed 's/UserShell: //g'` + + # Check for known home directories and shells for daemons + if [[ "${HOMEDIR}" == "/var/empty" || "${HOMEDIR}" == "/dev/null" || "${HOMEDIR}" == "/var/root" + || "${USERSHELL}" == "/usr/bin/false" || "${USERSHELL}" == "/dev/null" || "${USERSHELL}" == "/usr/sbin/uucico" ]] + then + continue + fi + + case "${1}" in + start) + # Start the daemon + su ${user} -c "/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart --quiet --start --background --config ${CONFIG}" + ;; + stop) + # Start the daemon + su ${user} -c "/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart --quiet --stop --config ${CONFIG}" + ;; + *) + echo "Usage: start|stop" + exit 1 + esac + done +} + +function vboxStopAllUserVms() +{ + vboxStartStopAllUserVms "stop" +} + +CONFIG=${1} +vboxStartStopAllUserVms "start" +trap vboxStopAllUserVms HUP KILL TERM + + -- cgit v1.2.3