VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/loadnetflt.sh@ 16805

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

VBoxUSB,VBoxNetFlt: 10.6 fixes to the load scripts.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1#!/bin/bash
2## @file
3# For development.
4#
5
6#
7# Copyright (C) 2006-2008 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# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18# Clara, CA 95054 USA or visit http://www.sun.com if you need
19# additional information or have any questions.
20#
21
22SCRIPT_NAME="loadusb"
23XNU_VERSION=`LC_ALL=C uname -r | LC_ALL=C cut -d . -f 1`
24
25DRVNAME="VBoxNetFlt.kext"
26BUNDLE="org.virtualbox.kext.VBoxNetFlt"
27
28if [ "$XNU_VERSION" -ge "9" ]; then
29 DEP_DRVNAME="VBoxDrv.kext"
30else
31 DEP_DRVNAME="VBoxDrvTiger.kext"
32fi
33DEP_BUNDLE="org.virtualbox.kext.VBoxDrv"
34
35
36DIR=`dirname "$0"`
37DIR=`cd "$DIR" && pwd`
38DEP_DIR="$DIR/$DEP_DRVNAME"
39DIR="$DIR/$DRVNAME"
40if [ ! -d "$DIR" ]; then
41 echo "Cannot find $DIR or it's not a directory..."
42 exit 1;
43fi
44if [ ! -d "$DEP_DIR" ]; then
45 echo "Cannot find $DEP_DIR or it's not a directory... (dependency)"
46 exit 1;
47fi
48if [ -n "$*" ]; then
49 OPTS="$*"
50else
51 OPTS="-t"
52fi
53
54trap "sudo chown -R `whoami` $DIR $DEP_DIR; exit 1" INT
55
56# Try unload any existing instance first.
57LOADED=`kextstat -b $BUNDLE -l`
58if test -n "$LOADED"; then
59 echo "${SCRIPT_NAME}.sh: Unloading $BUNDLE..."
60 sudo kextunload -v 6 -b $BUNDLE
61 LOADED=`kextstat -b $BUNDLE -l`
62 if test -n "$LOADED"; then
63 echo "${SCRIPT_NAME}.sh: failed to unload $BUNDLE, see above..."
64 exit 1;
65 fi
66 echo "${SCRIPT_NAME}.sh: Successfully unloaded $BUNDLE"
67fi
68
69set -e
70
71# Copy the .kext to the symbols directory and tweak the kextload options.
72if test -n "$VBOX_DARWIN_SYMS"; then
73 echo "${SCRIPT_NAME}.sh: copying the extension the symbol area..."
74 rm -Rf "$VBOX_DARWIN_SYMS/$DRVNAME"
75 mkdir -p "$VBOX_DARWIN_SYMS"
76 cp -R "$DIR" "$VBOX_DARWIN_SYMS/"
77 OPTS="$OPTS -s $VBOX_DARWIN_SYMS/ "
78 sync
79fi
80
81# On smbfs, this might succeed just fine but make no actual changes,
82# so we might have to temporarily copy the driver to a local directory.
83sudo chown -R root:wheel "$DIR" "$DEP_DIR"
84OWNER=`/usr/bin/stat -f "%u" "$DIR"`
85if test "$OWNER" -ne 0; then
86 TMP_DIR=/tmp/${SCRIPT_NAME}.tmp
87 echo "${SCRIPT_NAME}.sh: chown didn't work on $DIR, using temp location $TMP_DIR/$DRVNAME"
88
89 # clean up first (no sudo rm)
90 if test -e "$TMP_DIR"; then
91 sudo chown -R `whoami` "$TMP_DIR"
92 rm -Rf "$TMP_DIR"
93 fi
94
95 # make a copy and switch over DIR
96 mkdir -p "$TMP_DIR/"
97 sudo cp -Rp "$DIR" "$TMP_DIR/"
98 DIR="$TMP_DIR/$DRVNAME"
99
100 # load.sh puts it here.
101 DEP_DIR="/tmp/loaddrv.tmp/$DEP_DRVNAME"
102
103 # retry
104 sudo chown -R root:wheel "$DIR" "$DEP_DIR"
105fi
106
107sudo chmod -R o-rwx "$DIR"
108sync
109if [ "$XNU_VERSION" -ge "10" ]; then
110 echo "${SCRIPT_NAME}.sh: loading $DIR... (kextutil $OPTS -d \"$DEP_DIR\" \"$DIR\")"
111 sudo kextutil $OPTS -d "$DEP_DIR" "$DIR"
112else
113 echo "${SCRIPT_NAME}.sh: loading $DIR... (kextload $OPTS -d \"$DEP_DIR\" \"$DIR\")"
114sudo kextload $OPTS -d "$DEP_DIR" "$DIR"
115fi
116sync
117sudo chown -R `whoami` "$DIR" "$DEP_DIR"
118kextstat | grep org.virtualbox.kext
119
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