1 | #!/bin/sh
|
---|
2 | # $Id: postflight 69500 2017-10-28 15:14:05Z 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 | echo "Loading newly installed kernel extensions."
|
---|
63 | kextload "/Library/Extensions/VBoxGuest.kext"
|
---|
64 |
|
---|
65 | load_service "org.virtualbox.additions.vboxservice" "/Library/LaunchDaemons" "root"
|
---|
66 | load_service "org.virtualbox.additions.vboxclient" "/Library/LaunchAgents" "${USER}"
|
---|
67 |
|
---|
68 | echo "Done."
|
---|
69 |
|
---|
70 | exit 0;
|
---|