diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 03:01:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 03:01:46 +0000 |
commit | f8fe689a81f906d1b91bb3220acde2a4ecb14c5b (patch) | |
tree | 26484e9d7e2c67806c2d1760196ff01aaa858e8c /src/VBox/Installer/darwin/VirtualBox/VBoxAutostartDarwin.sh | |
parent | Initial commit. (diff) | |
download | virtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.tar.xz virtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.zip |
Adding upstream version 6.0.4-dfsg.upstream/6.0.4-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Installer/darwin/VirtualBox/VBoxAutostartDarwin.sh')
-rwxr-xr-x | src/VBox/Installer/darwin/VirtualBox/VBoxAutostartDarwin.sh | 61 |
1 files changed, 61 insertions, 0 deletions
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 + + |