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