VirtualBox

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

Last change on this file since 83563 was 82968, checked in by vboxsync, 5 years 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.0 KB
Line 
1#!/bin/sh
2
3#
4# Copyright (C) 2012-2020 Oracle Corporation
5#
6# This file is part of VirtualBox Open Source Edition (OSE), as
7# available from http://www.virtualbox.org. This file is free software;
8# you can redistribute it and/or modify it under the terms of the GNU
9# General Public License (GPL) as published by the Free Software
10# Foundation, in version 2 as it comes in the "COPYING" file of the
11# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
12# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
13#
14
15#
16# Wrapper for the per user autostart daemon. Gets a list of all users
17# and starts the VMs.
18#
19
20function vboxStartStopAllUserVms()
21{
22 # Go through the list and filter out all users without a shell and a
23 # non existing home.
24 for user in `dscl . -list /Users`
25 do
26 HOMEDIR=`dscl . -read /Users/${user} | grep NFSHomeDirectory | sed 's/NFSHomeDirectory: //g'`
27 USERSHELL=`dscl . -read /Users/${user} | grep UserShell | sed 's/UserShell: //g'`
28
29 # Check for known home directories and shells for daemons
30 if [[ "${HOMEDIR}" == "/var/empty" || "${HOMEDIR}" == "/dev/null" || "${HOMEDIR}" == "/var/root"
31 || "${USERSHELL}" == "/usr/bin/false" || "${USERSHELL}" == "/dev/null" || "${USERSHELL}" == "/usr/sbin/uucico" ]]
32 then
33 continue
34 fi
35
36 case "${1}" in
37 start)
38 # Start the daemon
39 su ${user} -c "/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart --quiet --start --background --config ${CONFIG}"
40 ;;
41 stop)
42 # Start the daemon
43 su ${user} -c "/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart --quiet --stop --config ${CONFIG}"
44 ;;
45 *)
46 echo "Usage: start|stop"
47 exit 1
48 esac
49 done
50}
51
52function vboxStopAllUserVms()
53{
54 vboxStartStopAllUserVms "stop"
55}
56
57CONFIG=${1}
58vboxStartStopAllUserVms "start"
59trap vboxStopAllUserVms HUP KILL TERM
60
61
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette