VirtualBox

source: vbox/trunk/src/VBox/Installer/solaris/vboxdrv.sh@ 13049

Last change on this file since 13049 was 12858, checked in by vboxsync, 16 years ago

Solaris/installer: Fix for missing xpg4/bin/id and bail out installation when vboxdrv setup fails.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 5.3 KB
Line 
1#!/bin/sh
2# Sun xVM VirtualBox
3# VirtualBox kernel module control script for Solaris.
4#
5# Copyright (C) 2007-2008 Sun Microsystems, Inc.
6#
7# This file is part of VirtualBox Open Source Edition (OSE), as
8# available from http://www.virtualbox.org. This file is free software;
9# you can redistribute it and/or modify it under the terms of the GNU
10# General Public License (GPL) as published by the Free Software
11# Foundation, in version 2 as it comes in the "COPYING" file of the
12# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14#
15# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
16# Clara, CA 95054 USA or visit http://www.sun.com if you need
17# additional information or have any questions.
18#
19
20SILENTUNLOAD=""
21MODNAME="vboxdrv"
22FLTMODNAME="vboxflt"
23MODDIR32="/platform/i86pc/kernel/drv"
24MODDIR64=$MODDIR32/amd64
25
26abort()
27{
28 echo 1>&2 "## $1"
29 exit 1
30}
31
32info()
33{
34 echo 1>&2 "$1"
35}
36
37check_if_installed()
38{
39 cputype=`isainfo -k`
40 modulepath="$MODDIR32/$MODNAME"
41 if test "$cputype" = "amd64"; then
42 modulepath="$MODDIR64/$MODNAME"
43 fi
44 if test -f "$modulepath"; then
45 return 0
46 fi
47
48 # Let us go a step further and check if user has mixed up x86/amd64
49 # amd64 ISA, x86 kernel module??
50 if test "$cputype" = "amd64"; then
51 modulepath="$MODDIR32/$MODNAME"
52 if test -f "$modulepath"; then
53 abort "Found 32-bit module instead of 64-bit. Please install the amd64 package!"
54 fi
55 else
56 # x86 ISA, amd64 kernel module??
57 modulepath="$MODDIR64/$MODNAME"
58 if test -f "$modulepath"; then
59 abort "Found 64-bit module instead of 32-bit. Please install the x86 package!"
60 fi
61 fi
62
63 abort "VirtualBox Host kernel module NOT installed."
64}
65
66module_loaded()
67{
68 if test -f "/etc/name_to_major"; then
69 loadentry=`cat /etc/name_to_major | grep $MODNAME`
70 else
71 loadentry=`/usr/sbin/modinfo | grep $MODNAME`
72 fi
73 if test -z "$loadentry"; then
74 return 1
75 fi
76 return 0
77}
78
79vboxflt_module_loaded()
80{
81 if test -f "/etc/name_to_major"; then
82 loadentry=`cat /etc/name_to_major | grep $FLTMODNAME`
83 else
84 loadentry=`/usr/sbin/modinfo | grep $FLTMODNAME`
85 fi
86 if test -z "$loadentry"; then
87 return 1
88 fi
89 return 0
90}
91
92check_root()
93{
94 idbin=/usr/xpg4/bin/id
95 if test ! -f "$idbin"; then
96 found=`which id | grep "no id"`
97 if test ! -z "$found"; then
98 abort "Failed to find a suitable user id binary! Aborting"
99 else
100 idbin=$found
101 fi
102 fi
103
104 if test `$idbin -u` -ne 0; then
105 abort "This program must be run with administrator privileges. Aborting"
106 fi
107}
108
109start_module()
110{
111 if module_loaded; then
112 info "VirtualBox Host kernel module already loaded."
113 else
114 if test -n "_HARDENED_"; then
115 /usr/sbin/add_drv -m'* 0600 root sys' $MODNAME
116 else
117 /usr/sbin/add_drv -m'* 0666 root sys' $MODNAME
118 fi
119 if test ! module_loaded; then
120 abort "Failed to load VirtualBox Host kernel module."
121 elif test -c "/devices/pseudo/$MODNAME@0:$MODNAME"; then
122 info "VirtualBox Host kernel module loaded."
123 else
124 abort "Aborting due to attach failure."
125 fi
126 fi
127}
128
129stop_module()
130{
131 if module_loaded; then
132 /usr/sbin/rem_drv $MODNAME || info "## WARNING!! Failed to unload VirtualBox Host kernel module. Old one still active!"
133 info "VirtualBox Host kernel module unloaded."
134 elif test -z "$SILENTUNLOAD"; then
135 info "VirtualBox Host kernel module not loaded."
136 fi
137
138 # check for vbi and force unload it
139 vbi_mod_id=`/usr/sbin/modinfo | grep vbi | cut -f 1 -d ' ' `
140 if test -n "$vbi_mod_id"; then
141 /usr/sbin/modunload -i $vbi_mod_id > /dev/null 2>&1
142 fi
143}
144
145start_vboxflt()
146{
147 if vboxflt_module_loaded; then
148 info "VirtualBox NetFilter kernel module already loaded."
149 else
150 /usr/sbin/add_drv -m'* 0600 root sys' $FLTMODNAME
151 /usr/sbin/modload -p drv/$FLTMODNAME
152 if test ! vboxflt_module_loaded; then
153 abort "Failed to load VirtualBox NetFilter kernel module."
154 else
155 info "VirtualBox NetFilter kernel module loaded."
156 fi
157 fi
158}
159
160stop_vboxflt()
161{
162 if vboxflt_module_loaded; then
163 /usr/sbin/rem_drv $FLTMODNAME || info "## WARNING!! Failed to unload VirtualBox NetFilter module. Old one still active!"
164 info "VirtualBox NetFilter kernel module unloaded."
165 elif test -z "$SILENTUNLOAD"; then
166 info "VirtualBox NetFilter kernel module not loaded."
167 fi
168}
169
170status_module()
171{
172 if module_loaded; then
173 info "Running."
174 else
175 info "Stopped."
176 fi
177}
178
179stop_all_modules()
180{
181 stop_vboxflt
182 stop_module
183}
184
185start_all_modules()
186{
187 start_module
188 start_vboxflt
189}
190
191check_root
192check_if_installed
193
194if test "$2" = "silentunload"; then
195 SILENTUNLOAD="$2"
196fi
197
198case "$1" in
199stopall)
200 stop_all_modules
201 ;;
202startall)
203 start_all_modules
204 ;;
205start)
206 start_module
207 ;;
208stop)
209 stop_module
210 ;;
211status)
212 status_module
213 ;;
214fltstart)
215 start_vboxflt
216 ;;
217fltstop)
218 stop_vboxflt
219 ;;
220*)
221 echo "Usage: $0 {start|stop|status|fltstart|fltstop|stopall|startall}"
222 exit 1
223esac
224
225exit 0
226
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