[31655] | 1 | #!/bin/sh
|
---|
[48924] | 2 | # $Id$
|
---|
| 3 | ## @file
|
---|
| 4 | # Reloads the new kernel extension at the end of installation.
|
---|
| 5 | #
|
---|
[31655] | 6 |
|
---|
| 7 | #
|
---|
[93115] | 8 | # Copyright (C) 2007-2022 Oracle Corporation
|
---|
[31655] | 9 | #
|
---|
[31673] | 10 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
| 11 | # available from http://www.virtualbox.org. This file is free software;
|
---|
| 12 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
| 13 | # General Public License (GPL) as published by the Free Software
|
---|
| 14 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
| 15 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
| 16 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
[31655] | 17 | #
|
---|
| 18 |
|
---|
| 19 | #
|
---|
[48928] | 20 | # Make sure the old startup items are gone.
|
---|
| 21 | #
|
---|
[69396] | 22 | if [ -d /Library/StartupItems/VirtualBox/ ]; then
|
---|
[48928] | 23 | rm -vf "/Library/StartupItems/VirtualBox/StartupParameters.plist"
|
---|
| 24 | rm -vf "/Library/StartupItems/VirtualBox/VirtualBox"
|
---|
| 25 | rm -vf "/Library/StartupItems/VirtualBox/Resources/English.lproj/Localizable.strings"
|
---|
| 26 | test -d "/Library/StartupItems/VirtualBox/Resources/English.lproj/" && rmdir "/Library/StartupItems/VirtualBox/Resources/English.lproj/"
|
---|
| 27 | test -d "/Library/StartupItems/VirtualBox/Resources/" && rmdir "/Library/StartupItems/VirtualBox/Resources/"
|
---|
| 28 | test -d "/Library/StartupItems/VirtualBox/" && rmdir "/Library/StartupItems/VirtualBox/"
|
---|
| 29 | fi
|
---|
| 30 |
|
---|
| 31 | #
|
---|
[49334] | 32 | # Make sure old kernel extensions are gone (moved to "/Library/Application Support/VirtualBox/" with 4.3).
|
---|
| 33 | #
|
---|
| 34 | rm -Rfv \
|
---|
| 35 | "/Library/Extensions/VBoxDrv.kext/" \
|
---|
| 36 | "/Library/Extensions/VBoxNetFlt.kext/" \
|
---|
| 37 | "/Library/Extensions/VBoxNetAdp.kext/" \
|
---|
| 38 | "/Library/Extensions/VBoxUSB.kext/" \
|
---|
| 39 | "/Library/Extensions/VBoxDrvTiger.kext/" \
|
---|
| 40 | "/Library/Extensions/VBoxUSBTiger.kext/"
|
---|
| 41 |
|
---|
| 42 | #
|
---|
[48928] | 43 | # Install the launchd script.
|
---|
| 44 | #
|
---|
[58281] | 45 | # Make sure "/Library/LaunchDaemons/ exists first as some uninstallers/users
|
---|
| 46 | # may be silly enough to remove it. We assume that /Library exists and will
|
---|
| 47 | # not try create it because it normally has extra ACLs.
|
---|
| 48 | #
|
---|
| 49 | if [ ! -e "/Library/LaunchDaemons/" ]; then
|
---|
| 50 | set -e
|
---|
| 51 | mkdir "/Library/LaunchDaemons"
|
---|
| 52 | chmod 755 "/Library/LaunchDaemons"
|
---|
| 53 | chown root:wheel "/Library/LaunchDaemons"
|
---|
| 54 | set +e
|
---|
| 55 | fi
|
---|
[48928] | 56 | rm -vf "/Library/LaunchDaemons/org.virtualbox.startup.plist"
|
---|
| 57 | set -e
|
---|
| 58 | ln -s "../Application Support/VirtualBox/LaunchDaemons/org.virtualbox.startup.plist" \
|
---|
| 59 | "/Library/LaunchDaemons/org.virtualbox.startup.plist"
|
---|
| 60 | set +e
|
---|
| 61 |
|
---|
| 62 | #
|
---|
[31655] | 63 | # Unload any old extension that might be loaded already (ignore failures).
|
---|
| 64 | #
|
---|
| 65 | sync
|
---|
| 66 | if kextstat -lb org.virtualbox.kext.VBoxNetAdp 2>&1 | grep -q org.virtualbox.kext.VBoxNetAdp; then
|
---|
| 67 | kextunload -m org.virtualbox.kext.VBoxNetAdp
|
---|
| 68 | fi
|
---|
| 69 | if kextstat -lb org.virtualbox.kext.VBoxNetFlt 2>&1 | grep -q org.virtualbox.kext.VBoxNetFlt; then
|
---|
| 70 | kextunload -m org.virtualbox.kext.VBoxNetFlt
|
---|
| 71 | fi
|
---|
| 72 | if kextstat -lb org.virtualbox.kext.VBoxUSB 2>&1 | grep -q org.virtualbox.kext.VBoxUSB; then
|
---|
| 73 | kextunload -m org.virtualbox.kext.VBoxUSB
|
---|
| 74 | fi
|
---|
| 75 | if kextstat -lb org.virtualbox.kext.VBoxDrv 2>&1 | grep -q org.virtualbox.kext.VBoxDrv; then
|
---|
| 76 | kextunload -m org.virtualbox.kext.VBoxDrv
|
---|
| 77 | fi
|
---|
| 78 |
|
---|
| 79 | #
|
---|
[86291] | 80 | # Load the extension, exit on first error except on BigSur onwards as an error
|
---|
| 81 | # is expected there and the user has to reboot.
|
---|
[31655] | 82 | #
|
---|
[92346] | 83 | MACOS_VERSION_MAJOR=$(sw_vers -productVersion | /usr/bin/sed -e 's/^\([0-9]*\).*$/\1/')
|
---|
[31655] | 84 | sync
|
---|
[92346] | 85 | if [[ ${MACOS_VERSION_MAJOR} -lt 11 ]]; then
|
---|
[86291] | 86 | set -e
|
---|
[86449] | 87 | kextload '/Library/Application Support/VirtualBox/VBoxDrv.kext'
|
---|
| 88 | kextload -d '/Library/Application Support/VirtualBox/VBoxDrv.kext' '/Library/Application Support/VirtualBox/VBoxNetFlt.kext'
|
---|
| 89 | kextload -d '/Library/Application Support/VirtualBox/VBoxDrv.kext' '/Library/Application Support/VirtualBox/VBoxNetAdp.kext'
|
---|
| 90 | else
|
---|
| 91 | VBOX_RC=0
|
---|
[86474] | 92 | if ! kmutil load -p '/Library/Application Support/VirtualBox/VBoxDrv.kext'; then
|
---|
[86449] | 93 | VBOX_RC=1
|
---|
| 94 | fi
|
---|
| 95 |
|
---|
[86474] | 96 | if ! kmutil load -p '/Library/Application Support/VirtualBox/VBoxNetFlt.kext'; then
|
---|
[86449] | 97 | VBOX_RC=1
|
---|
| 98 | fi
|
---|
| 99 |
|
---|
[86474] | 100 | if ! kmutil load -p '/Library/Application Support/VirtualBox/VBoxNetAdp.kext'; then
|
---|
[86449] | 101 | VBOX_RC=1
|
---|
| 102 | fi
|
---|
| 103 |
|
---|
| 104 | if [ $VBOX_RC -ne 1 ]; then
|
---|
| 105 | 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'
|
---|
| 106 | fi
|
---|
[86291] | 107 | fi
|
---|