VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/solaris/load.sh@ 97898

Last change on this file since 97898 was 97898, checked in by vboxsync, 2 years ago

SUPDrv/load.sh: fall back on pfexec if no sudo (S10).

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1#!/bin/bash
2# $Id: load.sh 97898 2022-12-29 15:16:03Z vboxsync $
3## @file
4# For development.
5#
6
7#
8# Copyright (C) 2006-2022 Oracle and/or its affiliates.
9#
10# This file is part of VirtualBox base platform packages, as
11# available from https://www.virtualbox.org.
12#
13# This program is free software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation, in version 3 of the
16# License.
17#
18# This program is distributed in the hope that it will be useful, but
19# WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21# General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, see <https://www.gnu.org/licenses>.
25#
26# The contents of this file may alternatively be used under the terms
27# of the Common Development and Distribution License Version 1.0
28# (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
29# in the VirtualBox distribution, in which case the provisions of the
30# CDDL are applicable instead of those of the GPL.
31#
32# You may elect to license modified versions of this file under the
33# terms and conditions of either the GPL or the CDDL or both.
34#
35# SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
36#
37
38DRVNAME="vboxdrv"
39DRIVERS_USING_IT="vboxusb vboxusbmon vboxnet vboxflt vboxbow"
40
41DRVFILE=`dirname "$0"`
42DRVFILE=`cd "$DRVFILE" && pwd`
43DRVFILE="$DRVFILE/$DRVNAME"
44if [ ! -f "$DRVFILE" ]; then
45 echo "load.sh: Cannot find $DRVFILE or it's not a file..."
46 exit 1;
47fi
48if [ ! -f "$DRVFILE.conf" ]; then
49 echo "load.sh: Cannot find $DRVFILE.conf or it's not a file..."
50 exit 1;
51fi
52
53SUDO=sudo
54hash "${SUDO}" 2> /dev/null || SUDO=pfexec
55#set -x
56
57# Disable the zone access service.
58servicefound=`svcs -H "virtualbox/zoneaccess" 2>/dev/null | grep '^online'`
59if test ! -z "$servicefound"; then
60 $SUDO svcadm disable svc:/application/virtualbox/zoneaccess:default
61fi
62
63# Unload driver that may depend on the driver we're going to (re-)load
64# as well as the driver itself.
65for drv in $DRIVERS_USING_IT $DRVNAME;
66do
67 LOADED=`modinfo | grep -w "$drv"`
68 if test -n "$LOADED"; then
69 MODID=`echo "$LOADED" | cut -d ' ' -f 1`
70 $SUDO modunload -i $MODID;
71 LOADED=`modinfo | grep -w "$drv"`;
72 if test -n "$LOADED"; then
73 echo "load.sh: failed to unload $drv";
74 dmesg | tail
75 exit 1;
76 fi
77 fi
78done
79
80#
81# Reconfigure the driver so it get a major number.
82#
83# Note! We have to copy the driver and config files to somewhere the kernel can
84# find them. It is searched for as drv/${DRVNAME}.conf in
85# kobj_module_path, which is usually:
86# /platform/i86pc/kernel /kernel /usr/kernel
87# To try prevent bad drivers from being loaded on the next boot, we remove
88# always the files.
89#
90MY_RC=1
91set -e
92$SUDO rm -f \
93 "/platform/i86pc/kernel/drv/${DRVNAME}.conf" \
94 "/platform/i86pc/kernel/drv/${DRVNAME}" \
95 "/platform/i86pc/kernel/drv/amd64/${DRVNAME}"
96sync
97$SUDO cp "${DRVFILE}" /platform/i86pc/kernel/drv/amd64/
98$SUDO cp "${DRVFILE}.conf" /platform/i86pc/kernel/drv/
99set +e
100
101$SUDO rem_drv $DRVNAME
102if $SUDO add_drv -v $DRVNAME; then
103 sync
104 if $SUDO modload "/platform/i86pc/kernel/drv/amd64/${DRVNAME}"; then
105 echo "load.sh: successfully loaded the driver"
106 modinfo | grep -w "$DRVNAME"
107 MY_RC=0
108 if test ! -h "/dev/vboxdrv"; then
109 $SUDO ln -sf "/devices/pseudo/vboxdrv@0:vboxdrv" /dev/vboxdrv
110 $SUDO chmod 0666 /dev/vboxdrv
111 fi
112 else
113 dmesg | tail
114 echo "load.sh: modload failed"
115 fi
116else
117 dmesg | tail
118 echo "load.sh: add_drv failed."
119fi
120
121$SUDO rm -f \
122 "/platform/i86pc/kernel/drv/${DRVNAME}.conf" \
123 "/platform/i86pc/kernel/drv/${DRVNAME}" \
124 "/platform/i86pc/kernel/drv/amd64/${DRVNAME}"
125sync
126
127exit $MY_RC;
128
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