VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxNetAdp/darwin/loadnetadp.sh@ 44528

Last change on this file since 44528 was 44528, checked in by vboxsync, 12 years ago

header (C) fixes

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