VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/darwin/load.sh@ 8155

Last change on this file since 8155 was 8155, checked in by vboxsync, 17 years ago

The Big Sun Rebranding Header Change

  • 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-2007 Sun Microsystems, Inc.
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# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27# Clara, CA 95054 USA or visit http://www.sun.com if you need
28# additional information or have any questions.
29#
30
31DRVNAME="VBoxDrv.kext"
32BUNDLE="org.virtualbox.kext.VBoxDrv"
33
34DIR=`dirname "$0"`
35DIR=`cd "$DIR" && pwd`
36DIR="$DIR/$DRVNAME"
37if [ ! -d "$DIR" ]; then
38 echo "Cannot find $DIR or it's not a directory..."
39 exit 1;
40fi
41if [ -n "$*" ]; then
42 OPTS="$*"
43else
44 OPTS="-t"
45fi
46
47# Make sure VBoxUSB is unloaded as it might be using symbols from us.
48LOADED=`kextstat -b org.virtualbox.kext.VBoxUSB -l`
49if test -n "$LOADED"; then
50 echo "load.sh: Unloading org.virtualbox.kext.VBoxUSB..."
51 sudo kextunload -v 6 -b org.virtualbox.kext.VBoxUSB
52 LOADED=`kextstat -b org.virtualbox.kext.VBoxUSB -l`
53 if test -n "$LOADED"; then
54 echo "load.sh: failed to unload org.virtualbox.kext.VBoxUSB, see above..."
55 exit 1;
56 fi
57 echo "load.sh: Successfully unloaded org.virtualbox.kext.VBoxUSB"
58fi
59
60# Try unload any existing instance first.
61LOADED=`kextstat -b $BUNDLE -l`
62if test -n "$LOADED"; then
63 echo "load.sh: Unloading $BUNDLE..."
64 sudo kextunload -v 6 -b $BUNDLE
65 LOADED=`kextstat -b $BUNDLE -l`
66 if test -n "$LOADED"; then
67 echo "load.sh: failed to unload $BUNDLE, see above..."
68 exit 1;
69 fi
70 echo "load.sh: Successfully unloaded $BUNDLE"
71fi
72
73set -e
74trap "sudo chown -R `whoami` $DIR; exit 1" INT
75# On smbfs, this might succeed just fine but make no actual changes,
76# so we might have to temporarily copy the driver to a local directory.
77sudo chown -R root:wheel "$DIR"
78OWNER=`stat -f "%u" "$DIR"`
79if test "$OWNER" -ne 0; then
80 TMP_DIR=/tmp/loaddrv.tmp
81 echo "load.sh: chown didn't work on $DIR, using temp location $TMP_DIR/$DRVNAME"
82
83 # clean up first (no sudo rm)
84 if test -e "$TMP_DIR"; then
85 sudo chown -R `whoami` "$TMP_DIR"
86 rm -Rf "$TMP_DIR"
87 fi
88
89 # make a copy and switch over DIR
90 mkdir -p "$TMP_DIR/"
91 cp -Rp "$DIR" "$TMP_DIR/"
92 DIR="$TMP_DIR/$DRVNAME"
93
94 # retry
95 sudo chown -R root:wheel "$DIR"
96fi
97sudo chmod -R o-rwx "$DIR"
98sync
99echo "load.sh: loading $DIR..."
100sudo kextload $OPTS "$DIR"
101sync
102sudo chown -R `whoami` "$DIR"
103#sudo chmod 666 /dev/vboxdrv
104kextstat | grep org.virtualbox.kext
105
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