VirtualBox

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

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

All: license header changes for 2.0 (OSE headers, add Sun GPL/LGPL disclaimer)

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

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