1 | #!/bin/sh
|
---|
2 | # $Id: vboxconfig.sh 30667 2010-07-06 13:18:28Z vboxsync $
|
---|
3 |
|
---|
4 | # Sun VirtualBox
|
---|
5 | # VirtualBox Configuration Script, Solaris host.
|
---|
6 | #
|
---|
7 | # Copyright (C) 2009 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 |
|
---|
18 | # Never use exit 2 or exit 20 etc., the return codes are used in
|
---|
19 | # SRv4 postinstall procedures which carry special meaning. Just use exit 1 for failure.
|
---|
20 |
|
---|
21 | # S10 or OpenSoalris
|
---|
22 | HOST_OS_MAJORVERSION=`uname -r`
|
---|
23 | # Which OpenSolaris version (snv_xxx)?
|
---|
24 | HOST_OS_MINORVERSION=`uname -v | grep 'snv' | sed -e "s/snv_//" -e "s/[^0-9]//"`
|
---|
25 |
|
---|
26 | DIR_VBOXBASE=${BASEDIR}/opt/VirtualBox
|
---|
27 | DIR_CONF="${BASEDIR}/platform/i86pc/kernel/drv"
|
---|
28 | DIR_MOD_32="${BASEDIR}/platform/i86pc/kernel/drv"
|
---|
29 | DIR_MOD_64=$DIR_MOD_32/amd64
|
---|
30 |
|
---|
31 | BIN_ADDDRV=/usr/sbin/add_drv
|
---|
32 | BIN_REMDRV=/usr/sbin/rem_drv
|
---|
33 | BIN_MODLOAD=/usr/sbin/modload
|
---|
34 | BIN_MODUNLOAD=/usr/sbin/modunload
|
---|
35 | BIN_MODINFO=/usr/sbin/modinfo
|
---|
36 | BIN_DEVFSADM=/usr/sbin/devfsadm
|
---|
37 | BIN_BOOTADM=/sbin/bootadm
|
---|
38 | BIN_SVCADM=/usr/sbin/svcadm
|
---|
39 | BIN_SVCCFG=/usr/sbin/svccfg
|
---|
40 | BIN_IFCONFIG=/sbin/ifconfig
|
---|
41 | BIN_ID=/usr/bin/id
|
---|
42 |
|
---|
43 | # "vboxdrv" is also used in sed lines here (change those as well if it ever changes)
|
---|
44 | MOD_VBOXDRV=vboxdrv
|
---|
45 | DESC_VBOXDRV="Host"
|
---|
46 |
|
---|
47 | MOD_VBOXNET=vboxnet
|
---|
48 | DESC_VBOXNET="NetAdapter"
|
---|
49 | MOD_VBOXNET_INST=32
|
---|
50 |
|
---|
51 | MOD_VBOXFLT=vboxflt
|
---|
52 | DESC_VBOXFLT="NetFilter"
|
---|
53 |
|
---|
54 | # No Separate VBI since (3.1)
|
---|
55 | #MOD_VBI=vbi
|
---|
56 | #DESC_VBI="Kernel Interface"
|
---|
57 |
|
---|
58 | MOD_VBOXUSBMON=vboxusbmon
|
---|
59 | DESC_VBOXUSBMON="USBMonitor"
|
---|
60 |
|
---|
61 | MOD_VBOXUSB=vboxusb
|
---|
62 | DESC_VBOXUSB="USB"
|
---|
63 |
|
---|
64 | REMOTEINST=0
|
---|
65 | FATALOP=fatal
|
---|
66 | NULLOP=nulloutput
|
---|
67 | SILENTOP=silent
|
---|
68 | IPSOP=ips
|
---|
69 | ISSILENT=
|
---|
70 | ISIPS=
|
---|
71 |
|
---|
72 | infoprint()
|
---|
73 | {
|
---|
74 | if test "$ISSILENT" != "$SILENTOP"; then
|
---|
75 | echo 1>&2 "$1"
|
---|
76 | fi
|
---|
77 | }
|
---|
78 |
|
---|
79 | subprint()
|
---|
80 | {
|
---|
81 | if test "$ISSILENT" != "$SILENTOP"; then
|
---|
82 | echo 1>&2 " - $1"
|
---|
83 | fi
|
---|
84 | }
|
---|
85 |
|
---|
86 | warnprint()
|
---|
87 | {
|
---|
88 | if test "$ISSILENT" != "$SILENTOP"; then
|
---|
89 | echo 1>&2 " * Warning!! $1"
|
---|
90 | fi
|
---|
91 | }
|
---|
92 |
|
---|
93 | errorprint()
|
---|
94 | {
|
---|
95 | echo 1>&2 "## $1"
|
---|
96 | }
|
---|
97 |
|
---|
98 |
|
---|
99 | # check_bin_path()
|
---|
100 | # !! failure is always fatal
|
---|
101 | check_bin_path()
|
---|
102 | {
|
---|
103 | if test -z "$1"; then
|
---|
104 | errorprint "missing argument to check_bin_path()"
|
---|
105 | exit 1
|
---|
106 | fi
|
---|
107 |
|
---|
108 | if test ! -x "$1"; then
|
---|
109 | errorprint "$1 missing or is not an executable"
|
---|
110 | exit 1
|
---|
111 | fi
|
---|
112 | return 0
|
---|
113 | }
|
---|
114 |
|
---|
115 | # find_bins()
|
---|
116 | # !! failure is always fatal
|
---|
117 | find_bins()
|
---|
118 | {
|
---|
119 | # Search only for binaries that might be in different locations
|
---|
120 | BIN_IFCONFIG=`which ifconfig 2> /dev/null`
|
---|
121 | BIN_SVCS=`which svcs 2> /dev/null`
|
---|
122 | BIN_ID=`which id 2> /dev/null`
|
---|
123 |
|
---|
124 | check_bin_path "$BIN_ID"
|
---|
125 | check_bin_path "$BIN_ADDDRV"
|
---|
126 | check_bin_path "$BIN_REMDRV"
|
---|
127 | check_bin_path "$BIN_MODLOAD"
|
---|
128 | check_bin_path "$BIN_MODUNLOAD"
|
---|
129 | check_bin_path "$BIN_MODINFO"
|
---|
130 | check_bin_path "$BIN_DEVFSADM"
|
---|
131 | check_bin_path "$BIN_BOOTADM"
|
---|
132 | check_bin_path "$BIN_SVCADM"
|
---|
133 | check_bin_path "$BIN_SVCCFG"
|
---|
134 | check_bin_path "$BIN_SVCS"
|
---|
135 | check_bin_path "$BIN_IFCONFIG"
|
---|
136 | }
|
---|
137 |
|
---|
138 | # check_root()
|
---|
139 | # !! failure is always fatal
|
---|
140 | check_root()
|
---|
141 | {
|
---|
142 | # Don't use "-u" option as some id binaries don't support it, instead
|
---|
143 | # rely on "uid=101(username) gid=10(groupname) groups=10(staff)" output
|
---|
144 | curuid=`$BIN_ID | cut -f 2 -d '=' | cut -f 1 -d '('`
|
---|
145 | if test "$curuid" -ne 0; then
|
---|
146 | errorprint "This script must be run with administrator privileges."
|
---|
147 | exit 1
|
---|
148 | fi
|
---|
149 | }
|
---|
150 |
|
---|
151 | # get_sysinfo
|
---|
152 | # cannot fail
|
---|
153 | get_sysinfo()
|
---|
154 | {
|
---|
155 | if test "$REMOTEINST" -eq 1 || test -z "$HOST_OS_MINORVERSION" || test -z "$HOST_OS_MAJORVERSION"; then
|
---|
156 | if test -f "${BASEDIR}/etc/release"; then
|
---|
157 | HOST_OS_MAJORVERSION=`cat ${BASEDIR}/etc/release | grep "Solaris 10"`
|
---|
158 | if test -n "$HOST_OS_MAJORVERSION"; then
|
---|
159 | HOST_OS_MAJORVERSION="5.10"
|
---|
160 | else
|
---|
161 | HOST_OS_MAJORVERSION=`cat ${BASEDIR}/etc/release | grep "snv_"`
|
---|
162 | if test -n "$HOST_OS_MAJORVERSION"; then
|
---|
163 | HOST_OS_MAJORVERSION="5.11"
|
---|
164 | fi
|
---|
165 | fi
|
---|
166 | if test "$HOST_OS_MAJORVERSION" != "5.10"; then
|
---|
167 | HOST_OS_MINORVERSION=`cat ${BASEDIR}/etc/release | tr ' ' '\n' | grep 'snv_' | sed -e "s/snv_//" -e "s/[^0-9]//"`
|
---|
168 | else
|
---|
169 | HOST_OS_MINORVERSION=""
|
---|
170 | fi
|
---|
171 | else
|
---|
172 | HOST_OS_MAJORVERSION=""
|
---|
173 | HOST_OS_MINORVERSION=""
|
---|
174 | fi
|
---|
175 | fi
|
---|
176 | }
|
---|
177 |
|
---|
178 | # check_zone()
|
---|
179 | # !! failure is always fatal
|
---|
180 | check_zone()
|
---|
181 | {
|
---|
182 | currentzone=`zonename`
|
---|
183 | if test "$currentzone" != "global"; then
|
---|
184 | errorprint "This script must be run from the global zone."
|
---|
185 | exit 1
|
---|
186 | fi
|
---|
187 | }
|
---|
188 |
|
---|
189 | # check_isa()
|
---|
190 | # !! failure is always fatal
|
---|
191 | check_isa()
|
---|
192 | {
|
---|
193 | currentisa=`uname -i`
|
---|
194 | if test "$currentisa" = "i86xpv"; then
|
---|
195 | errorprint "VirtualBox cannot run under xVM Dom0! Fatal Error, Aborting installation!"
|
---|
196 | exit 1
|
---|
197 | fi
|
---|
198 | }
|
---|
199 |
|
---|
200 | # check_module_arch()
|
---|
201 | # !! failure is always fatal
|
---|
202 | check_module_arch()
|
---|
203 | {
|
---|
204 | cputype=`isainfo -k`
|
---|
205 | if test "$cputype" != "amd64" && test "$cputype" != "i386"; then
|
---|
206 | errorprint "VirtualBox works only on i386/amd64 hosts, not $cputype"
|
---|
207 | exit 1
|
---|
208 | fi
|
---|
209 | }
|
---|
210 |
|
---|
211 | # module_added(modname)
|
---|
212 | # returns 1 if added, 0 otherwise
|
---|
213 | module_added()
|
---|
214 | {
|
---|
215 | if test -z "$1"; then
|
---|
216 | errorprint "missing argument to module_added()"
|
---|
217 | exit 1
|
---|
218 | fi
|
---|
219 |
|
---|
220 | # Add a space at end of module name to make sure we have a perfect match to avoid
|
---|
221 | # any substring matches: e.g "vboxusb" & "vbo $BASEDIR_OPT xusbmon"
|
---|
222 | loadentry=`cat ${BASEDIR}/etc/name_to_major | grep "$1 "`
|
---|
223 | if test -z "$loadentry"; then
|
---|
224 | return 1
|
---|
225 | fi
|
---|
226 | return 0
|
---|
227 | }
|
---|
228 |
|
---|
229 | # module_loaded(modname)
|
---|
230 | # returns 1 if loaded, 0 otherwise
|
---|
231 | module_loaded()
|
---|
232 | {
|
---|
233 | if test -z "$1"; then
|
---|
234 | errorprint "missing argument to module_loaded()"
|
---|
235 | exit 1
|
---|
236 | fi
|
---|
237 |
|
---|
238 | modname=$1
|
---|
239 | # modinfo should now work properly since we prevent module autounloading.
|
---|
240 | loadentry=`$BIN_MODINFO | grep "$modname "`
|
---|
241 | if test -z "$loadentry"; then
|
---|
242 | return 1
|
---|
243 | fi
|
---|
244 | return 0
|
---|
245 | }
|
---|
246 |
|
---|
247 | # add_driver(modname, moddesc, fatal, nulloutput, [driverperm])
|
---|
248 | # failure: depends on "fatal"
|
---|
249 | add_driver()
|
---|
250 | {
|
---|
251 | if test -z "$1" || test -z "$2"; then
|
---|
252 | errorprint "missing argument to add_driver()"
|
---|
253 | exit 1
|
---|
254 | fi
|
---|
255 |
|
---|
256 | modname="$1"
|
---|
257 | moddesc="$2"
|
---|
258 | fatal="$3"
|
---|
259 | nullop="$4"
|
---|
260 | modperm="$5"
|
---|
261 |
|
---|
262 | if test -n "$modperm"; then
|
---|
263 | if test "$nullop" = "$NULLOP"; then
|
---|
264 | $BIN_ADDDRV $BASEDIR_OPT -m"$modperm" $modname >/dev/null 2>&1
|
---|
265 | else
|
---|
266 | $BIN_ADDDRV $BASEDIR_OPT -m"$modperm" $modname
|
---|
267 | fi
|
---|
268 | else
|
---|
269 | if test "$nullop" = "$NULLOP"; then
|
---|
270 | $BIN_ADDDRV $BASEDIR_OPT $modname >/dev/null 2>&1
|
---|
271 | else
|
---|
272 | $BIN_ADDDRV $BASEDIR_OPT $modname
|
---|
273 | fi
|
---|
274 | fi
|
---|
275 |
|
---|
276 | if test $? -ne 0; then
|
---|
277 | subprint "Adding: $moddesc module ...FAILED!"
|
---|
278 | if test "$fatal" = "$FATALOP"; then
|
---|
279 | exit 1
|
---|
280 | fi
|
---|
281 | return 1
|
---|
282 | elif test "$REMOTEINST" -eq 1 && test "$?" -eq 0; then
|
---|
283 | subprint "Added: $moddesc driver"
|
---|
284 | fi
|
---|
285 | return 0
|
---|
286 | }
|
---|
287 |
|
---|
288 | # rem_driver(modname, moddesc, [fatal])
|
---|
289 | # failure: depends on [fatal]
|
---|
290 | rem_driver()
|
---|
291 | {
|
---|
292 | if test -z "$1" || test -z "$2"; then
|
---|
293 | errorprint "missing argument to rem_driver()"
|
---|
294 | exit 1
|
---|
295 | fi
|
---|
296 |
|
---|
297 | modname=$1
|
---|
298 | moddesc=$2
|
---|
299 | fatal=$3
|
---|
300 |
|
---|
301 | module_added $modname
|
---|
302 | if test "$?" -eq 0; then
|
---|
303 | if test "$ISIPS" != "$IPSOP"; then
|
---|
304 | $BIN_REMDRV $BASEDIR_OPT $modname
|
---|
305 | else
|
---|
306 | $BIN_REMDRV $BASEDIR_OPT $modname >/dev/null 2>&1
|
---|
307 | fi
|
---|
308 | # for remote installs, don't bother with return values of rem_drv
|
---|
309 | if test $? -eq 0; then
|
---|
310 | subprint "Removed: $moddesc module"
|
---|
311 | return 0
|
---|
312 | else
|
---|
313 | subprint "Removing: $moddesc ...FAILED!"
|
---|
314 | if test "$fatal" = "$FATALOP"; then
|
---|
315 | exit 1
|
---|
316 | fi
|
---|
317 | return 1
|
---|
318 | fi
|
---|
319 | fi
|
---|
320 | }
|
---|
321 |
|
---|
322 | # unload_module(modname, moddesc, [fatal])
|
---|
323 | # failure: fatal
|
---|
324 | unload_module()
|
---|
325 | {
|
---|
326 | if test -z "$1" || test -z "$2"; then
|
---|
327 | errorprint "missing argument to unload_module()"
|
---|
328 | exit 1
|
---|
329 | fi
|
---|
330 |
|
---|
331 | # No-OP for non-root installs
|
---|
332 | if test "$REMOTEINST" -eq 1; then
|
---|
333 | return 0
|
---|
334 | fi
|
---|
335 |
|
---|
336 | modname=$1
|
---|
337 | moddesc=$2
|
---|
338 | fatal=$3
|
---|
339 | modid=`$BIN_MODINFO | grep "$modname " | cut -f 1 -d ' ' `
|
---|
340 | if test -n "$modid"; then
|
---|
341 | $BIN_MODUNLOAD -i $modid
|
---|
342 | if test $? -eq 0; then
|
---|
343 | subprint "Unloaded: $moddesc module"
|
---|
344 | else
|
---|
345 | subprint "Unloading: $moddesc module ...FAILED!"
|
---|
346 | if test "$fatal" = "$FATALOP"; then
|
---|
347 | exit 1
|
---|
348 | fi
|
---|
349 | return 1
|
---|
350 | fi
|
---|
351 | fi
|
---|
352 | return 0
|
---|
353 | }
|
---|
354 |
|
---|
355 | # load_module(modname, moddesc, [fatal])
|
---|
356 | # pass "drv/modname" or "misc/vbi" etc.
|
---|
357 | # failure: fatal
|
---|
358 | load_module()
|
---|
359 | {
|
---|
360 | if test -z "$1" || test -z "$2"; then
|
---|
361 | errorprint "missing argument to load_module()"
|
---|
362 | exit 1
|
---|
363 | fi
|
---|
364 |
|
---|
365 | # No-OP for non-root installs
|
---|
366 | if test "$REMOTEINST" -eq 1; then
|
---|
367 | return 0
|
---|
368 | fi
|
---|
369 |
|
---|
370 | modname=$1
|
---|
371 | moddesc=$2
|
---|
372 | fatal=$3
|
---|
373 | $BIN_MODLOAD -p $modname
|
---|
374 | if test $? -eq 0; then
|
---|
375 | subprint "Loaded: $moddesc module"
|
---|
376 | return 0
|
---|
377 | else
|
---|
378 | subprint "Loading: $moddesc ...FAILED!"
|
---|
379 | if test "$fatal" = "$FATALOP"; then
|
---|
380 | exit 1
|
---|
381 | fi
|
---|
382 | return 1
|
---|
383 | fi
|
---|
384 | }
|
---|
385 |
|
---|
386 | # install_drivers()
|
---|
387 | # !! failure is always fatal
|
---|
388 | install_drivers()
|
---|
389 | {
|
---|
390 | if test -f "$DIR_CONF/vboxdrv.conf"; then
|
---|
391 | if test -n "_HARDENED_"; then
|
---|
392 | add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0600 root sys'"
|
---|
393 | else
|
---|
394 | add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0666 root sys'"
|
---|
395 | fi
|
---|
396 | load_module "drv/$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP"
|
---|
397 | else
|
---|
398 | errorprint "Extreme error! Missing $DIR_CONF/vboxdrv.conf, aborting."
|
---|
399 | return 1
|
---|
400 | fi
|
---|
401 |
|
---|
402 | # Add vboxdrv to devlink.tab
|
---|
403 | if test -f "${BASEDIR}/etc/devlink.tab"; then
|
---|
404 | sed -e '/name=vboxdrv/d' ${BASEDIR}/etc/devlink.tab > ${BASEDIR}/etc/devlink.vbox
|
---|
405 | echo "type=ddi_pseudo;name=vboxdrv \D" >> ${BASEDIR}/etc/devlink.vbox
|
---|
406 | mv -f ${BASEDIR}/etc/devlink.vbox ${BASEDIR}/etc/devlink.tab
|
---|
407 | else
|
---|
408 | errorprint "Missing ${BASEDIR}/etc/devlink.tab, aborting install"
|
---|
409 | return 1
|
---|
410 | fi
|
---|
411 |
|
---|
412 | # Create the device link for non-remote installs
|
---|
413 | if test "$REMOTEINST" -eq 0; then
|
---|
414 | /usr/sbin/devfsadm -i "$MOD_VBOXDRV"
|
---|
415 | if test $? -ne 0 || test ! -h "/dev/vboxdrv"; then
|
---|
416 | errorprint "Failed to create device link for $MOD_VBOXDRV."
|
---|
417 | exit 1
|
---|
418 | fi
|
---|
419 | fi
|
---|
420 |
|
---|
421 | # Load VBoxNetAdp
|
---|
422 | if test -f "$DIR_CONF/vboxnet.conf"; then
|
---|
423 | add_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
|
---|
424 | load_module "drv/$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
|
---|
425 | fi
|
---|
426 |
|
---|
427 | # Load VBoxNetFlt
|
---|
428 | if test -f "$DIR_CONF/vboxflt.conf"; then
|
---|
429 | add_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
|
---|
430 | load_module "drv/$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
|
---|
431 | fi
|
---|
432 |
|
---|
433 | # Load VBoxUSBMon, VBoxUSB
|
---|
434 | if test -f "$DIR_CONF/vboxusbmon.conf" && test "$HOST_OS_MAJORVERSION" != "5.10"; then
|
---|
435 | # For VirtualBox 3.1 the new USB code requires Nevada > 123
|
---|
436 | if test "$HOST_OS_MINORVERSION" -gt 123; then
|
---|
437 | add_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP" "not-$NULLOP" "'* 0666 root sys'"
|
---|
438 | load_module "drv/$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP"
|
---|
439 |
|
---|
440 | # Add vboxusbmon to devlink.tab
|
---|
441 | sed -e '/name=vboxusbmon/d' ${BASEDIR}/etc/devlink.tab > ${BASEDIR}/etc/devlink.vbox
|
---|
442 | echo "type=ddi_pseudo;name=vboxusbmon \D" >> ${BASEDIR}/etc/devlink.vbox
|
---|
443 | mv -f ${BASEDIR}/etc/devlink.vbox ${BASEDIR}/etc/devlink.tab
|
---|
444 |
|
---|
445 | # Create the device link for non-remote installs
|
---|
446 | if test "$REMOTEINST" -eq 0; then
|
---|
447 | /usr/sbin/devfsadm -i "$MOD_VBOXUSBMON"
|
---|
448 | if test $? -ne 0; then
|
---|
449 | errorprint "Failed to create device link for $MOD_VBOXUSBMON."
|
---|
450 | exit 1
|
---|
451 | fi
|
---|
452 | fi
|
---|
453 |
|
---|
454 | # Add vboxusb if present
|
---|
455 | # This driver is special, we need it in the boot-archive but since there is no
|
---|
456 | # USB device to attach to now (it's done at runtime) it will fail to attach so
|
---|
457 | # redirect attaching failure output to /dev/null
|
---|
458 | if test -f "$DIR_CONF/vboxusb.conf"; then
|
---|
459 | add_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP" "$NULLOP"
|
---|
460 | load_module "drv/$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP"
|
---|
461 | fi
|
---|
462 | else
|
---|
463 | if test -n "$HOST_OS_MINORVERSION"; then
|
---|
464 | warnprint "Solaris 5.11 snv_124 or higher required for USB support. Skipped installing USB support."
|
---|
465 | else
|
---|
466 | warnprint "Failed to determine Solaris 5.11 snv version. Skipped installing USB support."
|
---|
467 | fi
|
---|
468 | fi
|
---|
469 | fi
|
---|
470 |
|
---|
471 | return $?
|
---|
472 | }
|
---|
473 |
|
---|
474 | # remove_all([fatal])
|
---|
475 | # failure: depends on [fatal]
|
---|
476 | remove_drivers()
|
---|
477 | {
|
---|
478 | fatal=$1
|
---|
479 |
|
---|
480 | # Remove vboxdrv from devlink.tab
|
---|
481 | if test -f ${BASEDIR}/etc/devlink.tab; then
|
---|
482 | devlinkfound=`cat ${BASEDIR}/etc/devlink.tab | grep vboxdrv`
|
---|
483 | if test -n "$devlinkfound"; then
|
---|
484 | sed -e '/name=vboxdrv/d' ${BASEDIR}/etc/devlink.tab > ${BASEDIR}/etc/devlink.vbox
|
---|
485 | mv -f ${BASEDIR}/etc/devlink.vbox ${BASEDIR}/etc/devlink.tab
|
---|
486 | fi
|
---|
487 |
|
---|
488 | # Remove vboxusbmon from devlink.tab
|
---|
489 | devlinkfound=`cat ${BASEDIR}/etc/devlink.tab | grep vboxusbmon`
|
---|
490 | if test -n "$devlinkfound"; then
|
---|
491 | sed -e '/name=vboxusbmon/d' ${BASEDIR}/etc/devlink.tab > ${BASEDIR}/etc/devlink.vbox
|
---|
492 | mv -f ${BASEDIR}/etc/devlink.vbox ${BASEDIR}/etc/devlink.tab
|
---|
493 | fi
|
---|
494 | fi
|
---|
495 |
|
---|
496 | unload_module "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
|
---|
497 | rem_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
|
---|
498 |
|
---|
499 | unload_module "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
|
---|
500 | rem_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
|
---|
501 |
|
---|
502 | unload_module "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
|
---|
503 | rem_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
|
---|
504 |
|
---|
505 | unload_module "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
|
---|
506 | rem_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
|
---|
507 |
|
---|
508 | unload_module "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
|
---|
509 | rem_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
|
---|
510 |
|
---|
511 | # No separate VBI since 3.1
|
---|
512 | # unload_module "$MOD_VBI" "$DESC_VBI" "$fatal"
|
---|
513 |
|
---|
514 | # remove devlinks
|
---|
515 | if test -h "${BASEDIR}/dev/vboxdrv" || test -f "${BASEDIR}/dev/vboxdrv"; then
|
---|
516 | rm -f ${BASEDIR}/dev/vboxdrv
|
---|
517 | fi
|
---|
518 | if test -h "${BASEDIR}/dev/vboxusbmon" || test -f "${BASEDIR}/dev/vboxusbmon"; then
|
---|
519 | rm -f ${BASEDIR}/dev/vboxusbmon
|
---|
520 | fi
|
---|
521 |
|
---|
522 | # unpatch nwam/dhcpagent fix
|
---|
523 | nwamfile=${BASEDIR}/etc/nwam/llp
|
---|
524 | nwambackupfile=$nwamfile.vbox
|
---|
525 | if test -f "$nwamfile"; then
|
---|
526 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
527 | mv -f $nwambackupfile $nwamfile
|
---|
528 | fi
|
---|
529 |
|
---|
530 | # remove netmask configuration
|
---|
531 | nmaskfile=${BASEDIR}/etc/netmasks
|
---|
532 | nmaskbackupfile=$nmaskfile.vbox
|
---|
533 | if test -f "$nmaskfile"; then
|
---|
534 | sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
|
---|
535 | mv -f $nmaskbackupfile $nmaskfile
|
---|
536 | fi
|
---|
537 |
|
---|
538 | return 0
|
---|
539 | }
|
---|
540 |
|
---|
541 | # install_python_bindings(pythonbin)
|
---|
542 | # remarks: changes pwd
|
---|
543 | # failure: non fatal
|
---|
544 | install_python_bindings()
|
---|
545 | {
|
---|
546 | # The python binary might not be there, so just exit silently
|
---|
547 | if test -z "$1"; then
|
---|
548 | return 0
|
---|
549 | fi
|
---|
550 |
|
---|
551 | if test -z "$2"; then
|
---|
552 | errorprint "missing argument to install_python_bindings"
|
---|
553 | exit 1
|
---|
554 | fi
|
---|
555 |
|
---|
556 | pythonbin=$1
|
---|
557 | pythondesc=$2
|
---|
558 | if test -x "$pythonbin"; then
|
---|
559 | VBOX_INSTALL_PATH="$DIR_VBOXBASE"
|
---|
560 | export VBOX_INSTALL_PATH
|
---|
561 | cd $DIR_VBOXBASE/sdk/installer
|
---|
562 | $pythonbin ./vboxapisetup.py install > /dev/null
|
---|
563 | if test "$?" -eq 0; then
|
---|
564 | subprint "Installed: Bindings for $pythondesc"
|
---|
565 | fi
|
---|
566 | return 0
|
---|
567 | fi
|
---|
568 | return 1
|
---|
569 | }
|
---|
570 |
|
---|
571 |
|
---|
572 | # cleanup_install([fatal])
|
---|
573 | # failure: depends on [fatal]
|
---|
574 | cleanup_install()
|
---|
575 | {
|
---|
576 | fatal=$1
|
---|
577 |
|
---|
578 | # No-Op for remote installs
|
---|
579 | if test "$REMOTEINST" -eq 1; then
|
---|
580 | return 0
|
---|
581 | fi
|
---|
582 |
|
---|
583 | # stop webservice
|
---|
584 | servicefound=`$BIN_SVCS -a | grep "virtualbox/webservice" 2>/dev/null`
|
---|
585 | if test ! -z "$servicefound"; then
|
---|
586 | $BIN_SVCADM disable -s svc:/application/virtualbox/webservice:default
|
---|
587 | # Don't delete the manifest, this is handled by the manifest class action
|
---|
588 | # $BIN_SVCCFG delete svc:/application/virtualbox/webservice:default
|
---|
589 | if test "$?" -eq 0; then
|
---|
590 | subprint "Unloaded: Web service"
|
---|
591 | else
|
---|
592 | subprint "Unloading: Web service ...ERROR(S)."
|
---|
593 | fi
|
---|
594 | fi
|
---|
595 |
|
---|
596 | # stop zoneaccess service
|
---|
597 | servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" 2>/dev/null`
|
---|
598 | if test ! -z "$servicefound"; then
|
---|
599 | $BIN_SVCADM disable -s svc:/application/virtualbox/zoneaccess
|
---|
600 | # Don't delete the manifest, this is handled by the manifest class action
|
---|
601 | # $BIN_SVCCFG delete svc:/application/virtualbox/zoneaccess
|
---|
602 | if test "$?" -eq 0; then
|
---|
603 | subprint "Unloaded: Zone access service"
|
---|
604 | else
|
---|
605 | subprint "Unloading: Zone access service ...ERROR(S)."
|
---|
606 | fi
|
---|
607 | fi
|
---|
608 |
|
---|
609 | # unplumb all vboxnet instances for non-remote installs
|
---|
610 | inst=0
|
---|
611 | while test $inst -ne $MOD_VBOXNET_INST; do
|
---|
612 | vboxnetup=`$BIN_IFCONFIG vboxnet$inst >/dev/null 2>&1`
|
---|
613 | if test "$?" -eq 0; then
|
---|
614 | $BIN_IFCONFIG vboxnet$inst unplumb
|
---|
615 | if test "$?" -ne 0; then
|
---|
616 | errorprint "VirtualBox NetAdapter 'vboxnet$inst' couldn't be unplumbed (probably in use)."
|
---|
617 | if test "$fatal" = "$FATALOP"; then
|
---|
618 | exit 1
|
---|
619 | fi
|
---|
620 | fi
|
---|
621 | fi
|
---|
622 |
|
---|
623 | # unplumb vboxnet0 ipv6
|
---|
624 | vboxnetup=`$BIN_IFCONFIG vboxnet$inst inet6 >/dev/null 2>&1`
|
---|
625 | if test "$?" -eq 0; then
|
---|
626 | $BIN_IFCONFIG vboxnet$inst inet6 unplumb
|
---|
627 | if test "$?" -ne 0; then
|
---|
628 | errorprint "VirtualBox NetAdapter 'vboxnet$inst' IPv6 couldn't be unplumbed (probably in use)."
|
---|
629 | if test "$fatal" = "$FATALOP"; then
|
---|
630 | exit 1
|
---|
631 | fi
|
---|
632 | fi
|
---|
633 | fi
|
---|
634 |
|
---|
635 | inst=`expr $inst + 1`
|
---|
636 | done
|
---|
637 | }
|
---|
638 |
|
---|
639 |
|
---|
640 | # postinstall()
|
---|
641 | # !! failure is always fatal
|
---|
642 | postinstall()
|
---|
643 | {
|
---|
644 | infoprint "Loading VirtualBox kernel modules..."
|
---|
645 | install_drivers
|
---|
646 |
|
---|
647 | if test "$?" -eq 0; then
|
---|
648 | if test -f "$DIR_CONF/vboxnet.conf"; then
|
---|
649 | # nwam/dhcpagent fix
|
---|
650 | nwamfile=${BASEDIR}/etc/nwam/llp
|
---|
651 | nwambackupfile=$nwamfile.vbox
|
---|
652 | if test -f "$nwamfile"; then
|
---|
653 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
654 |
|
---|
655 | # add all vboxnet instances as static to nwam
|
---|
656 | inst=0
|
---|
657 | networkn=56
|
---|
658 | while test $inst -ne 1; do
|
---|
659 | echo "vboxnet$inst static 192.168.$networkn.1" >> $nwambackupfile
|
---|
660 | inst=`expr $inst + 1`
|
---|
661 | networkn=`expr $networkn + 1`
|
---|
662 | done
|
---|
663 | mv -f $nwambackupfile $nwamfile
|
---|
664 | fi
|
---|
665 |
|
---|
666 | # plumb and configure vboxnet0 for non-remote installs
|
---|
667 | if test "$REMOTEINST" -eq 0; then
|
---|
668 | $BIN_IFCONFIG vboxnet0 plumb up
|
---|
669 | if test "$?" -eq 0; then
|
---|
670 | $BIN_IFCONFIG vboxnet0 192.168.56.1 netmask 255.255.255.0 up
|
---|
671 |
|
---|
672 | # add the netmask to stay persistent across host reboots
|
---|
673 | nmaskfile=${BASEDIR}/etc/netmasks
|
---|
674 | nmaskbackupfile=$nmaskfile.vbox
|
---|
675 | if test -f $nmaskfile; then
|
---|
676 | sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
|
---|
677 | echo "#VirtualBox_SectionStart" >> $nmaskbackupfile
|
---|
678 | inst=0
|
---|
679 | networkn=56
|
---|
680 | while test $inst -ne 1; do
|
---|
681 | echo "192.168.$networkn.0 255.255.255.0" >> $nmaskbackupfile
|
---|
682 | inst=`expr $inst + 1`
|
---|
683 | networkn=`expr $networkn + 1`
|
---|
684 | done
|
---|
685 | echo "#VirtualBox_SectionEnd" >> $nmaskbackupfile
|
---|
686 | mv -f $nmaskbackupfile $nmaskfile
|
---|
687 | fi
|
---|
688 | else
|
---|
689 | # Should this be fatal?
|
---|
690 | warnprint "Failed to bring up vboxnet0!!"
|
---|
691 | fi
|
---|
692 | fi
|
---|
693 | fi
|
---|
694 |
|
---|
695 | if test -f ${BASEDIR}/var/svc/manifest/application/virtualbox/virtualbox-webservice.xml || test -f ${BASEDIR}/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml; then
|
---|
696 | infoprint "Configuring services..."
|
---|
697 | if test "$REMOTEINST" -eq 1; then
|
---|
698 | subprint "Skipped for targetted installs."
|
---|
699 | fi
|
---|
700 | fi
|
---|
701 |
|
---|
702 | # Enable Zone access service for non-remote installs, other services (Webservice) are delivered disabled by the manifest class action
|
---|
703 | if test "$REMOTEINST" -eq 0; then
|
---|
704 | servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" | grep "disabled" 2>/dev/null`
|
---|
705 | if test ! -z "$servicefound"; then
|
---|
706 | /usr/sbin/svcadm enable -s svc:/application/virtualbox/zoneaccess
|
---|
707 | if test "$?" -eq 0; then
|
---|
708 | subprint "Loaded: Zone access service"
|
---|
709 | else
|
---|
710 | subprint "Loading Zone access service ...FAILED."
|
---|
711 | fi
|
---|
712 | fi
|
---|
713 | fi
|
---|
714 |
|
---|
715 | # Install python bindings for non-remote installs
|
---|
716 | if test "$REMOTEINST" -eq 0; then
|
---|
717 | if test -f "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py" || test -h "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py"; then
|
---|
718 | PYTHONBIN=`which python 2> /dev/null`
|
---|
719 | if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
|
---|
720 | infoprint "Installing Python bindings..."
|
---|
721 |
|
---|
722 | INSTALLEDIT=1
|
---|
723 | PYTHONBIN=`which python2.4 2>/dev/null`
|
---|
724 | install_python_bindings "$PYTHONBIN" "Python 2.4"
|
---|
725 | if test "$?" -eq 0; then
|
---|
726 | INSTALLEDIT=0
|
---|
727 | fi
|
---|
728 | PYTHONBIN=`which python2.5 2>/dev/null`
|
---|
729 | install_python_bindings "$PYTHONBIN" "Python 2.5"
|
---|
730 | if test "$?" -eq 0; then
|
---|
731 | INSTALLEDIT=0
|
---|
732 | fi
|
---|
733 | PYTHONBIN=`which python2.6 2>/dev/null`
|
---|
734 | install_python_bindings "$PYTHONBIN" "Python 2.6"
|
---|
735 | if test "$?" -eq 0; then
|
---|
736 | INSTALLEDIT=0
|
---|
737 | fi
|
---|
738 |
|
---|
739 | # remove files installed by Python build
|
---|
740 | rm -rf $DIR_VBOXBASE/sdk/installer/build
|
---|
741 |
|
---|
742 | if test "$INSTALLEDIT" -ne 0; then
|
---|
743 | warnprint "No suitable Python version found. Required Python 2.4, 2.5 or 2.6."
|
---|
744 | warnprint "Skipped installing the Python bindings."
|
---|
745 | fi
|
---|
746 | else
|
---|
747 | warnprint "Python not found, skipped installed Python bindings."
|
---|
748 | fi
|
---|
749 | fi
|
---|
750 | else
|
---|
751 | warnprint "Skipped installing Python bindings. Run, as root, 'vboxapisetup.py install' manually from the booted system."
|
---|
752 | fi
|
---|
753 |
|
---|
754 | # Update boot archive
|
---|
755 | infoprint "Updating the boot archive..."
|
---|
756 | if test "$REMOTEINST" -eq 0; then
|
---|
757 | $BIN_BOOTADM update-archive > /dev/null
|
---|
758 | else
|
---|
759 | $BIN_BOOTADM update-archive -R ${BASEDIR} > /dev/null
|
---|
760 | fi
|
---|
761 |
|
---|
762 | return 0
|
---|
763 | else
|
---|
764 | errorprint "Failed to install drivers"
|
---|
765 | exit 666
|
---|
766 | fi
|
---|
767 | return 1
|
---|
768 | }
|
---|
769 |
|
---|
770 | # preremove([fatal])
|
---|
771 | # failure: depends on [fatal]
|
---|
772 | preremove()
|
---|
773 | {
|
---|
774 | fatal=$1
|
---|
775 |
|
---|
776 | cleanup_install "$fatal"
|
---|
777 |
|
---|
778 | remove_drivers "$fatal"
|
---|
779 | if test "$?" -eq 0; then
|
---|
780 | return 0;
|
---|
781 | fi
|
---|
782 | return 1
|
---|
783 | }
|
---|
784 |
|
---|
785 |
|
---|
786 |
|
---|
787 | # And it begins...
|
---|
788 | check_root
|
---|
789 | check_isa
|
---|
790 | check_zone
|
---|
791 | find_bins
|
---|
792 | get_sysinfo
|
---|
793 |
|
---|
794 | if test "x${BASEDIR}" != "x/"; then
|
---|
795 | BASEDIR_OPT="-b ${BASEDIR}"
|
---|
796 | REMOTEINST=1
|
---|
797 | fi
|
---|
798 |
|
---|
799 | # Get command line options
|
---|
800 | while test $# -gt 0;
|
---|
801 | do
|
---|
802 | case "$1" in
|
---|
803 | --postinstall | --preremove | --installdrivers | --removedrivers | --setupdrivers)
|
---|
804 | drvop="$1"
|
---|
805 | ;;
|
---|
806 | --fatal)
|
---|
807 | fatal="$FATALOP"
|
---|
808 | ;;
|
---|
809 | --silent)
|
---|
810 | ISSILENT="$SILENTOP"
|
---|
811 | ;;
|
---|
812 | --ips)
|
---|
813 | ISIPS="$IPSOP"
|
---|
814 | ;;
|
---|
815 | --altkerndir)
|
---|
816 | # Use alternate kernel driver config folder (dev only)
|
---|
817 | DIR_CONF="/usr/kernel/drv"
|
---|
818 | ;;
|
---|
819 | *)
|
---|
820 | break
|
---|
821 | ;;
|
---|
822 | esac
|
---|
823 | shift
|
---|
824 | done
|
---|
825 |
|
---|
826 | case "$drvop" in
|
---|
827 | --postinstall)
|
---|
828 | check_module_arch
|
---|
829 | postinstall
|
---|
830 | ;;
|
---|
831 | --preremove)
|
---|
832 | preremove "$fatal"
|
---|
833 | ;;
|
---|
834 | --installdrivers)
|
---|
835 | check_module_arch
|
---|
836 | install_drivers
|
---|
837 | ;;
|
---|
838 | --removedrivers)
|
---|
839 | remove_drivers "$fatal"
|
---|
840 | ;;
|
---|
841 | --setupdrivers)
|
---|
842 | remove_drivers "$fatal"
|
---|
843 | install_drivers
|
---|
844 | ;;
|
---|
845 | *)
|
---|
846 | errorprint "Invalid operation $drvop"
|
---|
847 | exit 1
|
---|
848 | esac
|
---|
849 |
|
---|
850 | exit "$?"
|
---|
851 |
|
---|