VirtualBox

source: vbox/trunk/src/VBox/Installer/darwin/VirtualBox/VBoxAutostartDarwin.sh

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1#!/bin/sh
2
3#
4# Copyright (C) 2012-2023 Oracle and/or its affiliates.
5#
6# This file is part of VirtualBox base platform packages, as
7# available from https://www.virtualbox.org.
8#
9# This program is free software; you can redistribute it and/or
10# modify it under the terms of the GNU General Public License
11# as published by the Free Software Foundation, in version 3 of the
12# License.
13#
14# This program is distributed in the hope that it will be useful, but
15# WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17# General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, see <https://www.gnu.org/licenses>.
21#
22# SPDX-License-Identifier: GPL-3.0-only
23#
24
25#
26# Wrapper for the per user autostart daemon. Gets a list of all users
27# and starts the VMs.
28#
29
30function vboxStartStopAllUserVms()
31{
32 # Go through the list and filter out all users without a shell and a
33 # non existing home.
34 for user in `dscl . -list /Users`
35 do
36 HOMEDIR=`dscl . -read /Users/"${user}" NFSHomeDirectory | sed 's/NFSHomeDirectory: //g'`
37 USERSHELL=`dscl . -read /Users/"${user}" UserShell | sed 's/UserShell: //g'`
38
39 # Check for known home directories and shells for daemons
40 if [[ "${HOMEDIR}" == "/var/empty" || "${HOMEDIR}" == "/dev/null" || "${HOMEDIR}" == "/var/root"
41 || "${USERSHELL}" == "/usr/bin/false" || "${USERSHELL}" == "/dev/null" || "${USERSHELL}" == "/usr/sbin/uucico" ]]
42 then
43 continue
44 fi
45
46 case "${1}" in
47 start)
48 # Start the daemon
49 su "${user}" -c "/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart --quiet --start --background --config ${CONFIG}"
50 ;;
51 stop)
52 # Stop the daemon
53 su "${user}" -c "/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart --quiet --stop --config ${CONFIG}"
54 ;;
55 *)
56 echo "Usage: start|stop"
57 exit 1
58 esac
59 done
60}
61
62function vboxStopAllUserVms()
63{
64 vboxStartStopAllUserVms "stop"
65}
66
67CONFIG=${1}
68vboxStartStopAllUserVms "start"
69trap vboxStopAllUserVms HUP KILL TERM
70
71
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use