VirtualBox

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

Last change on this file since 14783 was 14745, checked in by vboxsync, 16 years ago

darwin/load.sh: Fixed cp/chflags issue by sudoing it.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 4.1 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# Make sure VBoxNetFlt is unloaded as it might be using symbols from us.
61LOADED=`kextstat -b org.virtualbox.kext.VBoxNetFlt -l`
62if test -n "$LOADED"; then
63 echo "load.sh: Unloading org.virtualbox.kext.VBoxNetFlt..."
64 sudo kextunload -v 6 -b org.virtualbox.kext.VBoxNetFlt
65 LOADED=`kextstat -b org.virtualbox.kext.VBoxNetFlt -l`
66 if test -n "$LOADED"; then
67 echo "load.sh: failed to unload org.virtualbox.kext.VBoxNetFlt, see above..."
68 exit 1;
69 fi
70 echo "load.sh: Successfully unloaded org.virtualbox.kext.VBoxNetFlt"
71fi
72
73# Try unload any existing instance first.
74LOADED=`kextstat -b $BUNDLE -l`
75if test -n "$LOADED"; then
76 echo "load.sh: Unloading $BUNDLE..."
77 sudo kextunload -v 6 -b $BUNDLE
78 LOADED=`kextstat -b $BUNDLE -l`
79 if test -n "$LOADED"; then
80 echo "load.sh: failed to unload $BUNDLE, see above..."
81 exit 1;
82 fi
83 echo "load.sh: Successfully unloaded $BUNDLE"
84fi
85
86set -e
87
88# Copy the .kext to the symbols directory and tweak the kextload options.
89if test -n "$VBOX_DARWIN_SYMS"; then
90 echo "load.sh: copying the extension the symbol area..."
91 rm -Rf "$VBOX_DARWIN_SYMS/$DRVNAME"
92 mkdir -p "$VBOX_DARWIN_SYMS"
93 cp -R "$DIR" "$VBOX_DARWIN_SYMS/"
94 OPTS="$OPTS -s $VBOX_DARWIN_SYMS/ "
95 sync
96fi
97
98trap "sudo chown -R `whoami` $DIR; exit 1" INT
99# On smbfs, this might succeed just fine but make no actual changes,
100# so we might have to temporarily copy the driver to a local directory.
101sudo chown -R root:wheel "$DIR"
102OWNER=`/usr/bin/stat -f "%u" "$DIR"`
103if test "$OWNER" -ne 0; then
104 TMP_DIR=/tmp/loaddrv.tmp
105 echo "load.sh: chown didn't work on $DIR, using temp location $TMP_DIR/$DRVNAME"
106
107 # clean up first (no sudo rm)
108 if test -e "$TMP_DIR"; then
109 sudo chown -R `whoami` "$TMP_DIR"
110 rm -Rf "$TMP_DIR"
111 fi
112
113 # make a copy and switch over DIR
114 mkdir -p "$TMP_DIR/"
115 sudo cp -Rp "$DIR" "$TMP_DIR/"
116 DIR="$TMP_DIR/$DRVNAME"
117
118 # retry
119 sudo chown -R root:wheel "$DIR"
120fi
121sudo chmod -R o-rwx "$DIR"
122sync
123echo "load.sh: loading $DIR..."
124sudo kextload $OPTS "$DIR"
125sync
126sudo chown -R `whoami` "$DIR"
127#sudo chmod 666 /dev/vboxdrv
128kextstat | grep org.virtualbox.kext
129
Note: See TracBrowser for help on using the repository browser.

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