VirtualBox

source: vbox/trunk/src/VBox/Installer/darwin/VBoxKEXTs/postflight

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 *
File size: 4.4 KB
Line 
1#!/bin/sh
2# $Id$
3## @file
4# Reloads the new kernel extension at the end of installation.
5#
6
7#
8# Copyright (C) 2007-2023 Oracle and/or its affiliates.
9#
10# This file is part of VirtualBox base platform packages, as
11# available from https://www.virtualbox.org.
12#
13# This program is free software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation, in version 3 of the
16# License.
17#
18# This program is distributed in the hope that it will be useful, but
19# WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21# General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, see <https://www.gnu.org/licenses>.
25#
26# SPDX-License-Identifier: GPL-3.0-only
27#
28
29#
30# Make sure the old startup items are gone.
31#
32if [ -d /Library/StartupItems/VirtualBox/ ]; then
33 rm -vf "/Library/StartupItems/VirtualBox/StartupParameters.plist"
34 rm -vf "/Library/StartupItems/VirtualBox/VirtualBox"
35 rm -vf "/Library/StartupItems/VirtualBox/Resources/English.lproj/Localizable.strings"
36 test -d "/Library/StartupItems/VirtualBox/Resources/English.lproj/" && rmdir "/Library/StartupItems/VirtualBox/Resources/English.lproj/"
37 test -d "/Library/StartupItems/VirtualBox/Resources/" && rmdir "/Library/StartupItems/VirtualBox/Resources/"
38 test -d "/Library/StartupItems/VirtualBox/" && rmdir "/Library/StartupItems/VirtualBox/"
39fi
40
41#
42# Make sure old kernel extensions are gone (moved to "/Library/Application Support/VirtualBox/" with 4.3).
43#
44rm -Rfv \
45 "/Library/Extensions/VBoxDrv.kext/" \
46 "/Library/Extensions/VBoxNetFlt.kext/" \
47 "/Library/Extensions/VBoxNetAdp.kext/" \
48 "/Library/Extensions/VBoxUSB.kext/" \
49 "/Library/Extensions/VBoxDrvTiger.kext/" \
50 "/Library/Extensions/VBoxUSBTiger.kext/"
51
52#
53# Install the launchd script.
54#
55# Make sure "/Library/LaunchDaemons/ exists first as some uninstallers/users
56# may be silly enough to remove it. We assume that /Library exists and will
57# not try create it because it normally has extra ACLs.
58#
59if [ ! -e "/Library/LaunchDaemons/" ]; then
60 set -e
61 mkdir "/Library/LaunchDaemons"
62 chmod 755 "/Library/LaunchDaemons"
63 chown root:wheel "/Library/LaunchDaemons"
64 set +e
65fi
66rm -vf "/Library/LaunchDaemons/org.virtualbox.startup.plist"
67set -e
68ln -s "../Application Support/VirtualBox/LaunchDaemons/org.virtualbox.startup.plist" \
69 "/Library/LaunchDaemons/org.virtualbox.startup.plist"
70set +e
71
72#
73# Unload any old extension that might be loaded already (ignore failures).
74#
75sync
76if kextstat -lb org.virtualbox.kext.VBoxNetAdp 2>&1 | grep -q org.virtualbox.kext.VBoxNetAdp; then
77 kextunload -m org.virtualbox.kext.VBoxNetAdp
78fi
79if kextstat -lb org.virtualbox.kext.VBoxNetFlt 2>&1 | grep -q org.virtualbox.kext.VBoxNetFlt; then
80 kextunload -m org.virtualbox.kext.VBoxNetFlt
81fi
82if kextstat -lb org.virtualbox.kext.VBoxUSB 2>&1 | grep -q org.virtualbox.kext.VBoxUSB; then
83 kextunload -m org.virtualbox.kext.VBoxUSB
84fi
85if kextstat -lb org.virtualbox.kext.VBoxDrv 2>&1 | grep -q org.virtualbox.kext.VBoxDrv; then
86 kextunload -m org.virtualbox.kext.VBoxDrv
87fi
88
89#
90# Load the extension, exit on first error except on BigSur onwards as an error
91# is expected there and the user has to reboot.
92#
93MACOS_VERSION_MAJOR=$(sw_vers -productVersion | /usr/bin/sed -e 's/^\([0-9]*\).*$/\1/')
94sync
95if [[ ${MACOS_VERSION_MAJOR} -lt 11 ]]; then
96 set -e
97 kextload '/Library/Application Support/VirtualBox/VBoxDrv.kext'
98 kextload -d '/Library/Application Support/VirtualBox/VBoxDrv.kext' '/Library/Application Support/VirtualBox/VBoxNetFlt.kext'
99 kextload -d '/Library/Application Support/VirtualBox/VBoxDrv.kext' '/Library/Application Support/VirtualBox/VBoxNetAdp.kext'
100else
101 VBOX_RC=0
102 if ! kmutil load -p '/Library/Application Support/VirtualBox/VBoxDrv.kext'; then
103 VBOX_RC=1
104 fi
105
106 if ! kmutil load -p '/Library/Application Support/VirtualBox/VBoxNetFlt.kext'; then
107 VBOX_RC=1
108 fi
109
110 if ! kmutil load -p '/Library/Application Support/VirtualBox/VBoxNetAdp.kext'; then
111 VBOX_RC=1
112 fi
113
114 if [ $VBOX_RC -ne 1 ]; then
115 osascript -e 'display dialog "A reboot is required on macOS BigSur and onwards in order to be able to load the installed kernel extensions" buttons { "Ok" } with icon caution'
116 fi
117fi
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use