1 | #!/bin/sh
|
---|
2 | # $Id: vboxconfig.sh 26852 2010-02-26 13:52:34Z 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 -f "$DIR_CONF/vboxdrv.conf"; then
|
---|
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 | else
|
---|
361 | errorprint "Extreme error! Missing $DIR_CONF/vboxdrv.conf, aborting."
|
---|
362 | return 1
|
---|
363 | fi
|
---|
364 |
|
---|
365 | # Add vboxdrv to devlink.tab
|
---|
366 | sed -e '/name=vboxdrv/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
367 | echo "type=ddi_pseudo;name=vboxdrv \D" >> /etc/devlink.vbox
|
---|
368 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
369 |
|
---|
370 | # Create the device link
|
---|
371 | /usr/sbin/devfsadm -i "$MOD_VBOXDRV"
|
---|
372 |
|
---|
373 | if test $? -eq 0 && test -h "/dev/vboxdrv"; then
|
---|
374 |
|
---|
375 | if test -f "$DIR_CONF/vboxnet.conf"; then
|
---|
376 | add_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
|
---|
377 | load_module "drv/$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
|
---|
378 | fi
|
---|
379 |
|
---|
380 | if test -f "$DIR_CONF/vboxflt.conf"; then
|
---|
381 | add_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
|
---|
382 | load_module "drv/$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
|
---|
383 | fi
|
---|
384 |
|
---|
385 | if test -f "$DIR_CONF/vboxusbmon.conf" && test "$HOST_OS_MAJORVERSION" != "5.10"; then
|
---|
386 | # For VirtualBox 3.1 the new USB code requires Nevada > 123
|
---|
387 | if test "$HOST_OS_MINORVERSION" -gt 123; then
|
---|
388 | add_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP" "not-$NULLOP" "'* 0666 root sys'"
|
---|
389 | load_module "drv/$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP"
|
---|
390 |
|
---|
391 | # Add vboxusbmon to devlink.tab
|
---|
392 | sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
393 | echo "type=ddi_pseudo;name=vboxusbmon \D" >> /etc/devlink.vbox
|
---|
394 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
395 |
|
---|
396 | # Create the device link
|
---|
397 | /usr/sbin/devfsadm -i "$MOD_VBOXUSBMON"
|
---|
398 | if test $? -ne 0; then
|
---|
399 | errorprint "Failed to create device link for $MOD_VBOXUSBMON."
|
---|
400 | exit 1
|
---|
401 | fi
|
---|
402 |
|
---|
403 | # Add vboxusb if present
|
---|
404 | # This driver is special, we need it in the boot-archive but since there is no
|
---|
405 | # USB device to attach to now (it's done at runtime) it will fail to attach so
|
---|
406 | # redirect attaching failure output to /dev/null
|
---|
407 | if test -f "$DIR_CONF/vboxusb.conf"; then
|
---|
408 | add_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP" "$NULLOP"
|
---|
409 | load_module "drv/$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP"
|
---|
410 | fi
|
---|
411 | else
|
---|
412 | warnprint "Solaris 5.11 snv_124 or higher required for USB support. Skipped installing USB support."
|
---|
413 | fi
|
---|
414 | fi
|
---|
415 | else
|
---|
416 | errorprint "Failed to create device link for $MOD_VBOXDRV."
|
---|
417 | exit 1
|
---|
418 | fi
|
---|
419 |
|
---|
420 | return $?
|
---|
421 | }
|
---|
422 |
|
---|
423 | # remove_all([fatal])
|
---|
424 | # failure: depends on [fatal]
|
---|
425 | remove_drivers()
|
---|
426 | {
|
---|
427 | fatal=$1
|
---|
428 |
|
---|
429 | # Remove vboxdrv from devlink.tab
|
---|
430 | devlinkfound=`cat /etc/devlink.tab | grep vboxdrv`
|
---|
431 | if test -n "$devlinkfound"; then
|
---|
432 | sed -e '/name=vboxdrv/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
433 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
434 | fi
|
---|
435 |
|
---|
436 | # Remove vboxusbmon from devlink.tab
|
---|
437 | devlinkfound=`cat /etc/devlink.tab | grep vboxusbmon`
|
---|
438 | if test -n "$devlinkfound"; then
|
---|
439 | sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
440 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
441 | fi
|
---|
442 |
|
---|
443 | unload_module "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
|
---|
444 | rem_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
|
---|
445 |
|
---|
446 | unload_module "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
|
---|
447 | rem_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
|
---|
448 |
|
---|
449 | unload_module "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
|
---|
450 | rem_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
|
---|
451 |
|
---|
452 | unload_module "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
|
---|
453 | rem_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
|
---|
454 |
|
---|
455 | unload_module "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
|
---|
456 | rem_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
|
---|
457 |
|
---|
458 | # No separate VBI since 3.1
|
---|
459 | # unload_module "$MOD_VBI" "$DESC_VBI" "$fatal"
|
---|
460 |
|
---|
461 | # remove devlinks
|
---|
462 | if test -h "/dev/vboxdrv" || test -f "/dev/vboxdrv"; then
|
---|
463 | rm -f /dev/vboxdrv
|
---|
464 | fi
|
---|
465 | if test -h "/dev/vboxusbmon" || test -f "/dev/vboxusbmon"; then
|
---|
466 | rm -f /dev/vboxusbmon
|
---|
467 | fi
|
---|
468 |
|
---|
469 | # unpatch nwam/dhcpagent fix
|
---|
470 | nwamfile=/etc/nwam/llp
|
---|
471 | nwambackupfile=$nwamfile.vbox
|
---|
472 | if test -f "$nwamfile"; then
|
---|
473 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
474 | mv -f $nwambackupfile $nwamfile
|
---|
475 | fi
|
---|
476 |
|
---|
477 | return 0
|
---|
478 | }
|
---|
479 |
|
---|
480 | # install_python_bindings(pythonbin)
|
---|
481 | # remarks: changes pwd
|
---|
482 | # failure: non fatal
|
---|
483 | install_python_bindings()
|
---|
484 | {
|
---|
485 | # The python binary might not be there, so just exit silently
|
---|
486 | if test -z "$1"; then
|
---|
487 | return 0
|
---|
488 | fi
|
---|
489 |
|
---|
490 | if test -z "$2"; then
|
---|
491 | errorprint "missing argument to install_python_bindings"
|
---|
492 | exit 1
|
---|
493 | fi
|
---|
494 |
|
---|
495 | pythonbin=$1
|
---|
496 | pythondesc=$2
|
---|
497 | if test -x "$pythonbin"; then
|
---|
498 | VBOX_INSTALL_PATH="$DIR_VBOXBASE"
|
---|
499 | export VBOX_INSTALL_PATH
|
---|
500 | cd $DIR_VBOXBASE/sdk/installer
|
---|
501 | $pythonbin ./vboxapisetup.py install > /dev/null
|
---|
502 | if test "$?" -eq 0; then
|
---|
503 | subprint "Installed: Bindings for $pythondesc"
|
---|
504 | fi
|
---|
505 | return 0
|
---|
506 | fi
|
---|
507 | return 1
|
---|
508 | }
|
---|
509 |
|
---|
510 |
|
---|
511 | # cleanup_install([fatal])
|
---|
512 | # failure: depends on [fatal]
|
---|
513 | cleanup_install()
|
---|
514 | {
|
---|
515 | fatal=$1
|
---|
516 |
|
---|
517 | # stop and unregister webservice SMF
|
---|
518 | servicefound=`$BIN_SVCS -a | grep "virtualbox/webservice" 2>/dev/null`
|
---|
519 | if test ! -z "$servicefound"; then
|
---|
520 | $BIN_SVCADM disable -s svc:/application/virtualbox/webservice:default
|
---|
521 | $BIN_SVCCFG delete svc:/application/virtualbox/webservice:default
|
---|
522 | if test "$?" -eq 0; then
|
---|
523 | subprint "Unloaded: Web service"
|
---|
524 | else
|
---|
525 | subprint "Unloading: Web service ...ERROR(S)."
|
---|
526 | fi
|
---|
527 | fi
|
---|
528 |
|
---|
529 | # stop and unregister zoneaccess SMF
|
---|
530 | servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" 2>/dev/null`
|
---|
531 | if test ! -z "$servicefound"; then
|
---|
532 | $BIN_SVCADM disable -s svc:/application/virtualbox/zoneaccess
|
---|
533 | $BIN_SVCCFG delete svc:/application/virtualbox/zoneaccess
|
---|
534 | if test "$?" -eq 0; then
|
---|
535 | subprint "Unloaded: Zone access service"
|
---|
536 | else
|
---|
537 | subprint "Unloading: Zone access service ...ERROR(S)."
|
---|
538 | fi
|
---|
539 | fi
|
---|
540 |
|
---|
541 | # unplumb all vboxnet instances
|
---|
542 | inst=0
|
---|
543 | while test $inst -ne $MOD_VBOXNET_INST; do
|
---|
544 | vboxnetup=`$BIN_IFCONFIG vboxnet$inst >/dev/null 2>&1`
|
---|
545 | if test "$?" -eq 0; then
|
---|
546 | $BIN_IFCONFIG vboxnet$inst unplumb
|
---|
547 | if test "$?" -ne 0; then
|
---|
548 | errorprint "VirtualBox NetAdapter 'vboxnet$inst' couldn't be unplumbed (probably in use)."
|
---|
549 | if test "$fatal" = "$FATALOP"; then
|
---|
550 | exit 1
|
---|
551 | fi
|
---|
552 | fi
|
---|
553 | fi
|
---|
554 |
|
---|
555 | # unplumb vboxnet0 ipv6
|
---|
556 | vboxnetup=`$BIN_IFCONFIG vboxnet$inst inet6 >/dev/null 2>&1`
|
---|
557 | if test "$?" -eq 0; then
|
---|
558 | $BIN_IFCONFIG vboxnet$inst inet6 unplumb
|
---|
559 | if test "$?" -ne 0; then
|
---|
560 | errorprint "VirtualBox NetAdapter 'vboxnet$inst' IPv6 couldn't be unplumbed (probably in use)."
|
---|
561 | if test "$fatal" = "$FATALOP"; then
|
---|
562 | exit 1
|
---|
563 | fi
|
---|
564 | fi
|
---|
565 | fi
|
---|
566 |
|
---|
567 | inst=`expr $inst + 1`
|
---|
568 | done
|
---|
569 | }
|
---|
570 |
|
---|
571 |
|
---|
572 | # postinstall()
|
---|
573 | # !! failure is always fatal
|
---|
574 | postinstall()
|
---|
575 | {
|
---|
576 | infoprint "Loading VirtualBox kernel modules..."
|
---|
577 | install_drivers
|
---|
578 |
|
---|
579 | if test "$?" -eq 0; then
|
---|
580 | if test -f "$DIR_CONF/vboxnet.conf"; then
|
---|
581 | # nwam/dhcpagent fix
|
---|
582 | nwamfile=/etc/nwam/llp
|
---|
583 | nwambackupfile=$nwamfile.vbox
|
---|
584 | if test -f "$nwamfile"; then
|
---|
585 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
586 |
|
---|
587 | # add all vboxnet instances as static to nwam
|
---|
588 | inst=0
|
---|
589 | networkn=56
|
---|
590 | while test $inst -ne $MOD_VBOXNET_INST; do
|
---|
591 | echo "vboxnet$inst static 192.168.$networkn.1" >> $nwambackupfile
|
---|
592 | inst=`expr $inst + 1`
|
---|
593 | networkn=`expr $networkn + 1`
|
---|
594 | done
|
---|
595 | mv -f $nwambackupfile $nwamfile
|
---|
596 | fi
|
---|
597 |
|
---|
598 | # plumb and configure vboxnet0
|
---|
599 | $BIN_IFCONFIG vboxnet0 plumb up
|
---|
600 | if test "$?" -eq 0; then
|
---|
601 | $BIN_IFCONFIG vboxnet0 192.168.56.1 netmask 255.255.255.0 up
|
---|
602 | else
|
---|
603 | # Should this be fatal?
|
---|
604 | warnprint "Failed to bring up vboxnet0!!"
|
---|
605 | fi
|
---|
606 | fi
|
---|
607 |
|
---|
608 | if test -f /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml || test -f /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml; then
|
---|
609 | infoprint "Configuring services..."
|
---|
610 | fi
|
---|
611 |
|
---|
612 | # Web service
|
---|
613 | if test -f /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml; then
|
---|
614 | /usr/sbin/svccfg import /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml
|
---|
615 | /usr/sbin/svcadm disable -s svc:/application/virtualbox/webservice:default
|
---|
616 | if test "$?" -eq 0; then
|
---|
617 | subprint "Loaded: Web service"
|
---|
618 | else
|
---|
619 | subprint "Loading: Web service ...ERROR(S)."
|
---|
620 | fi
|
---|
621 | fi
|
---|
622 |
|
---|
623 | # Zone access service
|
---|
624 | if test -f /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml; then
|
---|
625 | /usr/sbin/svccfg import /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml
|
---|
626 | /usr/sbin/svcadm enable -s svc:/application/virtualbox/zoneaccess
|
---|
627 | if test "$?" -eq 0; then
|
---|
628 | subprint "Loaded: Zone access service"
|
---|
629 | else
|
---|
630 | subprint "Loading: Zone access service ...ERROR(S)."
|
---|
631 | fi
|
---|
632 | fi
|
---|
633 |
|
---|
634 | # Install python bindings
|
---|
635 | if test -f "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py" || test -h "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py"; then
|
---|
636 | PYTHONBIN=`which python 2> /dev/null`
|
---|
637 | if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
|
---|
638 | infoprint "Installing Python bindings..."
|
---|
639 |
|
---|
640 | INSTALLEDIT=1
|
---|
641 | PYTHONBIN=`which python2.4 2>/dev/null`
|
---|
642 | install_python_bindings "$PYTHONBIN" "Python 2.4"
|
---|
643 | if test "$?" -eq 0; then
|
---|
644 | INSTALLEDIT=0
|
---|
645 | fi
|
---|
646 | PYTHONBIN=`which python2.5 2>/dev/null`
|
---|
647 | install_python_bindings "$PYTHONBIN" "Python 2.5"
|
---|
648 | if test "$?" -eq 0; then
|
---|
649 | INSTALLEDIT=0
|
---|
650 | fi
|
---|
651 | PYTHONBIN=`which python2.6 2>/dev/null`
|
---|
652 | install_python_bindings "$PYTHONBIN" "Python 2.6"
|
---|
653 | if test "$?" -eq 0; then
|
---|
654 | INSTALLEDIT=0
|
---|
655 | fi
|
---|
656 |
|
---|
657 | # remove files installed by Python build
|
---|
658 | rm -rf $DIR_VBOXBASE/sdk/installer/build
|
---|
659 |
|
---|
660 | if test "$INSTALLEDIT" -ne 0; then
|
---|
661 | warnprint "No suitable Python version found. Required Python 2.4, 2.5 or 2.6."
|
---|
662 | warnprint "Skipped installing the Python bindings."
|
---|
663 | fi
|
---|
664 | else
|
---|
665 | warnprint "Python not found, skipped installed Python bindings."
|
---|
666 | fi
|
---|
667 | fi
|
---|
668 |
|
---|
669 | # Update boot archive
|
---|
670 | infoprint "Updating the boot archive..."
|
---|
671 | $BIN_BOOTADM update-archive > /dev/null
|
---|
672 |
|
---|
673 | return 0
|
---|
674 | else
|
---|
675 | errorprint "Failed to update boot-archive"
|
---|
676 | exit 666
|
---|
677 | fi
|
---|
678 | return 1
|
---|
679 | }
|
---|
680 |
|
---|
681 | # preremove([fatal])
|
---|
682 | # failure: depends on [fatal]
|
---|
683 | preremove()
|
---|
684 | {
|
---|
685 | fatal=$1
|
---|
686 |
|
---|
687 | cleanup_install "$fatal"
|
---|
688 |
|
---|
689 | remove_drivers "$fatal"
|
---|
690 | if test "$?" -eq 0; then
|
---|
691 | return 0;
|
---|
692 | fi
|
---|
693 | return 1
|
---|
694 | }
|
---|
695 |
|
---|
696 |
|
---|
697 |
|
---|
698 | # And it begins...
|
---|
699 | check_root
|
---|
700 | check_isa
|
---|
701 | check_zone
|
---|
702 | find_bins
|
---|
703 |
|
---|
704 | # Get command line options
|
---|
705 | while test $# -gt 0;
|
---|
706 | do
|
---|
707 | case "$1" in
|
---|
708 | --postinstall | --preremove | --installdrivers | --removedrivers | --setupdrivers)
|
---|
709 | drvop="$1"
|
---|
710 | ;;
|
---|
711 | --fatal)
|
---|
712 | fatal="$FATALOP"
|
---|
713 | ;;
|
---|
714 | --silent)
|
---|
715 | ISSILENT="$SILENTOP"
|
---|
716 | ;;
|
---|
717 | --ips)
|
---|
718 | ISIPS="$IPSOP"
|
---|
719 | ;;
|
---|
720 | --altkerndir)
|
---|
721 | # Use alternate kernel driver config folder (dev only)
|
---|
722 | DIR_CONF="/usr/kernel/drv"
|
---|
723 | ;;
|
---|
724 | *)
|
---|
725 | break
|
---|
726 | ;;
|
---|
727 | esac
|
---|
728 | shift
|
---|
729 | done
|
---|
730 |
|
---|
731 | case "$drvop" in
|
---|
732 | --postinstall)
|
---|
733 | check_module_arch
|
---|
734 | postinstall
|
---|
735 | ;;
|
---|
736 | --preremove)
|
---|
737 | preremove "$fatal"
|
---|
738 | ;;
|
---|
739 | --installdrivers)
|
---|
740 | check_module_arch
|
---|
741 | install_drivers
|
---|
742 | ;;
|
---|
743 | --removedrivers)
|
---|
744 | remove_drivers "$fatal"
|
---|
745 | ;;
|
---|
746 | --setupdrivers)
|
---|
747 | remove_drivers "$fatal"
|
---|
748 | install_drivers
|
---|
749 | ;;
|
---|
750 | *)
|
---|
751 | errorprint "Invalid operation $drvop"
|
---|
752 | exit 1
|
---|
753 | esac
|
---|
754 |
|
---|
755 | exit "$?"
|
---|
756 |
|
---|