1 | #!/bin/sh
|
---|
2 | # $Id: postflight 75701 2018-11-25 01:39:10Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # Post flight installer script for the VirtualBox OS X kernel extensions.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2007-2017 Oracle Corporation
|
---|
9 | #
|
---|
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.
|
---|
17 | #
|
---|
18 |
|
---|
19 | set -e
|
---|
20 |
|
---|
21 | # Setup environment.
|
---|
22 | export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH"
|
---|
23 |
|
---|
24 | unload_service()
|
---|
25 | {
|
---|
26 | ITEM_ID=$1
|
---|
27 | ITEM_PATH=$2
|
---|
28 | FORCED_USER=$3
|
---|
29 |
|
---|
30 | loaded="NO"
|
---|
31 | test -n "$(sudo -u "$FORCED_USER" launchctl list | grep $ITEM_ID)" && loaded="YES"
|
---|
32 | if [ "$loaded" = "YES" ] ; then
|
---|
33 | echo "Unloading previously installed service: $ITEM_ID"
|
---|
34 | sudo -u "$FORCED_USER" launchctl unload -F "$ITEM_PATH/$ITEM_ID.plist"
|
---|
35 | fi
|
---|
36 | }
|
---|
37 |
|
---|
38 | load_service()
|
---|
39 | {
|
---|
40 | ITEM_ID=$1
|
---|
41 | ITEM_PATH=$2
|
---|
42 | FORCED_USER=$3
|
---|
43 |
|
---|
44 | echo "Loading newly installed service: $ITEM_ID"
|
---|
45 | sudo -u "$FORCED_USER" launchctl load -F "$ITEM_PATH/$ITEM_ID.plist"
|
---|
46 | }
|
---|
47 |
|
---|
48 | unload_service "org.virtualbox.additions.vboxservice" "/Library/LaunchDaemons" "root"
|
---|
49 | unload_service "org.virtualbox.additions.vboxclient" "/Library/LaunchAgents" "${USER}"
|
---|
50 |
|
---|
51 | items="VBoxGuest"
|
---|
52 | for item in $items; do
|
---|
53 | kext_item="org.virtualbox.kext.$item"
|
---|
54 |
|
---|
55 | loaded="NO"
|
---|
56 | test -n "$(kextstat | grep $kext_item)" && loaded="YES"
|
---|
57 | if [ "$loaded" = "YES" ] ; then
|
---|
58 | echo "Unloading $item kernel extension..."
|
---|
59 | kextunload -b $kext_item
|
---|
60 | fi
|
---|
61 | done
|
---|
62 |
|
---|
63 | echo "Updating kernel cache (should trigger loading of new modules)."
|
---|
64 | touch "/System/Library/Extensions/"
|
---|
65 | kextcache -update-volume / || true
|
---|
66 |
|
---|
67 | #echo "Loading newly installed kernel extensions."
|
---|
68 | #kextload "/Library/Extensions/VBoxGuest.kext"
|
---|
69 |
|
---|
70 | load_service "org.virtualbox.additions.vboxservice" "/Library/LaunchDaemons" "root"
|
---|
71 | load_service "org.virtualbox.additions.vboxclient" "/Library/LaunchAgents" "${USER}"
|
---|
72 |
|
---|
73 | echo "Done."
|
---|
74 |
|
---|
75 | exit 0;
|
---|