1 | #!/bin/sh
|
---|
2 | ## @file
|
---|
3 | # VBoxService wrapper script.
|
---|
4 | #
|
---|
5 | # Load required kernel extensions before start service (if necessary).
|
---|
6 | #
|
---|
7 |
|
---|
8 | #
|
---|
9 | # Copyright (C) 2007-2022 Oracle Corporation
|
---|
10 | #
|
---|
11 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | # available from http://www.virtualbox.org. This file is free software;
|
---|
13 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | # General Public License (GPL) as published by the Free Software
|
---|
15 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | #
|
---|
19 |
|
---|
20 | export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH"
|
---|
21 |
|
---|
22 | echo "Check if kernel extensions loaded..."
|
---|
23 | items="VBoxGuest"
|
---|
24 | for item in $items; do
|
---|
25 | kext_item="org.virtualbox.kext.$item"
|
---|
26 | loaded=`kextstat | grep $kext_item`
|
---|
27 | if [ -z "$loaded" ] ; then
|
---|
28 | echo "Loading $item kernel extension..."
|
---|
29 | XNU_VERSION=`LC_ALL=C uname -r | LC_ALL=C cut -d . -f 1`
|
---|
30 | if [ "$XNU_VERSION" -ge "10" ]; then
|
---|
31 | kextutil /Library/Extensions/$item.kext
|
---|
32 | else
|
---|
33 | kextload /Library/Extensions/$item.kext
|
---|
34 | fi
|
---|
35 | fi
|
---|
36 | done
|
---|
37 |
|
---|
38 | echo "Check if VBoxClient is added for all non-system users"
|
---|
39 | for user in $(dscl . -list /Users | grep -v -e'^_' -e'root'); do
|
---|
40 | system_user="YES"
|
---|
41 | test -n "$(dscl . -read /Users/$user NFSHomeDirectory | grep '/Users')" && system_user="NO"
|
---|
42 | if [ "$system_user" = "NO" ]; then
|
---|
43 | loaded="NO"
|
---|
44 | test -n "$(sudo -u "$user" launchctl list | grep 'org.virtualbox.additions.vboxclient')" && loaded="YES"
|
---|
45 | if [ "$loaded" = "NO" ] ; then
|
---|
46 | echo "Loading org.virtualbox.additions.vboxclient for $user"
|
---|
47 | sudo -u "$user" launchctl load -F "/Library/LaunchAgents/org.virtualbox.additions.vboxclient.plist"
|
---|
48 | fi
|
---|
49 | fi
|
---|
50 | done
|
---|
51 |
|
---|
52 | exec "/Library/Application Support/VirtualBox Guest Additions/VBoxService" -f
|
---|
53 |
|
---|