VirtualBox

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

最後變更 在這個檔案從15131是 15131,由 vboxsync 提交於 16 年 前

#3202: VBoxDrv[Tiger] fixes. Created two VBoxUSB versions too and kicked out the horrible postflight hack that edited Info.plist. Made VBoxUSB depend on VBoxDrv and share IPRT with it.

  • 屬性 svn:eol-style 設為 LF
  • 屬性 svn:executable 設為 *
  • 屬性 svn:keywords 設為 Id
檔案大小: 2.6 KB
 
1#!/bin/bash
2## @file
3# For development.
4#
5
6#
7# Copyright (C) 2006-2008 Sun Microsystems, Inc.
8#
9# Sun Microsystems, Inc. confidential
10# All rights reserved
11#
12
13SCRIPT_NAME="loadusb"
14XNU_VERSION=`LC_ALL=C uname -r | LC_ALL=C cut -d . -f 1`
15
16DRVNAME="VBoxNetFlt.kext"
17BUNDLE="org.virtualbox.kext.VBoxNetFlt"
18
19if [ "$XNU_VERSION" -ge "9" ]; then
20 DEP_DRVNAME="VBoxDrv.kext"
21else
22 DEP_DRVNAME="VBoxDrvTiger.kext"
23fi
24DEP_BUNDLE="org.virtualbox.kext.VBoxDrv"
25
26
27DIR=`dirname "$0"`
28DIR=`cd "$DIR" && pwd`
29DEP_DIR="$DIR/$DEP_DRVNAME"
30DIR="$DIR/$DRVNAME"
31if [ ! -d "$DIR" ]; then
32 echo "Cannot find $DIR or it's not a directory..."
33 exit 1;
34fi
35if [ ! -d "$DEP_DIR" ]; then
36 echo "Cannot find $DEP_DIR or it's not a directory... (dependency)"
37 exit 1;
38fi
39if [ -n "$*" ]; then
40 OPTS="$*"
41else
42 OPTS="-t"
43fi
44
45trap "sudo chown -R `whoami` $DIR $DEP_DIR; exit 1" INT
46
47# Try unload any existing instance first.
48LOADED=`kextstat -b $BUNDLE -l`
49if test -n "$LOADED"; then
50 echo "${SCRIPT_NAME}.sh: Unloading $BUNDLE..."
51 sudo kextunload -v 6 -b $BUNDLE
52 LOADED=`kextstat -b $BUNDLE -l`
53 if test -n "$LOADED"; then
54 echo "${SCRIPT_NAME}.sh: failed to unload $BUNDLE, see above..."
55 exit 1;
56 fi
57 echo "${SCRIPT_NAME}.sh: Successfully unloaded $BUNDLE"
58fi
59
60set -e
61
62# Copy the .kext to the symbols directory and tweak the kextload options.
63if test -n "$VBOX_DARWIN_SYMS"; then
64 echo "${SCRIPT_NAME}.sh: copying the extension the symbol area..."
65 rm -Rf "$VBOX_DARWIN_SYMS/$DRVNAME"
66 mkdir -p "$VBOX_DARWIN_SYMS"
67 cp -R "$DIR" "$VBOX_DARWIN_SYMS/"
68 OPTS="$OPTS -s $VBOX_DARWIN_SYMS/ "
69 sync
70fi
71
72# On smbfs, this might succeed just fine but make no actual changes,
73# so we might have to temporarily copy the driver to a local directory.
74sudo chown -R root:wheel "$DIR" "$DEP_DIR"
75OWNER=`/usr/bin/stat -f "%u" "$DIR"`
76if test "$OWNER" -ne 0; then
77 TMP_DIR=/tmp/${SCRIPT_NAME}.tmp
78 echo "${SCRIPT_NAME}.sh: chown didn't work on $DIR, using temp location $TMP_DIR/$DRVNAME"
79
80 # clean up first (no sudo rm)
81 if test -e "$TMP_DIR"; then
82 sudo chown -R `whoami` "$TMP_DIR"
83 rm -Rf "$TMP_DIR"
84 fi
85
86 # make a copy and switch over DIR
87 mkdir -p "$TMP_DIR/"
88 sudo cp -Rp "$DIR" "$TMP_DIR/"
89 DIR="$TMP_DIR/$DRVNAME"
90
91 # load.sh puts it here.
92 DEP_DIR="/tmp/loaddrv.tmp/$DEP_DRVNAME"
93
94 # retry
95 sudo chown -R root:wheel "$DIR" "$DEP_DIR"
96fi
97
98sudo chmod -R o-rwx "$DIR"
99sync
100echo "${SCRIPT_NAME}.sh: loading $DIR... (kextload $OPTS \"$DIR\")"
101sudo kextload $OPTS -d "$DEP_DIR" "$DIR"
102sync
103sudo chown -R `whoami` "$DIR" "$DEP_DIR"
104kextstat | grep org.virtualbox.kext
105
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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