VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/darwin/load.sh@ 18182

Last change on this file since 18182 was 18182, checked in by vboxsync, 16 years ago

load.sh: unload VBoxNetAdp too.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 4.9 KB
Line 
1#!/bin/bash
2## @file
3# For development.
4#
5
6#
7# Copyright (C) 2006-2007 Sun Microsystems, Inc.
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17# The contents of this file may alternatively be used under the terms
18# of the Common Development and Distribution License Version 1.0
19# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20# VirtualBox OSE distribution, in which case the provisions of the
21# CDDL are applicable instead of those of the GPL.
22#
23# You may elect to license modified versions of this file under the
24# terms and conditions of either the GPL or the CDDL or both.
25#
26# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27# Clara, CA 95054 USA or visit http://www.sun.com if you need
28# additional information or have any questions.
29#
30
31XNU_VERSION=`LC_ALL=C uname -r | LC_ALL=C cut -d . -f 1`
32if [ "$XNU_VERSION" -ge "9" ]; then
33 DRVNAME="VBoxDrv.kext"
34else
35 DRVNAME="VBoxDrvTiger.kext"
36fi
37BUNDLE="org.virtualbox.kext.VBoxDrv"
38
39DIR=`dirname "$0"`
40DIR=`cd "$DIR" && pwd`
41DIR="$DIR/$DRVNAME"
42if [ ! -d "$DIR" ]; then
43 echo "Cannot find $DIR or it's not a directory..."
44 exit 1;
45fi
46if [ -n "$*" ]; then
47 OPTS="$*"
48else
49 OPTS="-t"
50fi
51
52# Make sure VBoxUSB is unloaded as it might be using symbols from us.
53LOADED=`kextstat -b org.virtualbox.kext.VBoxUSB -l`
54if test -n "$LOADED"; then
55 echo "load.sh: Unloading org.virtualbox.kext.VBoxUSB..."
56 sudo kextunload -v 6 -b org.virtualbox.kext.VBoxUSB
57 LOADED=`kextstat -b org.virtualbox.kext.VBoxUSB -l`
58 if test -n "$LOADED"; then
59 echo "load.sh: failed to unload org.virtualbox.kext.VBoxUSB, see above..."
60 exit 1;
61 fi
62 echo "load.sh: Successfully unloaded org.virtualbox.kext.VBoxUSB"
63fi
64
65# Make sure VBoxNetFlt is unloaded as it might be using symbols from us.
66LOADED=`kextstat -b org.virtualbox.kext.VBoxNetFlt -l`
67if test -n "$LOADED"; then
68 echo "load.sh: Unloading org.virtualbox.kext.VBoxNetFlt..."
69 sudo kextunload -v 6 -b org.virtualbox.kext.VBoxNetFlt
70 LOADED=`kextstat -b org.virtualbox.kext.VBoxNetFlt -l`
71 if test -n "$LOADED"; then
72 echo "load.sh: failed to unload org.virtualbox.kext.VBoxNetFlt, see above..."
73 exit 1;
74 fi
75 echo "load.sh: Successfully unloaded org.virtualbox.kext.VBoxNetFlt"
76fi
77
78# Make sure VBoxNetAdp is unloaded as it might be using symbols from us.
79LOADED=`kextstat -b org.virtualbox.kext.VBoxNetAdp -l`
80if test -n "$LOADED"; then
81 echo "load.sh: Unloading org.virtualbox.kext.VBoxNetAdp..."
82 sudo kextunload -v 6 -b org.virtualbox.kext.VBoxNetAdp
83 LOADED=`kextstat -b org.virtualbox.kext.VBoxNetAdp -l`
84 if test -n "$LOADED"; then
85 echo "load.sh: failed to unload org.virtualbox.kext.VBoxNetAdp, see above..."
86 exit 1;
87 fi
88 echo "load.sh: Successfully unloaded org.virtualbox.kext.VBoxNetAdp"
89fi
90
91# Try unload any existing instance first.
92LOADED=`kextstat -b $BUNDLE -l`
93if test -n "$LOADED"; then
94 echo "load.sh: Unloading $BUNDLE..."
95 sudo kextunload -v 6 -b $BUNDLE
96 LOADED=`kextstat -b $BUNDLE -l`
97 if test -n "$LOADED"; then
98 echo "load.sh: failed to unload $BUNDLE, see above..."
99 exit 1;
100 fi
101 echo "load.sh: Successfully unloaded $BUNDLE"
102fi
103
104set -e
105
106# Copy the .kext to the symbols directory and tweak the kextload options.
107if test -n "$VBOX_DARWIN_SYMS"; then
108 echo "load.sh: copying the extension the symbol area..."
109 rm -Rf "$VBOX_DARWIN_SYMS/$DRVNAME"
110 mkdir -p "$VBOX_DARWIN_SYMS"
111 cp -R "$DIR" "$VBOX_DARWIN_SYMS/"
112 OPTS="$OPTS -s $VBOX_DARWIN_SYMS/ "
113 sync
114fi
115
116trap "sudo chown -R `whoami` $DIR; exit 1" INT
117# On smbfs, this might succeed just fine but make no actual changes,
118# so we might have to temporarily copy the driver to a local directory.
119sudo chown -R root:wheel "$DIR"
120OWNER=`/usr/bin/stat -f "%u" "$DIR"`
121if test "$OWNER" -ne 0; then
122 TMP_DIR=/tmp/loaddrv.tmp
123 echo "load.sh: chown didn't work on $DIR, using temp location $TMP_DIR/$DRVNAME"
124
125 # clean up first (no sudo rm)
126 if test -e "$TMP_DIR"; then
127 sudo chown -R `whoami` "$TMP_DIR"
128 rm -Rf "$TMP_DIR"
129 fi
130
131 # make a copy and switch over DIR
132 mkdir -p "$TMP_DIR/"
133 sudo cp -Rp "$DIR" "$TMP_DIR/"
134 DIR="$TMP_DIR/$DRVNAME"
135
136 # retry
137 sudo chown -R root:wheel "$DIR"
138fi
139sudo chmod -R o-rwx "$DIR"
140sync
141echo "load.sh: loading $DIR..."
142
143if [ "$XNU_VERSION" -ge "10" ]; then
144 echo "${SCRIPT_NAME}.sh: loading $DIR... (kextutil $OPTS \"$DIR\")"
145 sudo kextutil $OPTS "$DIR"
146else
147 sudo kextload $OPTS "$DIR"
148fi
149sync
150sudo chown -R `whoami` "$DIR"
151#sudo chmod 666 /dev/vboxdrv
152kextstat | grep org.virtualbox.kext
153
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette