1 | #!/bin/sh
|
---|
2 | # $Id: vboxconfig.sh 22082 2009-08-07 17:57:05Z 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.alldomusa.eu.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 | warnprint()
|
---|
71 | {
|
---|
72 | if test "$ISSILENT" != "$SILENTOP"; then
|
---|
73 | echo 1>&2 "* Warning!! $1"
|
---|
74 | fi
|
---|
75 | }
|
---|
76 |
|
---|
77 | success()
|
---|
78 | {
|
---|
79 | if test "$ISSILENT" != "$SILENTOP"; then
|
---|
80 | echo 1>&2 "$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`
|
---|
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 | modulepath="$DIR_MOD_32/$MOD_VBOXDRV"
|
---|
176 | if test "$cputype" = "amd64"; then
|
---|
177 | modulepath="$DIR_MOD_64/$MOD_VBOXDRV"
|
---|
178 | elif test "$cputype" != "i386"; then
|
---|
179 | errorprint "VirtualBox works only on i386/amd64 architectures, not $cputype"
|
---|
180 | exit 1
|
---|
181 | fi
|
---|
182 |
|
---|
183 | # If things are where they should be, return success
|
---|
184 | if test -f "$modulepath" || test -h "$modulepath"; then
|
---|
185 | return 0
|
---|
186 | fi
|
---|
187 |
|
---|
188 | # Something's screwed, let us go a step further and check if user has mixed up x86/amd64
|
---|
189 | # amd64 ISA, x86 kernel module??
|
---|
190 | if test "$cputype" = "amd64"; then
|
---|
191 | modulepath="$DIR_MOD_32/$MOD_VBOXDRV"
|
---|
192 | if test -f "$modulepath"; then
|
---|
193 | errorprint "Found 32-bit module instead of 64-bit. Please install the amd64 package!"
|
---|
194 | exit 1
|
---|
195 | fi
|
---|
196 | else
|
---|
197 | # x86 ISA, amd64 kernel module??
|
---|
198 | modulepath="$DIR_MOD_64/$MOD_VBOXDRV"
|
---|
199 | if test -f "$modulepath"; then
|
---|
200 | errorprint "Found 64-bit module instead of 32-bit. Please install the x86 package!"
|
---|
201 | exit 1
|
---|
202 | fi
|
---|
203 | fi
|
---|
204 |
|
---|
205 | # Shouldn't really happen...
|
---|
206 | errorprint "VirtualBox Host kernel module NOT installed."
|
---|
207 | exit 1
|
---|
208 | }
|
---|
209 |
|
---|
210 | # module_added(modname)
|
---|
211 | # returns 0 if added, 1 otherwise
|
---|
212 | module_added()
|
---|
213 | {
|
---|
214 | if test -z "$1"; then
|
---|
215 | errorprint "missing argument to module_added()"
|
---|
216 | exit 1
|
---|
217 | fi
|
---|
218 |
|
---|
219 | loadentry=`cat /etc/name_to_major | grep $1`
|
---|
220 | if test -z "$loadentry"; then
|
---|
221 | return 1
|
---|
222 | fi
|
---|
223 | return 0
|
---|
224 | }
|
---|
225 |
|
---|
226 | # module_loaded(modname)
|
---|
227 | # returns 1 if loaded, 0 otherwise
|
---|
228 | module_loaded()
|
---|
229 | {
|
---|
230 | if test -z "$1"; then
|
---|
231 | errorprint "missing argument to module_loaded()"
|
---|
232 | exit 1
|
---|
233 | fi
|
---|
234 |
|
---|
235 | modname=$1
|
---|
236 | # modinfo should now work properly since we prevent module autounloading
|
---|
237 | loadentry=`$BIN_MODINFO | grep $modname`
|
---|
238 | if test -z "$loadentry"; then
|
---|
239 | return 1
|
---|
240 | fi
|
---|
241 | return 0
|
---|
242 | }
|
---|
243 |
|
---|
244 | # add_driver(modname, moddesc, [driverperm], [fatal])
|
---|
245 | # failure: depends on [fatal]
|
---|
246 | add_driver()
|
---|
247 | {
|
---|
248 | if test -z "$1" || test -z "$2"; then
|
---|
249 | errorprint "missing argument to add_driver()"
|
---|
250 | exit 1
|
---|
251 | fi
|
---|
252 |
|
---|
253 | modname="$1"
|
---|
254 | moddesc="$2"
|
---|
255 | modperm="$3"
|
---|
256 | if test "$3" = "$FATALOP"; then
|
---|
257 | fatal="$FATALOP"
|
---|
258 | modperm=""
|
---|
259 | fi
|
---|
260 | if test "$4" = "$FATALOP"; then
|
---|
261 | fatal="$FATALOP"
|
---|
262 | fi
|
---|
263 |
|
---|
264 | if test -n "$modperm"; then
|
---|
265 | $BIN_ADDDRV -m"$modperm" $modname
|
---|
266 | else
|
---|
267 | $BIN_ADDDRV $modname
|
---|
268 | fi
|
---|
269 |
|
---|
270 | if test $? -ne 0; then
|
---|
271 | errorprint " - Adding: $moddesc module ...FAILED!"
|
---|
272 | if test "$fatal" = "$FATALOP"; then
|
---|
273 | exit 1
|
---|
274 | fi
|
---|
275 | return 1
|
---|
276 | fi
|
---|
277 | return 0
|
---|
278 | }
|
---|
279 |
|
---|
280 | # rem_driver(modname, moddesc, [fatal])
|
---|
281 | # failure: depends on [fatal]
|
---|
282 | rem_driver()
|
---|
283 | {
|
---|
284 | if test -z "$1" || test -z "$2"; then
|
---|
285 | errorprint "missing argument to rem_driver()"
|
---|
286 | exit 1
|
---|
287 | fi
|
---|
288 |
|
---|
289 | modname=$1
|
---|
290 | moddesc=$2
|
---|
291 | fatal=$3
|
---|
292 | module_added $modname
|
---|
293 | if test "$?" -eq 0; then
|
---|
294 | $BIN_REMDRV $modname
|
---|
295 | if test $? -eq 0; then
|
---|
296 | success " - Removed: $moddesc module"
|
---|
297 | return 0
|
---|
298 | else
|
---|
299 | errorprint " - Removing: $moddesc ...FAILED!"
|
---|
300 | if test "$fatal" = "$FATALOP"; then
|
---|
301 | exit 1
|
---|
302 | fi
|
---|
303 | return 1
|
---|
304 | fi
|
---|
305 | fi
|
---|
306 | }
|
---|
307 |
|
---|
308 | # unload_module(modname, moddesc, [fatal])
|
---|
309 | # failure: fatal
|
---|
310 | unload_module()
|
---|
311 | {
|
---|
312 | if test -z "$1" || test -z "$2"; then
|
---|
313 | errorprint "missing argument to unload_module()"
|
---|
314 | exit 1
|
---|
315 | fi
|
---|
316 |
|
---|
317 | modname=$1
|
---|
318 | moddesc=$2
|
---|
319 | fatal=$3
|
---|
320 | modid=`$BIN_MODINFO | grep $modname | cut -f 1 -d ' ' `
|
---|
321 | if test -n "$modid"; then
|
---|
322 | $BIN_MODUNLOAD -i $modid
|
---|
323 | if test $? -eq 0; then
|
---|
324 | success " - Unloaded: $moddesc module"
|
---|
325 | else
|
---|
326 | errorprint " - Unloading: $moddesc ...FAILED!"
|
---|
327 | if test "$fatal" = "$FATALOP"; then
|
---|
328 | exit 1
|
---|
329 | fi
|
---|
330 | return 1
|
---|
331 | fi
|
---|
332 | fi
|
---|
333 | return 0
|
---|
334 | }
|
---|
335 |
|
---|
336 | # load_module(modname, moddesc, [fatal])
|
---|
337 | # pass "drv/modname" or "misc/vbi" etc.
|
---|
338 | # failure: fatal
|
---|
339 | load_module()
|
---|
340 | {
|
---|
341 | if test -z "$1" || test -z "$2"; then
|
---|
342 | errorprint "missing argument to load_module()"
|
---|
343 | exit 1
|
---|
344 | fi
|
---|
345 |
|
---|
346 | modname=$1
|
---|
347 | moddesc=$2
|
---|
348 | fatal=$3
|
---|
349 | $BIN_MODLOAD -p $modname
|
---|
350 | if test $? -eq 0; then
|
---|
351 | success " - Loaded: $moddesc module"
|
---|
352 | return 0
|
---|
353 | else
|
---|
354 | errorprint " - Loading: $modesc ...FAILED!"
|
---|
355 | if test "$fatal" = "$FATALOP"; then
|
---|
356 | exit 1
|
---|
357 | fi
|
---|
358 | return 1
|
---|
359 | fi
|
---|
360 | }
|
---|
361 |
|
---|
362 | # install_drivers()
|
---|
363 | # !! failure is always fatal
|
---|
364 | install_drivers()
|
---|
365 | {
|
---|
366 | if test -n "_HARDENED_"; then
|
---|
367 | add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "'* 0600 root sys'" "$FATALOP"
|
---|
368 | else
|
---|
369 | add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "'* 0666 root sys'" "$FATALOP"
|
---|
370 | fi
|
---|
371 | load_module "drv/$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP"
|
---|
372 |
|
---|
373 | # Add vboxdrv to devlink.tab
|
---|
374 | sed -e '/name=vboxdrv/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
375 | echo "type=ddi_pseudo;name=vboxdrv \D" >> /etc/devlink.vbox
|
---|
376 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
377 |
|
---|
378 | # Create the device link
|
---|
379 | /usr/sbin/devfsadm -i "$MOD_VBOXDRV"
|
---|
380 |
|
---|
381 | if test $? -eq 0 && test -h "/dev/vboxdrv"; then
|
---|
382 |
|
---|
383 | if test -f /platform/i86pc/kernel/drv/vboxnet.conf; then
|
---|
384 | add_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
|
---|
385 | load_module "drv/$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
|
---|
386 | fi
|
---|
387 |
|
---|
388 | if test -f /platform/i86pc/kernel/drv/vboxflt.conf; then
|
---|
389 | add_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
|
---|
390 | load_module "drv/$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
|
---|
391 | fi
|
---|
392 |
|
---|
393 | if test -f /platform/i86pc/kernel/drv/vboxusbmon.conf && test "$HOST_OS_VERSION" != "5.10"; then
|
---|
394 | add_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP"
|
---|
395 | load_module "drv/$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP"
|
---|
396 |
|
---|
397 | # Add vboxusbmon to devlink.tab
|
---|
398 | sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
399 | echo "type=ddi_pseudo;name=vboxusbmon \D" >> /etc/devlink.vbox
|
---|
400 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
401 |
|
---|
402 | # Create the device link
|
---|
403 | /usr/sbin/devfsadm -i "$MOD_VBOXUSBMON"
|
---|
404 | if test $? -ne 0; then
|
---|
405 | errorprint "Failed to create device link for $MOD_VBOXUSBMON."
|
---|
406 | exit 1
|
---|
407 | fi
|
---|
408 | fi
|
---|
409 | else
|
---|
410 | errorprint "Failed to create device link for $MOD_VBOXDRV."
|
---|
411 | exit 1
|
---|
412 | fi
|
---|
413 |
|
---|
414 | return $?
|
---|
415 | }
|
---|
416 |
|
---|
417 | # remove_all([fatal])
|
---|
418 | # failure: depends on [fatal]
|
---|
419 | remove_drivers()
|
---|
420 | {
|
---|
421 | fatal=$1
|
---|
422 |
|
---|
423 | # Remove vboxdrv from devlink.tab
|
---|
424 | devlinkfound=`cat /etc/devlink.tab | grep vboxdrv`
|
---|
425 | if test -n "$devlinkfound"; then
|
---|
426 | sed -e '/name=vboxdrv/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
427 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
428 | fi
|
---|
429 |
|
---|
430 | # Remove vboxusbmon from devlink.tab
|
---|
431 | devlinkfound=`cat /etc/devlink.tab | grep vboxusbmon`
|
---|
432 | if test -n "$devlinkfound"; then
|
---|
433 | sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
434 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
435 | fi
|
---|
436 |
|
---|
437 | unload_module "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
|
---|
438 | rem_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
|
---|
439 |
|
---|
440 | unload_module "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
|
---|
441 | rem_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
|
---|
442 |
|
---|
443 | unload_module "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
|
---|
444 | rem_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
|
---|
445 |
|
---|
446 | unload_module "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
|
---|
447 | rem_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
|
---|
448 |
|
---|
449 | unload_module "$MOD_VBI" "$DESC_VBI" "$fatal"
|
---|
450 |
|
---|
451 | # remove devlinks
|
---|
452 | if test -h "/dev/vboxdrv" || test -f "/dev/vboxdrv"; then
|
---|
453 | rm -f /dev/vboxdrv
|
---|
454 | fi
|
---|
455 | if test -h "/dev/vboxusbmon" || test -f "/dev/vboxusbmon"; then
|
---|
456 | rm -f /dev/vboxusbmon
|
---|
457 | fi
|
---|
458 |
|
---|
459 | # unpatch nwam/dhcpagent fix
|
---|
460 | nwamfile=/etc/nwam/llp
|
---|
461 | nwambackupfile=$nwamfile.vbox
|
---|
462 | if test -f "$nwamfile"; then
|
---|
463 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
464 | mv -f $nwambackupfile $nwamfile
|
---|
465 | fi
|
---|
466 |
|
---|
467 | return 0
|
---|
468 | }
|
---|
469 |
|
---|
470 | # install_python_bindings(pythonbin)
|
---|
471 | # remarks: changes pwd
|
---|
472 | # failure: non fatal
|
---|
473 | install_python_bindings()
|
---|
474 | {
|
---|
475 | PYTHONBIN=$1
|
---|
476 | if test -x "$PYTHONBIN"; then
|
---|
477 | VBOX_INSTALL_PATH="$DIR_VBOXBASE"
|
---|
478 | export VBOX_INSTALL_PATH
|
---|
479 | cd $DIR_VBOXBASE/sdk/installer
|
---|
480 | $PYTHONBIN ./vboxapisetup.py install > /dev/null
|
---|
481 | return 0
|
---|
482 | fi
|
---|
483 | return 1
|
---|
484 | }
|
---|
485 |
|
---|
486 |
|
---|
487 | # cleanup_install([fatal])
|
---|
488 | # failure: depends on [fatal]
|
---|
489 | cleanup_install()
|
---|
490 | {
|
---|
491 | fatal=$1
|
---|
492 |
|
---|
493 | # stop and unregister webservice SMF
|
---|
494 | servicefound=`$BIN_SVCS -a | grep "virtualbox/webservice" 2>/dev/null`
|
---|
495 | if test ! -z "$servicefound"; then
|
---|
496 | $BIN_SVCADM disable -s svc:/application/virtualbox/webservice:default
|
---|
497 | $BIN_SVCCFG delete svc:/application/virtualbox/webservice:default
|
---|
498 | if test "$?" -eq 0; then
|
---|
499 | success " - Unloaded: Web service"
|
---|
500 | else
|
---|
501 | warnprint " - Unloading: Web service ...ERROR(S)."
|
---|
502 | fi
|
---|
503 | fi
|
---|
504 |
|
---|
505 | # stop and unregister zoneaccess SMF
|
---|
506 | servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" 2>/dev/null`
|
---|
507 | if test ! -z "$servicefound"; then
|
---|
508 | $BIN_SVCADM disable -s svc:/application/virtualbox/zoneaccess
|
---|
509 | $BIN_SVCCFG delete svc:/application/virtualbox/zoneaccess
|
---|
510 | if test "$?" -eq 0; then
|
---|
511 | success " - Unloaded: Zone access service"
|
---|
512 | else
|
---|
513 | warnprint " - Unloading: Zone access service ...ERROR(S)."
|
---|
514 | fi
|
---|
515 | fi
|
---|
516 |
|
---|
517 | # unplumb vboxnet0
|
---|
518 | vboxnetup=`$BIN_IFCONFIG vboxnet0 >/dev/null 2>&1`
|
---|
519 | if test "$?" -eq 0; then
|
---|
520 | $BIN_IFCONFIG vboxnet0 unplumb
|
---|
521 | if test "$?" -ne 0; then
|
---|
522 | errorprint "VirtualBox NetAdapter 'vboxnet0' couldn't be unplumbed (probably in use)."
|
---|
523 | if test "$fatal" = "$FATALOP"; then
|
---|
524 | exit 1
|
---|
525 | fi
|
---|
526 | fi
|
---|
527 | fi
|
---|
528 | }
|
---|
529 |
|
---|
530 |
|
---|
531 | # postinstall()
|
---|
532 | # !! failure is always fatal
|
---|
533 | postinstall()
|
---|
534 | {
|
---|
535 | infoprint "Loading VirtualBox kernel modules..."
|
---|
536 | install_drivers
|
---|
537 |
|
---|
538 | if test "$?" -eq 0; then
|
---|
539 | if test -f /platform/i86pc/kernel/drv/vboxnet.conf; then
|
---|
540 | # nwam/dhcpagent fix
|
---|
541 | nwamfile=/etc/nwam/llp
|
---|
542 | nwambackupfile=$nwamfile.vbox
|
---|
543 | if test -f "$nwamfile"; then
|
---|
544 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
545 | echo "vboxnet0 static 192.168.56.1" >> $nwambackupfile
|
---|
546 | mv -f $nwambackupfile $nwamfile
|
---|
547 | fi
|
---|
548 |
|
---|
549 | # plumb and configure vboxnet0
|
---|
550 | $BIN_IFCONFIG vboxnet0 plumb up
|
---|
551 | if test "$?" -eq 0; then
|
---|
552 | $BIN_IFCONFIG vboxnet0 192.168.56.1 netmask 255.255.255.0 up
|
---|
553 | else
|
---|
554 | # Should this be fatal?
|
---|
555 | warnprint "Failed to bring up vboxnet0!!"
|
---|
556 | fi
|
---|
557 | fi
|
---|
558 |
|
---|
559 | if test -f /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml || test -f /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml; then
|
---|
560 | infoprint "Configuring services..."
|
---|
561 | fi
|
---|
562 |
|
---|
563 | # Web service
|
---|
564 | if test -f /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml; then
|
---|
565 | /usr/sbin/svccfg import /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml
|
---|
566 | /usr/sbin/svcadm disable -s svc:/application/virtualbox/webservice:default
|
---|
567 | if test "$?" -eq 0; then
|
---|
568 | success " - Loaded: Web service"
|
---|
569 | else
|
---|
570 | warnprint " - Loading: Web service ...ERROR(S)."
|
---|
571 | fi
|
---|
572 | fi
|
---|
573 |
|
---|
574 | # Zone access service
|
---|
575 | if test -f /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml; then
|
---|
576 | /usr/sbin/svccfg import /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml
|
---|
577 | /usr/sbin/svcadm enable -s svc:/application/virtualbox/zoneaccess
|
---|
578 | if test "$?" -eq 0; then
|
---|
579 | success " - Loaded: Zone access service"
|
---|
580 | else
|
---|
581 | warnprint " - Loading: Zone access service ...ERROR(S)."
|
---|
582 | fi
|
---|
583 | fi
|
---|
584 |
|
---|
585 | # Install python bindings
|
---|
586 | if test -f "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py" || test -h "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py"; then
|
---|
587 | PYTHONBIN=`which python 2> /dev/null`
|
---|
588 | if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
|
---|
589 | infoprint "Installing Python bindings..."
|
---|
590 |
|
---|
591 | INSTALLEDIT=1
|
---|
592 | PYTHONBIN=`which python2.4 2>/dev/null`
|
---|
593 | install_python_bindings "$PYTHONBIN"
|
---|
594 | if test "$?" -eq 0; then
|
---|
595 | INSTALLEDIT=0
|
---|
596 | fi
|
---|
597 | PYTHONBIN=`which python2.5 2>/dev/null`
|
---|
598 | install_python_bindings "$PYTHONBIN"
|
---|
599 | if test "$?" -eq 0; then
|
---|
600 | INSTALLEDIT=0
|
---|
601 | fi
|
---|
602 | PYTHONBIN=`which python2.6 2>/dev/null`
|
---|
603 | install_python_bindings "$PYTHONBIN"
|
---|
604 | if test "$?" -eq 0; then
|
---|
605 | INSTALLEDIT=0
|
---|
606 | fi
|
---|
607 |
|
---|
608 | # remove files installed by Python build
|
---|
609 | rm -rf $DIR_VBOXBASE/sdk/installer/build
|
---|
610 |
|
---|
611 | if test "$INSTALLEDIT" -ne 0; then
|
---|
612 | warnprint "No suitable Python version found. Required Python 2.4, 2.5 or 2.6."
|
---|
613 | warnprint "Skipped installing the Python bindings."
|
---|
614 | fi
|
---|
615 | else
|
---|
616 | warnprint "Python not found, skipped installed Python bindings."
|
---|
617 | fi
|
---|
618 | fi
|
---|
619 |
|
---|
620 | # Update boot archive
|
---|
621 | infoprint "Updating the boot archive..."
|
---|
622 | $BIN_BOOTADM update-archive > /dev/null
|
---|
623 |
|
---|
624 | return 0
|
---|
625 | else
|
---|
626 | errorprint "Failed to update boot-archive"
|
---|
627 | exit 666
|
---|
628 | fi
|
---|
629 | return 1
|
---|
630 | }
|
---|
631 |
|
---|
632 | # preremove([fatal])
|
---|
633 | # failure: depends on [fatal]
|
---|
634 | preremove()
|
---|
635 | {
|
---|
636 | fatal=$1
|
---|
637 |
|
---|
638 | cleanup_install "$fatal"
|
---|
639 |
|
---|
640 | remove_drivers "$fatal"
|
---|
641 | if test "$?" -eq 0; then
|
---|
642 | return 0;
|
---|
643 | fi
|
---|
644 | return 1
|
---|
645 | }
|
---|
646 |
|
---|
647 |
|
---|
648 |
|
---|
649 | # And it begins...
|
---|
650 | check_root
|
---|
651 | check_isa
|
---|
652 | check_zone
|
---|
653 | find_bins
|
---|
654 |
|
---|
655 | drvop=$1
|
---|
656 | if test "$2" = "$FATALOP" || test "$3" = "$FATALOP"; then
|
---|
657 | fatal=$FATALOP
|
---|
658 | fi
|
---|
659 | if test "$2" = "$SILENTOP" || test "$3" = "$SILENTOP"; then
|
---|
660 | ISSILENT=$SILENTOP
|
---|
661 | fi
|
---|
662 |
|
---|
663 | case "$drvop" in
|
---|
664 | postinstall)
|
---|
665 | check_module_arch
|
---|
666 | postinstall
|
---|
667 | ;;
|
---|
668 | preremove)
|
---|
669 | preremove "$fatal"
|
---|
670 | ;;
|
---|
671 | install_drivers)
|
---|
672 | check_module_arch
|
---|
673 | install_drivers
|
---|
674 | ;;
|
---|
675 | remove_drivers)
|
---|
676 | remove_drivers "$fatal"
|
---|
677 | ;;
|
---|
678 | *)
|
---|
679 | echo "Usage: $0 postinstall|preremove|install_drivers|remove_drivers [fatal] [silent]"
|
---|
680 | exit 1
|
---|
681 | esac
|
---|
682 |
|
---|
683 | exit "$?"
|
---|
684 |
|
---|