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