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