1 | #!/bin/bash
|
---|
2 | ## @file
|
---|
3 | # For development.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2006-2020 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 | # The contents of this file may alternatively be used under the terms
|
---|
18 | # of the Common Development and Distribution License Version 1.0
|
---|
19 | # (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | # VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | # CDDL are applicable instead of those of the GPL.
|
---|
22 | #
|
---|
23 | # You may elect to license modified versions of this file under the
|
---|
24 | # terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | #
|
---|
26 |
|
---|
27 | SCRIPT_NAME="loadusb"
|
---|
28 | XNU_VERSION=`LC_ALL=C uname -r | LC_ALL=C cut -d . -f 1`
|
---|
29 |
|
---|
30 | DRVNAME="VBoxUSB.kext"
|
---|
31 | BUNDLE="org.virtualbox.kext.VBoxUSB"
|
---|
32 |
|
---|
33 | DEP_DRVNAME="VBoxDrv.kext"
|
---|
34 | DEP_BUNDLE="org.virtualbox.kext.VBoxDrv"
|
---|
35 |
|
---|
36 |
|
---|
37 | DIR=`dirname "$0"`
|
---|
38 | DIR=`cd "$DIR" && pwd`
|
---|
39 | DEP_DIR="$DIR/$DEP_DRVNAME"
|
---|
40 | DIR="$DIR/$DRVNAME"
|
---|
41 | if [ ! -d "$DIR" ]; then
|
---|
42 | echo "Cannot find $DIR or it's not a directory..."
|
---|
43 | exit 1;
|
---|
44 | fi
|
---|
45 | if [ ! -d "$DEP_DIR" ]; then
|
---|
46 | echo "Cannot find $DEP_DIR or it's not a directory... (dependency)"
|
---|
47 | exit 1;
|
---|
48 | fi
|
---|
49 | if [ -n "$*" ]; then
|
---|
50 | OPTS="$*"
|
---|
51 | else
|
---|
52 | OPTS="-t"
|
---|
53 | fi
|
---|
54 |
|
---|
55 | trap "sudo chown -R `whoami` $DIR $DEP_DIR; exit 1" INT
|
---|
56 |
|
---|
57 | # Try unload any existing instance first.
|
---|
58 | LOADED=`kextstat -b $BUNDLE -l`
|
---|
59 | if test -n "$LOADED"; then
|
---|
60 | echo "${SCRIPT_NAME}.sh: Unloading $BUNDLE..."
|
---|
61 | sudo kextunload -v 6 -b $BUNDLE
|
---|
62 | LOADED=`kextstat -b $BUNDLE -l`
|
---|
63 | if test -n "$LOADED"; then
|
---|
64 | echo "${SCRIPT_NAME}.sh: failed to unload $BUNDLE, see above..."
|
---|
65 | exit 1;
|
---|
66 | fi
|
---|
67 | echo "${SCRIPT_NAME}.sh: Successfully unloaded $BUNDLE"
|
---|
68 | fi
|
---|
69 |
|
---|
70 | # We are now done since VBoxUSB.kext is no longer used.
|
---|