1 | #!/bin/sh
|
---|
2 | # $Id: vboxconfig.sh 22227 2009-08-13 10:02:08Z vboxsync $
|
---|
3 |
|
---|
4 | # Sun VirtualBox
|
---|
5 | # VirtualBox Configuration Script, Solaris host.
|
---|
6 | #
|
---|
7 | # Copyright (C) 2009 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 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | # Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | # additional information or have any questions.
|
---|
20 | #
|
---|
21 |
|
---|
22 |
|
---|
23 | # Never use exit 2 or exit 20 etc., the return codes are used in
|
---|
24 | # SRv4 postinstall procedures which carry special meaning. Just use exit 1 for failure.
|
---|
25 |
|
---|
26 | HOST_OS_VERSION=`uname -r`
|
---|
27 |
|
---|
28 | DIR_VBOXBASE=/opt/VirtualBox
|
---|
29 | DIR_MOD_32="/platform/i86pc/kernel/drv"
|
---|
30 | DIR_MOD_64=$DIR_MOD_32/amd64
|
---|
31 |
|
---|
32 | BIN_ADDDRV=/usr/sbin/add_drv
|
---|
33 | BIN_REMDRV=/usr/sbin/rem_drv
|
---|
34 | BIN_MODLOAD=/usr/sbin/modload
|
---|
35 | BIN_MODUNLOAD=/usr/sbin/modunload
|
---|
36 | BIN_MODINFO=/usr/sbin/modinfo
|
---|
37 | BIN_DEVFSADM=/usr/sbin/devfsadm
|
---|
38 | BIN_BOOTADM=/sbin/bootadm
|
---|
39 | BIN_SVCADM=/usr/sbin/svcadm
|
---|
40 | BIN_SVCCFG=/usr/sbin/svccfg
|
---|
41 | BIN_IFCONFIG=/sbin/ifconfig
|
---|
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 |
|
---|
50 | MOD_VBOXFLT=vboxflt
|
---|
51 | DESC_VBOXFLT="NetFilter"
|
---|
52 |
|
---|
53 | MOD_VBI=vbi
|
---|
54 | DESC_VBI="Kernel Interface"
|
---|
55 |
|
---|
56 | MOD_VBOXUSBMON=vboxusbmon
|
---|
57 | DESC_VBOXUSBMON="USBMonitor"
|
---|
58 |
|
---|
59 | FATALOP=fatal
|
---|
60 | SILENTOP=silent
|
---|
61 | ISSILENT=
|
---|
62 |
|
---|
63 | infoprint()
|
---|
64 | {
|
---|
65 | if test "$ISSILENT" != "$SILENTOP"; then
|
---|
66 | echo 1>&2 "$1"
|
---|
67 | fi
|
---|
68 | }
|
---|
69 |
|
---|
70 | subprint()
|
---|
71 | {
|
---|
72 | if test "$ISSILENT" != "$SILENTOP"; then
|
---|
73 | echo 1>&2 " - $1"
|
---|
74 | fi
|
---|
75 | }
|
---|
76 |
|
---|
77 | warnprint()
|
---|
78 | {
|
---|
79 | if test "$ISSILENT" != "$SILENTOP"; then
|
---|
80 | echo 1>&2 "* Warning!! $1"
|
---|
81 | fi
|
---|
82 | }
|
---|
83 |
|
---|
84 | errorprint()
|
---|
85 | {
|
---|
86 | echo 1>&2 "## $1"
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 | # check_bin_path()
|
---|
91 | # !! failure is always fatal
|
---|
92 | check_bin_path()
|
---|
93 | {
|
---|
94 | if test -z "$1"; then
|
---|
95 | errorprint "missing argument to check_bin_path()"
|
---|
96 | exit 1
|
---|
97 | fi
|
---|
98 |
|
---|
99 | if test ! -x "$1"; then
|
---|
100 | errorprint "$1 missing or is not an executable"
|
---|
101 | exit 1
|
---|
102 | fi
|
---|
103 | return 0
|
---|
104 | }
|
---|
105 |
|
---|
106 | # find_bins()
|
---|
107 | # !! failure is always fatal
|
---|
108 | find_bins()
|
---|
109 | {
|
---|
110 | # Search only for binaries that might be in different locations
|
---|
111 | BIN_IFCONFIG=`which ifconfig 2> /dev/null`
|
---|
112 | BIN_SVCS=`which svcs 2> /dev/null`
|
---|
113 |
|
---|
114 | check_bin_path "$BIN_ADDDRV"
|
---|
115 | check_bin_path "$BIN_REMDRV"
|
---|
116 | check_bin_path "$BIN_MODLOAD"
|
---|
117 | check_bin_path "$BIN_MODUNLOAD"
|
---|
118 | check_bin_path "$BIN_MODINFO"
|
---|
119 | check_bin_path "$BIN_DEVFSADM"
|
---|
120 | check_bin_path "$BIN_BOOTADM"
|
---|
121 | check_bin_path "$BIN_SVCADM"
|
---|
122 | check_bin_path "$BIN_SVCCFG"
|
---|
123 | check_bin_path "$BIN_SVCS"
|
---|
124 | check_bin_path "$BIN_IFCONFIG"
|
---|
125 | }
|
---|
126 |
|
---|
127 | # check_root()
|
---|
128 | # !! failure is always fatal
|
---|
129 | check_root()
|
---|
130 | {
|
---|
131 | idbin=/usr/xpg4/bin/id
|
---|
132 | if test ! -x "$idbin"; then
|
---|
133 | found=`which id 2> /dev/null`
|
---|
134 | if test ! -x "$found"; then
|
---|
135 | errorprint "Failed to find a suitable user id executable."
|
---|
136 | exit 1
|
---|
137 | else
|
---|
138 | idbin=$found
|
---|
139 | fi
|
---|
140 | fi
|
---|
141 |
|
---|
142 | if test `$idbin -u` -ne 0; then
|
---|
143 | errorprint "This script must be run with administrator privileges."
|
---|
144 | exit 1
|
---|
145 | fi
|
---|
146 | }
|
---|
147 |
|
---|
148 | # check_zone()
|
---|
149 | # !! failure is always fatal
|
---|
150 | check_zone()
|
---|
151 | {
|
---|
152 | currentzone=`zonename`
|
---|
153 | if test "$currentzone" != "global"; then
|
---|
154 | errorprint "This script must be run from the global zone."
|
---|
155 | exit 1
|
---|
156 | fi
|
---|
157 | }
|
---|
158 |
|
---|
159 | # check_isa()
|
---|
160 | # !! failure is always fatal
|
---|
161 | check_isa()
|
---|
162 | {
|
---|
163 | currentisa=`uname -i`
|
---|
164 | if test "$currentisa" = "i86xpv"; then
|
---|
165 | errorprint "VirtualBox cannot run under xVM Dom0! Fatal Error, Aborting installation!"
|
---|
166 | exit 1
|
---|
167 | fi
|
---|
168 | }
|
---|
169 |
|
---|
170 | # check_module_arch()
|
---|
171 | # !! failure is always fatal
|
---|
172 | check_module_arch()
|
---|
173 | {
|
---|
174 | cputype=`isainfo -k`
|
---|
175 | if test "$cputype" != "amd64" && test "$cputype" != "i386"; then
|
---|
176 | errorprint "VirtualBox works only on i386/amd64 hosts, not $cputype"
|
---|
177 | exit 1
|
---|
178 | fi
|
---|
179 | }
|
---|
180 |
|
---|
181 | # module_added(modname)
|
---|
182 | # returns 1 if added, 0 otherwise
|
---|
183 | module_added()
|
---|
184 | {
|
---|
185 | if test -z "$1"; then
|
---|
186 | errorprint "missing argument to module_added()"
|
---|
187 | exit 1
|
---|
188 | fi
|
---|
189 |
|
---|
190 | loadentry=`cat /etc/name_to_major | grep $1`
|
---|
191 | if test -z "$loadentry"; then
|
---|
192 | return 1
|
---|
193 | fi
|
---|
194 | return 0
|
---|
195 | }
|
---|
196 |
|
---|
197 | # module_loaded(modname)
|
---|
198 | # returns 1 if loaded, 0 otherwise
|
---|
199 | module_loaded()
|
---|
200 | {
|
---|
201 | if test -z "$1"; then
|
---|
202 | errorprint "missing argument to module_loaded()"
|
---|
203 | exit 1
|
---|
204 | fi
|
---|
205 |
|
---|
206 | modname=$1
|
---|
207 | # modinfo should now work properly since we prevent module autounloading
|
---|
208 | loadentry=`$BIN_MODINFO | grep $modname`
|
---|
209 | if test -z "$loadentry"; then
|
---|
210 | return 1
|
---|
211 | fi
|
---|
212 | return 0
|
---|
213 | }
|
---|
214 |
|
---|
215 | # add_driver(modname, moddesc, [driverperm], [fatal])
|
---|
216 | # failure: depends on [fatal]
|
---|
217 | add_driver()
|
---|
218 | {
|
---|
219 | if test -z "$1" || test -z "$2"; then
|
---|
220 | errorprint "missing argument to add_driver()"
|
---|
221 | exit 1
|
---|
222 | fi
|
---|
223 |
|
---|
224 | modname="$1"
|
---|
225 | moddesc="$2"
|
---|
226 | modperm="$3"
|
---|
227 | if test "$3" = "$FATALOP"; then
|
---|
228 | fatal="$FATALOP"
|
---|
229 | modperm=""
|
---|
230 | fi
|
---|
231 | if test "$4" = "$FATALOP"; then
|
---|
232 | fatal="$FATALOP"
|
---|
233 | fi
|
---|
234 |
|
---|
235 | if test -n "$modperm"; then
|
---|
236 | $BIN_ADDDRV -m"$modperm" $modname
|
---|
237 | else
|
---|
238 | $BIN_ADDDRV $modname
|
---|
239 | fi
|
---|
240 |
|
---|
241 | if test $? -ne 0; then
|
---|
242 | subprint "Adding: $moddesc module ...FAILED!"
|
---|
243 | if test "$fatal" = "$FATALOP"; then
|
---|
244 | exit 1
|
---|
245 | fi
|
---|
246 | return 1
|
---|
247 | fi
|
---|
248 | return 0
|
---|
249 | }
|
---|
250 |
|
---|
251 | # rem_driver(modname, moddesc, [fatal])
|
---|
252 | # failure: depends on [fatal]
|
---|
253 | rem_driver()
|
---|
254 | {
|
---|
255 | if test -z "$1" || test -z "$2"; then
|
---|
256 | errorprint "missing argument to rem_driver()"
|
---|
257 | exit 1
|
---|
258 | fi
|
---|
259 |
|
---|
260 | modname=$1
|
---|
261 | moddesc=$2
|
---|
262 | fatal=$3
|
---|
263 | module_added $modname
|
---|
264 | if test "$?" -eq 0; then
|
---|
265 | $BIN_REMDRV $modname
|
---|
266 | if test $? -eq 0; then
|
---|
267 | subprint "Removed: $moddesc module"
|
---|
268 | return 0
|
---|
269 | else
|
---|
270 | subprint "Removing: $moddesc ...FAILED!"
|
---|
271 | if test "$fatal" = "$FATALOP"; then
|
---|
272 | exit 1
|
---|
273 | fi
|
---|
274 | return 1
|
---|
275 | fi
|
---|
276 | fi
|
---|
277 | }
|
---|
278 |
|
---|
279 | # unload_module(modname, moddesc, [fatal])
|
---|
280 | # failure: fatal
|
---|
281 | unload_module()
|
---|
282 | {
|
---|
283 | if test -z "$1" || test -z "$2"; then
|
---|
284 | errorprint "missing argument to unload_module()"
|
---|
285 | exit 1
|
---|
286 | fi
|
---|
287 |
|
---|
288 | modname=$1
|
---|
289 | moddesc=$2
|
---|
290 | fatal=$3
|
---|
291 | modid=`$BIN_MODINFO | grep $modname | cut -f 1 -d ' ' `
|
---|
292 | if test -n "$modid"; then
|
---|
293 | $BIN_MODUNLOAD -i $modid
|
---|
294 | if test $? -eq 0; then
|
---|
295 | subprint "Unloaded: $moddesc module"
|
---|
296 | else
|
---|
297 | subprint "Unloading: $moddesc ...FAILED!"
|
---|
298 | if test "$fatal" = "$FATALOP"; then
|
---|
299 | exit 1
|
---|
300 | fi
|
---|
301 | return 1
|
---|
302 | fi
|
---|
303 | fi
|
---|
304 | return 0
|
---|
305 | }
|
---|
306 |
|
---|
307 | # load_module(modname, moddesc, [fatal])
|
---|
308 | # pass "drv/modname" or "misc/vbi" etc.
|
---|
309 | # failure: fatal
|
---|
310 | load_module()
|
---|
311 | {
|
---|
312 | if test -z "$1" || test -z "$2"; then
|
---|
313 | errorprint "missing argument to load_module()"
|
---|
314 | exit 1
|
---|
315 | fi
|
---|
316 |
|
---|
317 | modname=$1
|
---|
318 | moddesc=$2
|
---|
319 | fatal=$3
|
---|
320 | $BIN_MODLOAD -p $modname
|
---|
321 | if test $? -eq 0; then
|
---|
322 | subprint "Loaded: $moddesc module"
|
---|
323 | return 0
|
---|
324 | else
|
---|
325 | subprint "Loading: $modesc ...FAILED!"
|
---|
326 | if test "$fatal" = "$FATALOP"; then
|
---|
327 | exit 1
|
---|
328 | fi
|
---|
329 | return 1
|
---|
330 | fi
|
---|
331 | }
|
---|
332 |
|
---|
333 | # install_drivers()
|
---|
334 | # !! failure is always fatal
|
---|
335 | install_drivers()
|
---|
336 | {
|
---|
337 | if test -n "_HARDENED_"; then
|
---|
338 | add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "'* 0600 root sys'" "$FATALOP"
|
---|
339 | else
|
---|
340 | add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "'* 0666 root sys'" "$FATALOP"
|
---|
341 | fi
|
---|
342 | load_module "drv/$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP"
|
---|
343 |
|
---|
344 | # Add vboxdrv to devlink.tab
|
---|
345 | sed -e '/name=vboxdrv/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
346 | echo "type=ddi_pseudo;name=vboxdrv \D" >> /etc/devlink.vbox
|
---|
347 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
348 |
|
---|
349 | # Create the device link
|
---|
350 | /usr/sbin/devfsadm -i "$MOD_VBOXDRV"
|
---|
351 |
|
---|
352 | if test $? -eq 0 && test -h "/dev/vboxdrv"; then
|
---|
353 |
|
---|
354 | if test -f /platform/i86pc/kernel/drv/vboxnet.conf; then
|
---|
355 | add_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
|
---|
356 | load_module "drv/$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
|
---|
357 | fi
|
---|
358 |
|
---|
359 | if test -f /platform/i86pc/kernel/drv/vboxflt.conf; then
|
---|
360 | add_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
|
---|
361 | load_module "drv/$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
|
---|
362 | fi
|
---|
363 |
|
---|
364 | if test -f /platform/i86pc/kernel/drv/vboxusbmon.conf && test "$HOST_OS_VERSION" != "5.10"; then
|
---|
365 | add_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP"
|
---|
366 | load_module "drv/$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP"
|
---|
367 |
|
---|
368 | # Add vboxusbmon to devlink.tab
|
---|
369 | sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
370 | echo "type=ddi_pseudo;name=vboxusbmon \D" >> /etc/devlink.vbox
|
---|
371 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
372 |
|
---|
373 | # Create the device link
|
---|
374 | /usr/sbin/devfsadm -i "$MOD_VBOXUSBMON"
|
---|
375 | if test $? -ne 0; then
|
---|
376 | errorprint "Failed to create device link for $MOD_VBOXUSBMON."
|
---|
377 | exit 1
|
---|
378 | fi
|
---|
379 | fi
|
---|
380 | else
|
---|
381 | errorprint "Failed to create device link for $MOD_VBOXDRV."
|
---|
382 | exit 1
|
---|
383 | fi
|
---|
384 |
|
---|
385 | return $?
|
---|
386 | }
|
---|
387 |
|
---|
388 | # remove_all([fatal])
|
---|
389 | # failure: depends on [fatal]
|
---|
390 | remove_drivers()
|
---|
391 | {
|
---|
392 | fatal=$1
|
---|
393 |
|
---|
394 | # Remove vboxdrv from devlink.tab
|
---|
395 | devlinkfound=`cat /etc/devlink.tab | grep vboxdrv`
|
---|
396 | if test -n "$devlinkfound"; then
|
---|
397 | sed -e '/name=vboxdrv/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
398 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
399 | fi
|
---|
400 |
|
---|
401 | # Remove vboxusbmon from devlink.tab
|
---|
402 | devlinkfound=`cat /etc/devlink.tab | grep vboxusbmon`
|
---|
403 | if test -n "$devlinkfound"; then
|
---|
404 | sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
405 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
406 | fi
|
---|
407 |
|
---|
408 | unload_module "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
|
---|
409 | rem_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
|
---|
410 |
|
---|
411 | unload_module "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
|
---|
412 | rem_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
|
---|
413 |
|
---|
414 | unload_module "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
|
---|
415 | rem_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
|
---|
416 |
|
---|
417 | unload_module "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
|
---|
418 | rem_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
|
---|
419 |
|
---|
420 | unload_module "$MOD_VBI" "$DESC_VBI" "$fatal"
|
---|
421 |
|
---|
422 | # remove devlinks
|
---|
423 | if test -h "/dev/vboxdrv" || test -f "/dev/vboxdrv"; then
|
---|
424 | rm -f /dev/vboxdrv
|
---|
425 | fi
|
---|
426 | if test -h "/dev/vboxusbmon" || test -f "/dev/vboxusbmon"; then
|
---|
427 | rm -f /dev/vboxusbmon
|
---|
428 | fi
|
---|
429 |
|
---|
430 | # unpatch nwam/dhcpagent fix
|
---|
431 | nwamfile=/etc/nwam/llp
|
---|
432 | nwambackupfile=$nwamfile.vbox
|
---|
433 | if test -f "$nwamfile"; then
|
---|
434 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
435 | mv -f $nwambackupfile $nwamfile
|
---|
436 | fi
|
---|
437 |
|
---|
438 | return 0
|
---|
439 | }
|
---|
440 |
|
---|
441 | # install_python_bindings(pythonbin)
|
---|
442 | # remarks: changes pwd
|
---|
443 | # failure: non fatal
|
---|
444 | install_python_bindings()
|
---|
445 | {
|
---|
446 | if test -z "$1" || test -z "$2"; then
|
---|
447 | errorprint "missing argument to install_python_bindings"
|
---|
448 | exit 1
|
---|
449 | fi
|
---|
450 |
|
---|
451 | pythonbin=$1
|
---|
452 | pythondesc=$2
|
---|
453 | if test -x "$pythonbin"; then
|
---|
454 | VBOX_INSTALL_PATH="$DIR_VBOXBASE"
|
---|
455 | export VBOX_INSTALL_PATH
|
---|
456 | cd $DIR_VBOXBASE/sdk/installer
|
---|
457 | $pythonbin ./vboxapisetup.py install > /dev/null
|
---|
458 | if test "$?" -eq 0; then
|
---|
459 | subprint "Installed: Bindings for $pythondesc"
|
---|
460 | fi
|
---|
461 | return 0
|
---|
462 | fi
|
---|
463 | return 1
|
---|
464 | }
|
---|
465 |
|
---|
466 |
|
---|
467 | # cleanup_install([fatal])
|
---|
468 | # failure: depends on [fatal]
|
---|
469 | cleanup_install()
|
---|
470 | {
|
---|
471 | fatal=$1
|
---|
472 |
|
---|
473 | # stop and unregister webservice SMF
|
---|
474 | servicefound=`$BIN_SVCS -a | grep "virtualbox/webservice" 2>/dev/null`
|
---|
475 | if test ! -z "$servicefound"; then
|
---|
476 | $BIN_SVCADM disable -s svc:/application/virtualbox/webservice:default
|
---|
477 | $BIN_SVCCFG delete svc:/application/virtualbox/webservice:default
|
---|
478 | if test "$?" -eq 0; then
|
---|
479 | subprint "Unloaded: Web service"
|
---|
480 | else
|
---|
481 | subprint "Unloading: Web service ...ERROR(S)."
|
---|
482 | fi
|
---|
483 | fi
|
---|
484 |
|
---|
485 | # stop and unregister zoneaccess SMF
|
---|
486 | servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" 2>/dev/null`
|
---|
487 | if test ! -z "$servicefound"; then
|
---|
488 | $BIN_SVCADM disable -s svc:/application/virtualbox/zoneaccess
|
---|
489 | $BIN_SVCCFG delete svc:/application/virtualbox/zoneaccess
|
---|
490 | if test "$?" -eq 0; then
|
---|
491 | subprint "Unloaded: Zone access service"
|
---|
492 | else
|
---|
493 | subprint "Unloading: Zone access service ...ERROR(S)."
|
---|
494 | fi
|
---|
495 | fi
|
---|
496 |
|
---|
497 | # unplumb vboxnet0
|
---|
498 | vboxnetup=`$BIN_IFCONFIG vboxnet0 >/dev/null 2>&1`
|
---|
499 | if test "$?" -eq 0; then
|
---|
500 | $BIN_IFCONFIG vboxnet0 unplumb
|
---|
501 | if test "$?" -ne 0; then
|
---|
502 | errorprint "VirtualBox NetAdapter 'vboxnet0' couldn't be unplumbed (probably in use)."
|
---|
503 | if test "$fatal" = "$FATALOP"; then
|
---|
504 | exit 1
|
---|
505 | fi
|
---|
506 | fi
|
---|
507 | fi
|
---|
508 | }
|
---|
509 |
|
---|
510 |
|
---|
511 | # postinstall()
|
---|
512 | # !! failure is always fatal
|
---|
513 | postinstall()
|
---|
514 | {
|
---|
515 | infoprint "Loading VirtualBox kernel modules..."
|
---|
516 | install_drivers
|
---|
517 |
|
---|
518 | if test "$?" -eq 0; then
|
---|
519 | if test -f /platform/i86pc/kernel/drv/vboxnet.conf; then
|
---|
520 | # nwam/dhcpagent fix
|
---|
521 | nwamfile=/etc/nwam/llp
|
---|
522 | nwambackupfile=$nwamfile.vbox
|
---|
523 | if test -f "$nwamfile"; then
|
---|
524 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
525 | echo "vboxnet0 static 192.168.56.1" >> $nwambackupfile
|
---|
526 | mv -f $nwambackupfile $nwamfile
|
---|
527 | fi
|
---|
528 |
|
---|
529 | # plumb and configure vboxnet0
|
---|
530 | $BIN_IFCONFIG vboxnet0 plumb up
|
---|
531 | if test "$?" -eq 0; then
|
---|
532 | $BIN_IFCONFIG vboxnet0 192.168.56.1 netmask 255.255.255.0 up
|
---|
533 | else
|
---|
534 | # Should this be fatal?
|
---|
535 | warnprint "Failed to bring up vboxnet0!!"
|
---|
536 | fi
|
---|
537 | fi
|
---|
538 |
|
---|
539 | if test -f /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml || test -f /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml; then
|
---|
540 | infoprint "Configuring services..."
|
---|
541 | fi
|
---|
542 |
|
---|
543 | # Web service
|
---|
544 | if test -f /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml; then
|
---|
545 | /usr/sbin/svccfg import /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml
|
---|
546 | /usr/sbin/svcadm disable -s svc:/application/virtualbox/webservice:default
|
---|
547 | if test "$?" -eq 0; then
|
---|
548 | subprint "Loaded: Web service"
|
---|
549 | else
|
---|
550 | subprint "Loading: Web service ...ERROR(S)."
|
---|
551 | fi
|
---|
552 | fi
|
---|
553 |
|
---|
554 | # Zone access service
|
---|
555 | if test -f /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml; then
|
---|
556 | /usr/sbin/svccfg import /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml
|
---|
557 | /usr/sbin/svcadm enable -s svc:/application/virtualbox/zoneaccess
|
---|
558 | if test "$?" -eq 0; then
|
---|
559 | subprint "Loaded: Zone access service"
|
---|
560 | else
|
---|
561 | subprint "Loading: Zone access service ...ERROR(S)."
|
---|
562 | fi
|
---|
563 | fi
|
---|
564 |
|
---|
565 | # Install python bindings
|
---|
566 | if test -f "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py" || test -h "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py"; then
|
---|
567 | PYTHONBIN=`which python 2> /dev/null`
|
---|
568 | if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
|
---|
569 | infoprint "Installing Python bindings..."
|
---|
570 |
|
---|
571 | INSTALLEDIT=1
|
---|
572 | PYTHONBIN=`which python2.4 2>/dev/null`
|
---|
573 | install_python_bindings "$PYTHONBIN" "Python 2.4"
|
---|
574 | if test "$?" -eq 0; then
|
---|
575 | INSTALLEDIT=0
|
---|
576 | fi
|
---|
577 | PYTHONBIN=`which python2.5 2>/dev/null`
|
---|
578 | install_python_bindings "$PYTHONBIN" "Python 2.5"
|
---|
579 | if test "$?" -eq 0; then
|
---|
580 | INSTALLEDIT=0
|
---|
581 | fi
|
---|
582 | PYTHONBIN=`which python2.6 2>/dev/null`
|
---|
583 | install_python_bindings "$PYTHONBIN" "Python 2.6"
|
---|
584 | if test "$?" -eq 0; then
|
---|
585 | INSTALLEDIT=0
|
---|
586 | fi
|
---|
587 |
|
---|
588 | # remove files installed by Python build
|
---|
589 | rm -rf $DIR_VBOXBASE/sdk/installer/build
|
---|
590 |
|
---|
591 | if test "$INSTALLEDIT" -ne 0; then
|
---|
592 | warnprint "No suitable Python version found. Required Python 2.4, 2.5 or 2.6."
|
---|
593 | warnprint "Skipped installing the Python bindings."
|
---|
594 | fi
|
---|
595 | else
|
---|
596 | warnprint "Python not found, skipped installed Python bindings."
|
---|
597 | fi
|
---|
598 | fi
|
---|
599 |
|
---|
600 | # Update boot archive
|
---|
601 | infoprint "Updating the boot archive..."
|
---|
602 | $BIN_BOOTADM update-archive > /dev/null
|
---|
603 |
|
---|
604 | return 0
|
---|
605 | else
|
---|
606 | errorprint "Failed to update boot-archive"
|
---|
607 | exit 666
|
---|
608 | fi
|
---|
609 | return 1
|
---|
610 | }
|
---|
611 |
|
---|
612 | # preremove([fatal])
|
---|
613 | # failure: depends on [fatal]
|
---|
614 | preremove()
|
---|
615 | {
|
---|
616 | fatal=$1
|
---|
617 |
|
---|
618 | cleanup_install "$fatal"
|
---|
619 |
|
---|
620 | remove_drivers "$fatal"
|
---|
621 | if test "$?" -eq 0; then
|
---|
622 | return 0;
|
---|
623 | fi
|
---|
624 | return 1
|
---|
625 | }
|
---|
626 |
|
---|
627 |
|
---|
628 |
|
---|
629 | # And it begins...
|
---|
630 | check_root
|
---|
631 | check_isa
|
---|
632 | check_zone
|
---|
633 | find_bins
|
---|
634 |
|
---|
635 | drvop=$1
|
---|
636 | if test "$2" = "$FATALOP" || test "$3" = "$FATALOP"; then
|
---|
637 | fatal=$FATALOP
|
---|
638 | fi
|
---|
639 | if test "$2" = "$SILENTOP" || test "$3" = "$SILENTOP"; then
|
---|
640 | ISSILENT=$SILENTOP
|
---|
641 | fi
|
---|
642 |
|
---|
643 | case "$drvop" in
|
---|
644 | postinstall)
|
---|
645 | check_module_arch
|
---|
646 | postinstall
|
---|
647 | ;;
|
---|
648 | preremove)
|
---|
649 | preremove "$fatal"
|
---|
650 | ;;
|
---|
651 | install_drivers)
|
---|
652 | check_module_arch
|
---|
653 | install_drivers
|
---|
654 | ;;
|
---|
655 | remove_drivers)
|
---|
656 | remove_drivers "$fatal"
|
---|
657 | ;;
|
---|
658 | *)
|
---|
659 | echo "Usage: $0 postinstall|preremove|install_drivers|remove_drivers [fatal] [silent]"
|
---|
660 | exit 1
|
---|
661 | esac
|
---|
662 |
|
---|
663 | exit "$?"
|
---|
664 |
|
---|