VirtualBox

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

Last change on this file since 28800 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

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