1 | #!/bin/sh
|
---|
2 | # $Id: vboxconfig.sh 40190 2012-02-21 09:51:01Z vboxsync $
|
---|
3 |
|
---|
4 | #
|
---|
5 | # VirtualBox Configuration Script, Solaris host.
|
---|
6 | #
|
---|
7 | # Copyright (C) 2009-2010 Oracle Corporation
|
---|
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 |
|
---|
18 | # Never use exit 2 or exit 20 etc., the return codes are used in
|
---|
19 | # SRv4 postinstall procedures which carry special meaning. Just use exit 1 for failure.
|
---|
20 |
|
---|
21 | # LC_ALL should take precedence over LC_* and LANG but whatever...
|
---|
22 | LC_ALL=C
|
---|
23 | export LC_ALL
|
---|
24 |
|
---|
25 | LANG=C
|
---|
26 | export LANG
|
---|
27 |
|
---|
28 | DIR_VBOXBASE="$PKG_INSTALL_ROOT/opt/VirtualBox"
|
---|
29 | DIR_CONF="$PKG_INSTALL_ROOT/platform/i86pc/kernel/drv"
|
---|
30 | DIR_MOD_32="$PKG_INSTALL_ROOT/platform/i86pc/kernel/drv"
|
---|
31 | DIR_MOD_64="$DIR_MOD_32/amd64"
|
---|
32 |
|
---|
33 | # Default paths, these will be overridden by 'which' if they don't exist
|
---|
34 | BIN_ADDDRV=/usr/sbin/add_drv
|
---|
35 | BIN_REMDRV=/usr/sbin/rem_drv
|
---|
36 | BIN_MODLOAD=/usr/sbin/modload
|
---|
37 | BIN_MODUNLOAD=/usr/sbin/modunload
|
---|
38 | BIN_MODINFO=/usr/sbin/modinfo
|
---|
39 | BIN_DEVFSADM=/usr/sbin/devfsadm
|
---|
40 | BIN_BOOTADM=/sbin/bootadm
|
---|
41 | BIN_SVCADM=/usr/sbin/svcadm
|
---|
42 | BIN_SVCCFG=/usr/sbin/svccfg
|
---|
43 | BIN_IFCONFIG=/sbin/ifconfig
|
---|
44 | BIN_SVCS=/usr/bin/svcs
|
---|
45 | BIN_ID=/usr/bin/id
|
---|
46 | BIN_PKILL=/usr/bin/pkill
|
---|
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 (STREAMS)"
|
---|
58 |
|
---|
59 | MOD_VBOXBOW=vboxbow
|
---|
60 | DESC_VBOXBOW="NetFilter (Crossbow)"
|
---|
61 |
|
---|
62 | # No Separate VBI since (3.1)
|
---|
63 | #MOD_VBI=vbi
|
---|
64 | #DESC_VBI="Kernel Interface"
|
---|
65 |
|
---|
66 | MOD_VBOXUSBMON=vboxusbmon
|
---|
67 | DESC_VBOXUSBMON="USBMonitor"
|
---|
68 |
|
---|
69 | MOD_VBOXUSB=vboxusb
|
---|
70 | DESC_VBOXUSB="USB"
|
---|
71 |
|
---|
72 | UPDATEBOOTARCHIVE=0
|
---|
73 | REMOTEINST=0
|
---|
74 | FATALOP=fatal
|
---|
75 | NULLOP=nulloutput
|
---|
76 | SILENTOP=silent
|
---|
77 | IPSOP=ips
|
---|
78 | ISSILENT=
|
---|
79 | ISIPS=
|
---|
80 |
|
---|
81 | infoprint()
|
---|
82 | {
|
---|
83 | if test "$ISSILENT" != "$SILENTOP"; then
|
---|
84 | echo 1>&2 "$1"
|
---|
85 | fi
|
---|
86 | }
|
---|
87 |
|
---|
88 | subprint()
|
---|
89 | {
|
---|
90 | if test "$ISSILENT" != "$SILENTOP"; then
|
---|
91 | echo 1>&2 " - $1"
|
---|
92 | fi
|
---|
93 | }
|
---|
94 |
|
---|
95 | warnprint()
|
---|
96 | {
|
---|
97 | if test "$ISSILENT" != "$SILENTOP"; then
|
---|
98 | echo 1>&2 " * Warning!! $1"
|
---|
99 | fi
|
---|
100 | }
|
---|
101 |
|
---|
102 | errorprint()
|
---|
103 | {
|
---|
104 | echo 1>&2 "## $1"
|
---|
105 | }
|
---|
106 |
|
---|
107 | helpprint()
|
---|
108 | {
|
---|
109 | echo 1>&2 "$1"
|
---|
110 | }
|
---|
111 |
|
---|
112 | printusage()
|
---|
113 | {
|
---|
114 | helpprint "VirtualBox Configuration Script"
|
---|
115 | helpprint "usage: $0 <operation> [options]"
|
---|
116 | helpprint
|
---|
117 | helpprint "<operation> must be one of the following:"
|
---|
118 | helpprint " --postinstall Perform full post installation procedure"
|
---|
119 | helpprint " --preremove Perform full pre remove procedure"
|
---|
120 | helpprint " --installdrivers Only install the drivers"
|
---|
121 | helpprint " --removedrivers Only remove the drivers"
|
---|
122 | helpprint " --setupdrivers Setup drivers, reloads existing drivers"
|
---|
123 | helpprint
|
---|
124 | helpprint "[options] are one or more of the following:"
|
---|
125 | helpprint " --silent Silent mode"
|
---|
126 | helpprint " --fatal Don't continue on failure (required for postinstall)"
|
---|
127 | helpprint " --ips This is an IPS package postinstall/preremove"
|
---|
128 | helpprint " --altkerndir Use /usr/kernel/drv as the driver directory"
|
---|
129 | helpprint
|
---|
130 | }
|
---|
131 |
|
---|
132 | # find_bin_path()
|
---|
133 | # !! failure is always fatal
|
---|
134 | find_bin_path()
|
---|
135 | {
|
---|
136 | if test -z "$1"; then
|
---|
137 | errorprint "missing argument to find_bin_path()"
|
---|
138 | exit 1
|
---|
139 | fi
|
---|
140 |
|
---|
141 | binfilename=`basename $1`
|
---|
142 | binfilepath=`which $binfilename 2> /dev/null`
|
---|
143 | if test -x "$binfilepath"; then
|
---|
144 | echo "$binfilepath"
|
---|
145 | return 0
|
---|
146 | else
|
---|
147 | errorprint "$1 missing or is not an executable"
|
---|
148 | exit 1
|
---|
149 | fi
|
---|
150 | }
|
---|
151 |
|
---|
152 | # find_bins()
|
---|
153 | # !! failure is always fatal
|
---|
154 | find_bins()
|
---|
155 | {
|
---|
156 | # Search only for binaries that might be in different locations
|
---|
157 | if test ! -x "$BIN_ID"; then
|
---|
158 | BIN_ID=`find_bin_path "$BIN_ID"`
|
---|
159 | fi
|
---|
160 |
|
---|
161 | if test ! -x "$BIN_ADDDRV"; then
|
---|
162 | BIN_ADDDRV=`find_bin_path "$BIN_ADDDRV"`
|
---|
163 | fi
|
---|
164 |
|
---|
165 | if test ! -x "$BIN_REMDRV"; then
|
---|
166 | BIN_REMDRV=`find_bin_path "$BIN_REMDRV"`
|
---|
167 | fi
|
---|
168 |
|
---|
169 | if test ! -x "$BIN_MODLOAD"; then
|
---|
170 | BIN_MODLOAD=`check_bin_path "$BIN_MODLOAD"`
|
---|
171 | fi
|
---|
172 |
|
---|
173 | if test ! -x "$BIN_MODUNLOAD"; then
|
---|
174 | BIN_MODUNLOAD=`find_bin_path "$BIN_MODUNLOAD"`
|
---|
175 | fi
|
---|
176 |
|
---|
177 | if test ! -x "$BIN_MODINFO"; then
|
---|
178 | BIN_MODINFO=`find_bin_path "$BIN_MODINFO"`
|
---|
179 | fi
|
---|
180 |
|
---|
181 | if test ! -x "$BIN_DEVFSADM"; then
|
---|
182 | BIN_DEVFSADM=`find_bin_path "$BIN_DEVFSADM"`
|
---|
183 | fi
|
---|
184 |
|
---|
185 | if test ! -x "$BIN_BOOTADM"; then
|
---|
186 | BIN_BOOTADM=`find_bin_path "$BIN_BOOTADM"`
|
---|
187 | fi
|
---|
188 |
|
---|
189 | if test ! -x "$BIN_SVCADM"; then
|
---|
190 | BIN_SVCADM=`find_bin_path "$BIN_SVCADM"`
|
---|
191 | fi
|
---|
192 |
|
---|
193 | if test ! -x "$BIN_SVCCFG"; then
|
---|
194 | BIN_SVCCFG=`find_bin_path "$BIN_SVCCFG"`
|
---|
195 | fi
|
---|
196 |
|
---|
197 | if test ! -x "$BIN_SVCS"; then
|
---|
198 | BIN_SVCS=`find_bin_path "$BIN_SVCS"`
|
---|
199 | fi
|
---|
200 |
|
---|
201 | if test ! -x "$BIN_IFCONFIG"; then
|
---|
202 | BIN_IFCONFIG=`find_bin_path "$BIN_IFCONFIG"`
|
---|
203 | fi
|
---|
204 |
|
---|
205 | if test ! -x "$BIN_PKILL"; then
|
---|
206 | BIN_PKILL=`find_bin_path "$BIN_PKILL"`
|
---|
207 | fi
|
---|
208 | }
|
---|
209 |
|
---|
210 | # check_root()
|
---|
211 | # !! failure is always fatal
|
---|
212 | check_root()
|
---|
213 | {
|
---|
214 | # Don't use "-u" option as some id binaries don't support it, instead
|
---|
215 | # rely on "uid=101(username) gid=10(groupname) groups=10(staff)" output
|
---|
216 | curuid=`$BIN_ID | cut -f 2 -d '=' | cut -f 1 -d '('`
|
---|
217 | if test "$curuid" -ne 0; then
|
---|
218 | errorprint "This script must be run with administrator privileges."
|
---|
219 | exit 1
|
---|
220 | fi
|
---|
221 | }
|
---|
222 |
|
---|
223 | # get_sysinfo
|
---|
224 | # cannot fail
|
---|
225 | get_sysinfo()
|
---|
226 | {
|
---|
227 | BIN_PKG=`which pkg 2> /dev/null`
|
---|
228 | if test -x "$BIN_PKG"; then
|
---|
229 | PKGFMRI=`$BIN_PKG $BASEDIR_PKGOPT contents -H -t set -a name=pkg.fmri -o pkg.fmri pkg:/system/kernel 2> /dev/null`
|
---|
230 | if test -z "$PKGFMRI"; then
|
---|
231 | # Perhaps this is old pkg without '-a' option and/or system/kernel is missing and it's part of 'entire'
|
---|
232 | # Try fallback.
|
---|
233 | PKGFMRI=`$BIN_PKG $BASEDIR_PKGOPT contents -H -t set -o pkg.fmri entire | head -1 2> /dev/null`
|
---|
234 | if test -z "$PKGFMRI"; then
|
---|
235 | # Perhaps entire is conflicting. Try using opensolaris/entire.
|
---|
236 | # Last fallback try.
|
---|
237 | PKGFMRI=`$BIN_PKG $BASEDIR_PKGOPT contents -H -t set -o pkg.fmri opensolaris.org/entire | head -1 2> /dev/null`
|
---|
238 | fi
|
---|
239 | fi
|
---|
240 | if test ! -z "$PKGFMRI"; then
|
---|
241 | # The format is "pkg://solaris/system/[email protected],5.11-0.161:20110315T070332Z"
|
---|
242 | # or "pkg://solaris/system/[email protected],5.11-0.175.0.0.0.1.0:20111012T032837Z"
|
---|
243 | STR_KERN=`echo "$PKGFMRI" | sed 's/^.*\@//;s/\:.*//;s/.*,//'`
|
---|
244 | if test ! -z "$STR_KERN"; then
|
---|
245 | # The format is "5.11-0.161" or "5.11-0.175.0.0.0.1.0"
|
---|
246 | HOST_OS_MAJORVERSION=`echo "$STR_KERN" | cut -f1 -d'-'`
|
---|
247 | HOST_OS_MINORVERSION=`echo "$STR_KERN" | cut -f2 -d'-' | cut -f2 -d '.'`
|
---|
248 | else
|
---|
249 | errorprint "Failed to parse the Solaris kernel version."
|
---|
250 | exit 1
|
---|
251 | fi
|
---|
252 | else
|
---|
253 | errorprint "Failed to detect the Solaris kernel version."
|
---|
254 | exit 1
|
---|
255 | fi
|
---|
256 | else
|
---|
257 | HOST_OS_MAJORVERSION=`uname -r`
|
---|
258 | if test -z "$HOST_OS_MAJORVERSION" || test "$HOST_OS_MAJORVERSION" != "5.10"; then
|
---|
259 | # S11 without 'pkg' ?? Something's wrong... bail.
|
---|
260 | errorprint "Solaris $HOST_OS_MAJOR_VERSION detected without executable $BIN_PKG !? Confused."
|
---|
261 | exit 1
|
---|
262 | fi
|
---|
263 | if test "$REMOTEINST" -eq 0; then
|
---|
264 | # Use uname to verify it's S10.
|
---|
265 | # Major version is S10, Minor version is no longer relevant (or used), use uname -v so it gets something
|
---|
266 | # like "Generic_blah" for purely cosmetic purposes
|
---|
267 | HOST_OS_MINORVERSION=`uname -v`
|
---|
268 | else
|
---|
269 | # Remote installs from S10 local.
|
---|
270 | BIN_PKGCHK=`which pkgchk 2> /dev/null`
|
---|
271 | if test ! -x "$BIN_PKGCHK"; then
|
---|
272 | errorprint "Failed to find an executable pkgchk binary $BIN_PKGCHK."
|
---|
273 | errorprint "Cannot determine Solaris version on remote target $PKG_INSTALL_ROOT"
|
---|
274 | exit 1
|
---|
275 | fi
|
---|
276 |
|
---|
277 | REMOTE_S10=`$BIN_PKGCHK -l -p /kernel/amd64/genunix $BASEDIR_PKGOPT 2> /dev/null | grep SUNWckr | tr -d ' \t'`
|
---|
278 | if test ! -z "$REMOTE_S10" && test "$REMOTE_S10" = "SUNWckr"; then
|
---|
279 | HOST_OS_MAJORVERSION="5.10"
|
---|
280 | HOST_OS_MINORVERSION=""
|
---|
281 | else
|
---|
282 | errorprint "Remote target $PKG_INSTALL_ROOT is not Solaris 10."
|
---|
283 | errorprint "Will not attempt to install to an unidentified remote target."
|
---|
284 | exit 1
|
---|
285 | fi
|
---|
286 | fi
|
---|
287 | fi
|
---|
288 | }
|
---|
289 |
|
---|
290 | # check_zone()
|
---|
291 | # !! failure is always fatal
|
---|
292 | check_zone()
|
---|
293 | {
|
---|
294 | currentzone=`zonename`
|
---|
295 | if test "$currentzone" != "global"; then
|
---|
296 | errorprint "This script must be run from the global zone."
|
---|
297 | exit 1
|
---|
298 | fi
|
---|
299 | }
|
---|
300 |
|
---|
301 | # check_isa()
|
---|
302 | # !! failure is always fatal
|
---|
303 | check_isa()
|
---|
304 | {
|
---|
305 | currentisa=`uname -i`
|
---|
306 | if test "$currentisa" = "i86xpv"; then
|
---|
307 | errorprint "VirtualBox cannot run under xVM Dom0! Fatal Error, Aborting installation!"
|
---|
308 | exit 1
|
---|
309 | fi
|
---|
310 | }
|
---|
311 |
|
---|
312 | # check_module_arch()
|
---|
313 | # !! failure is always fatal
|
---|
314 | check_module_arch()
|
---|
315 | {
|
---|
316 | cputype=`isainfo -k`
|
---|
317 | if test "$cputype" != "amd64" && test "$cputype" != "i386"; then
|
---|
318 | errorprint "VirtualBox works only on i386/amd64 hosts, not $cputype"
|
---|
319 | exit 1
|
---|
320 | fi
|
---|
321 | }
|
---|
322 |
|
---|
323 | # update_boot_archive()
|
---|
324 | # cannot fail
|
---|
325 | update_boot_archive()
|
---|
326 | {
|
---|
327 | infoprint "Updating the boot archive..."
|
---|
328 | if test "$REMOTEINST" -eq 0; then
|
---|
329 | $BIN_BOOTADM update-archive > /dev/null
|
---|
330 | else
|
---|
331 | $BIN_BOOTADM update-archive -R "$PKG_INSTALL_ROOT" > /dev/null
|
---|
332 | fi
|
---|
333 | UPDATEBOOTARCHIVE=0
|
---|
334 | }
|
---|
335 |
|
---|
336 |
|
---|
337 | # module_added(modname)
|
---|
338 | # returns 1 if added, 0 otherwise
|
---|
339 | module_added()
|
---|
340 | {
|
---|
341 | if test -z "$1"; then
|
---|
342 | errorprint "missing argument to module_added()"
|
---|
343 | exit 1
|
---|
344 | fi
|
---|
345 |
|
---|
346 | # Add a space at end of module name to make sure we have a perfect match to avoid
|
---|
347 | # any substring matches: e.g "vboxusb" & "vboxusbmon"
|
---|
348 | loadentry=`cat "$PKG_INSTALL_ROOT/etc/name_to_major" | grep "$1 "`
|
---|
349 | if test -z "$loadentry"; then
|
---|
350 | return 1
|
---|
351 | fi
|
---|
352 | return 0
|
---|
353 | }
|
---|
354 |
|
---|
355 | # module_loaded(modname)
|
---|
356 | # returns 1 if loaded, 0 otherwise
|
---|
357 | module_loaded()
|
---|
358 | {
|
---|
359 | if test -z "$1"; then
|
---|
360 | errorprint "missing argument to module_loaded()"
|
---|
361 | exit 1
|
---|
362 | fi
|
---|
363 |
|
---|
364 | modname=$1
|
---|
365 | # modinfo should now work properly since we prevent module autounloading.
|
---|
366 | loadentry=`$BIN_MODINFO | grep "$modname "`
|
---|
367 | if test -z "$loadentry"; then
|
---|
368 | return 1
|
---|
369 | fi
|
---|
370 | return 0
|
---|
371 | }
|
---|
372 |
|
---|
373 | # add_driver(modname, moddesc, fatal, nulloutput, [driverperm])
|
---|
374 | # failure: depends on "fatal"
|
---|
375 | add_driver()
|
---|
376 | {
|
---|
377 | if test -z "$1" || test -z "$2"; then
|
---|
378 | errorprint "missing argument to add_driver()"
|
---|
379 | exit 1
|
---|
380 | fi
|
---|
381 |
|
---|
382 | modname="$1"
|
---|
383 | moddesc="$2"
|
---|
384 | fatal="$3"
|
---|
385 | nullop="$4"
|
---|
386 | modperm="$5"
|
---|
387 |
|
---|
388 | if test -n "$modperm"; then
|
---|
389 | if test "$nullop" = "$NULLOP"; then
|
---|
390 | $BIN_ADDDRV $BASEDIR_OPT -m"$modperm" $modname >/dev/null 2>&1
|
---|
391 | else
|
---|
392 | $BIN_ADDDRV $BASEDIR_OPT -m"$modperm" $modname
|
---|
393 | fi
|
---|
394 | else
|
---|
395 | if test "$nullop" = "$NULLOP"; then
|
---|
396 | $BIN_ADDDRV $BASEDIR_OPT $modname >/dev/null 2>&1
|
---|
397 | else
|
---|
398 | $BIN_ADDDRV $BASEDIR_OPT $modname
|
---|
399 | fi
|
---|
400 | fi
|
---|
401 |
|
---|
402 | if test $? -ne 0; then
|
---|
403 | subprint "Adding: $moddesc module ...FAILED!"
|
---|
404 | if test "$fatal" = "$FATALOP"; then
|
---|
405 | exit 1
|
---|
406 | fi
|
---|
407 | return 1
|
---|
408 | elif test "$REMOTEINST" -eq 1 && test "$?" -eq 0; then
|
---|
409 | subprint "Added: $moddesc driver"
|
---|
410 | fi
|
---|
411 | return 0
|
---|
412 | }
|
---|
413 |
|
---|
414 | # rem_driver(modname, moddesc, [fatal])
|
---|
415 | # failure: depends on [fatal]
|
---|
416 | rem_driver()
|
---|
417 | {
|
---|
418 | if test -z "$1" || test -z "$2"; then
|
---|
419 | errorprint "missing argument to rem_driver()"
|
---|
420 | exit 1
|
---|
421 | fi
|
---|
422 |
|
---|
423 | modname=$1
|
---|
424 | moddesc=$2
|
---|
425 | fatal=$3
|
---|
426 |
|
---|
427 | module_added $modname
|
---|
428 | if test "$?" -eq 0; then
|
---|
429 | UPDATEBOOTARCHIVE=1
|
---|
430 | if test "$ISIPS" != "$IPSOP"; then
|
---|
431 | $BIN_REMDRV $BASEDIR_OPT $modname
|
---|
432 | else
|
---|
433 | $BIN_REMDRV $BASEDIR_OPT $modname >/dev/null 2>&1
|
---|
434 | fi
|
---|
435 | # for remote installs, don't bother with return values of rem_drv
|
---|
436 | if test $? -eq 0; then
|
---|
437 | subprint "Removed: $moddesc module"
|
---|
438 | return 0
|
---|
439 | else
|
---|
440 | subprint "Removing: $moddesc ...FAILED!"
|
---|
441 | if test "$fatal" = "$FATALOP"; then
|
---|
442 | exit 1
|
---|
443 | fi
|
---|
444 | return 1
|
---|
445 | fi
|
---|
446 | fi
|
---|
447 | }
|
---|
448 |
|
---|
449 | # unload_module(modname, moddesc, [fatal])
|
---|
450 | # failure: fatal
|
---|
451 | unload_module()
|
---|
452 | {
|
---|
453 | if test -z "$1" || test -z "$2"; then
|
---|
454 | errorprint "missing argument to unload_module()"
|
---|
455 | exit 1
|
---|
456 | fi
|
---|
457 |
|
---|
458 | # No-OP for non-root installs
|
---|
459 | if test "$REMOTEINST" -eq 1; then
|
---|
460 | return 0
|
---|
461 | fi
|
---|
462 |
|
---|
463 | modname=$1
|
---|
464 | moddesc=$2
|
---|
465 | fatal=$3
|
---|
466 | modid=`$BIN_MODINFO | grep "$modname " | cut -f 1 -d ' ' `
|
---|
467 | if test -n "$modid"; then
|
---|
468 | $BIN_MODUNLOAD -i $modid
|
---|
469 | if test $? -eq 0; then
|
---|
470 | subprint "Unloaded: $moddesc module"
|
---|
471 | else
|
---|
472 | subprint "Unloading: $moddesc module ...FAILED!"
|
---|
473 | if test "$fatal" = "$FATALOP"; then
|
---|
474 | exit 1
|
---|
475 | fi
|
---|
476 | return 1
|
---|
477 | fi
|
---|
478 | fi
|
---|
479 | return 0
|
---|
480 | }
|
---|
481 |
|
---|
482 | # load_module(modname, moddesc, [fatal])
|
---|
483 | # pass "drv/modname" or "misc/vbi" etc.
|
---|
484 | # failure: fatal
|
---|
485 | load_module()
|
---|
486 | {
|
---|
487 | if test -z "$1" || test -z "$2"; then
|
---|
488 | errorprint "missing argument to load_module()"
|
---|
489 | exit 1
|
---|
490 | fi
|
---|
491 |
|
---|
492 | # No-OP for non-root installs
|
---|
493 | if test "$REMOTEINST" -eq 1; then
|
---|
494 | return 0
|
---|
495 | fi
|
---|
496 |
|
---|
497 | modname=$1
|
---|
498 | moddesc=$2
|
---|
499 | fatal=$3
|
---|
500 | $BIN_MODLOAD -p $modname
|
---|
501 | if test $? -eq 0; then
|
---|
502 | subprint "Loaded: $moddesc module"
|
---|
503 | return 0
|
---|
504 | else
|
---|
505 | subprint "Loading: $moddesc ...FAILED!"
|
---|
506 | if test "$fatal" = "$FATALOP"; then
|
---|
507 | exit 1
|
---|
508 | fi
|
---|
509 | return 1
|
---|
510 | fi
|
---|
511 | }
|
---|
512 |
|
---|
513 | load_vboxflt()
|
---|
514 | {
|
---|
515 | if test -f "$DIR_CONF/vboxflt.conf"; then
|
---|
516 | add_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
|
---|
517 | load_module "drv/$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP"
|
---|
518 | else
|
---|
519 | # For custom pkgs that optionally ship this module, let's not fail but just warn
|
---|
520 | warnprint "$DESC_VBOXFLT installation requested but not shipped in this package."
|
---|
521 | fi
|
---|
522 | }
|
---|
523 |
|
---|
524 | load_vboxbow()
|
---|
525 | {
|
---|
526 | if test -f "$DIR_CONF/vboxbow.conf"; then
|
---|
527 | add_driver "$MOD_VBOXBOW" "$DESC_VBOXBOW" "$FATALOP"
|
---|
528 | load_module "drv/$MOD_VBOXBOW" "$DESC_VBOXBOW" "$FATALOP"
|
---|
529 | else
|
---|
530 | # For custom pkgs that optionally ship this module, let's not fail but just warn
|
---|
531 | warnprint "$DESC_VBOXBOW installation requested but not shipped in this package."
|
---|
532 | fi
|
---|
533 | }
|
---|
534 |
|
---|
535 | # install_drivers()
|
---|
536 | # !! failure is always fatal
|
---|
537 | install_drivers()
|
---|
538 | {
|
---|
539 | if test -f "$DIR_CONF/vboxdrv.conf"; then
|
---|
540 | if test -n "_HARDENED_"; then
|
---|
541 | add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0600 root sys'"
|
---|
542 | else
|
---|
543 | add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" "not-$NULLOP" "'* 0666 root sys'"
|
---|
544 | fi
|
---|
545 | load_module "drv/$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP"
|
---|
546 | else
|
---|
547 | errorprint "Extreme error! Missing $DIR_CONF/vboxdrv.conf, aborting."
|
---|
548 | return 1
|
---|
549 | fi
|
---|
550 |
|
---|
551 | # Add vboxdrv to devlink.tab
|
---|
552 | if test -f "$PKG_INSTALL_ROOT/etc/devlink.tab"; then
|
---|
553 | sed -e '/name=vboxdrv/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
554 | echo "type=ddi_pseudo;name=vboxdrv \D" >> "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
555 | mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
|
---|
556 | else
|
---|
557 | errorprint "Missing $PKG_INSTALL_ROOT/etc/devlink.tab, aborting install"
|
---|
558 | return 1
|
---|
559 | fi
|
---|
560 |
|
---|
561 | # Create the device link for non-remote installs
|
---|
562 | if test "$REMOTEINST" -eq 0; then
|
---|
563 | /usr/sbin/devfsadm -i "$MOD_VBOXDRV"
|
---|
564 | if test $? -ne 0 || test ! -h "/dev/vboxdrv"; then
|
---|
565 | errorprint "Failed to create device link for $MOD_VBOXDRV."
|
---|
566 | exit 1
|
---|
567 | fi
|
---|
568 | fi
|
---|
569 |
|
---|
570 | # Load VBoxNetAdp
|
---|
571 | if test -f "$DIR_CONF/vboxnet.conf"; then
|
---|
572 | add_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
|
---|
573 | load_module "drv/$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP"
|
---|
574 | fi
|
---|
575 |
|
---|
576 | # If both vboxinst_vboxbow and vboxinst_vboxflt exist, bail.
|
---|
577 | if test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxflt" && test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxbow"; then
|
---|
578 | errorprint "Force-install files '$PKG_INSTALL_ROOT/etc/vboxinst_vboxflt' and '$PKG_INSTALL_ROOT/etc/vboxinst_vboxbow' both exist."
|
---|
579 | errorprint "Cannot load $DESC_VBOXFLT and $DESC_VBOXBOW drivers at the same time."
|
---|
580 | return 1
|
---|
581 | fi
|
---|
582 |
|
---|
583 | # If the force-install files exists, install blindly
|
---|
584 | if test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxflt"; then
|
---|
585 | load_vboxflt
|
---|
586 | elif test -f "$PKG_INSTALL_ROOT/etc/vboxinst_vboxbow"; then
|
---|
587 | infoprint "here"
|
---|
588 | load_vboxbow
|
---|
589 | else
|
---|
590 | # If host is S10 or S11 (< snv_159) or vboxbow isn't shipped, then load vboxflt
|
---|
591 | if test "$HOST_OS_MAJORVERSION" = "5.10" || test "$HOST_OS_MINORVERSION" -lt 159 || test ! -f "$DIR_CONF/vboxbow.conf"; then
|
---|
592 | load_vboxflt
|
---|
593 | else
|
---|
594 | # For S11 snv_159+ load vboxbow
|
---|
595 | load_vboxbow
|
---|
596 | fi
|
---|
597 | fi
|
---|
598 |
|
---|
599 | # Load VBoxUSBMon, VBoxUSB
|
---|
600 | if test -f "$DIR_CONF/vboxusbmon.conf" && test "$HOST_OS_MAJORVERSION" != "5.10"; then
|
---|
601 | # For VirtualBox 3.1 the new USB code requires Nevada > 123
|
---|
602 | if test "$HOST_OS_MINORVERSION" -gt 123; then
|
---|
603 | # Add a group "vboxuser" (8-character limit) for USB access.
|
---|
604 | # All users which need host USB-passthrough support will have to be added to this group.
|
---|
605 | groupadd vboxuser >/dev/null 2>&1
|
---|
606 |
|
---|
607 | add_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP" "not-$NULLOP" "'* 0666 root sys'"
|
---|
608 | load_module "drv/$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP"
|
---|
609 |
|
---|
610 | chown root:vboxuser "/devices/pseudo/vboxusbmon@0:vboxusbmon"
|
---|
611 |
|
---|
612 | # Add vboxusbmon to devlink.tab
|
---|
613 | sed -e '/name=vboxusbmon/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
614 | echo "type=ddi_pseudo;name=vboxusbmon \D" >> "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
615 | mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
|
---|
616 |
|
---|
617 | # Create the device link for non-remote installs
|
---|
618 | if test "$REMOTEINST" -eq 0; then
|
---|
619 | /usr/sbin/devfsadm -i "$MOD_VBOXUSBMON"
|
---|
620 | if test $? -ne 0; then
|
---|
621 | errorprint "Failed to create device link for $MOD_VBOXUSBMON."
|
---|
622 | exit 1
|
---|
623 | fi
|
---|
624 | fi
|
---|
625 |
|
---|
626 | # Add vboxusb if present
|
---|
627 | # This driver is special, we need it in the boot-archive but since there is no
|
---|
628 | # USB device to attach to now (it's done at runtime) it will fail to attach so
|
---|
629 | # redirect attaching failure output to /dev/null
|
---|
630 | if test -f "$DIR_CONF/vboxusb.conf"; then
|
---|
631 | add_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP" "$NULLOP"
|
---|
632 | load_module "drv/$MOD_VBOXUSB" "$DESC_VBOXUSB" "$FATALOP"
|
---|
633 | fi
|
---|
634 | else
|
---|
635 | if test -n "$HOST_OS_MINORVERSION"; then
|
---|
636 | warnprint "Solaris 5.11 build 124 or higher required for USB support. Skipped installing USB support."
|
---|
637 | else
|
---|
638 | warnprint "Failed to determine Solaris 5.11 snv version. Skipped installing USB support."
|
---|
639 | fi
|
---|
640 | fi
|
---|
641 | fi
|
---|
642 |
|
---|
643 | return $?
|
---|
644 | }
|
---|
645 |
|
---|
646 | # remove_drivers([fatal])
|
---|
647 | # failure: depends on [fatal]
|
---|
648 | remove_drivers()
|
---|
649 | {
|
---|
650 | fatal=$1
|
---|
651 |
|
---|
652 | # Remove vboxdrv from devlink.tab
|
---|
653 | if test -f "$PKG_INSTALL_ROOT/etc/devlink.tab"; then
|
---|
654 | devlinkfound=`cat "$PKG_INSTALL_ROOT/etc/devlink.tab" | grep vboxdrv`
|
---|
655 | if test -n "$devlinkfound"; then
|
---|
656 | sed -e '/name=vboxdrv/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
657 | mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
|
---|
658 | fi
|
---|
659 |
|
---|
660 | # Remove vboxusbmon from devlink.tab
|
---|
661 | devlinkfound=`cat "$PKG_INSTALL_ROOT/etc/devlink.tab" | grep vboxusbmon`
|
---|
662 | if test -n "$devlinkfound"; then
|
---|
663 | sed -e '/name=vboxusbmon/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
|
---|
664 | mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
|
---|
665 | fi
|
---|
666 | fi
|
---|
667 |
|
---|
668 | unload_module "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
|
---|
669 | rem_driver "$MOD_VBOXUSB" "$DESC_VBOXUSB" "$fatal"
|
---|
670 |
|
---|
671 | unload_module "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
|
---|
672 | rem_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal"
|
---|
673 |
|
---|
674 | unload_module "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
|
---|
675 | rem_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal"
|
---|
676 |
|
---|
677 | unload_module "$MOD_VBOXBOW" "$DESC_VBOXBOW" "$fatal"
|
---|
678 | rem_driver "$MOD_VBOXBOW" "$DESC_VBOXBOW" "$fatal"
|
---|
679 |
|
---|
680 | unload_module "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
|
---|
681 | rem_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal"
|
---|
682 |
|
---|
683 | unload_module "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
|
---|
684 | rem_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal"
|
---|
685 |
|
---|
686 | # No separate VBI since 3.1
|
---|
687 | # unload_module "$MOD_VBI" "$DESC_VBI" "$fatal"
|
---|
688 |
|
---|
689 | # remove devlinks
|
---|
690 | if test -h "$PKG_INSTALL_ROOT/dev/vboxdrv" || test -f "$PKG_INSTALL_ROOT/dev/vboxdrv"; then
|
---|
691 | rm -f "$PKG_INSTALL_ROOT/dev/vboxdrv"
|
---|
692 | fi
|
---|
693 | if test -h "$PKG_INSTALL_ROOT/dev/vboxusbmon" || test -f "$PKG_INSTALL_ROOT/dev/vboxusbmon"; then
|
---|
694 | rm -f "$PKG_INSTALL_ROOT/dev/vboxusbmon"
|
---|
695 | fi
|
---|
696 |
|
---|
697 | # unpatch nwam/dhcpagent fix
|
---|
698 | nwamfile="$PKG_INSTALL_ROOT/etc/nwam/llp"
|
---|
699 | nwambackupfile=$nwamfile.vbox
|
---|
700 | if test -f "$nwamfile"; then
|
---|
701 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
702 | mv -f $nwambackupfile $nwamfile
|
---|
703 | fi
|
---|
704 |
|
---|
705 | # remove netmask configuration
|
---|
706 | if test -h "$PKG_INSTALL_ROOT/etc/netmasks"; then
|
---|
707 | nmaskfile="$PKG_INSTALL_ROOT/etc/inet/netmasks"
|
---|
708 | else
|
---|
709 | nmaskfile="$PKG_INSTALL_ROOT/etc/netmasks"
|
---|
710 | fi
|
---|
711 | nmaskbackupfile=$nmaskfile.vbox
|
---|
712 | if test -f "$nmaskfile"; then
|
---|
713 | sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
|
---|
714 | mv -f $nmaskbackupfile $nmaskfile
|
---|
715 | fi
|
---|
716 |
|
---|
717 | if test $UPDATEBOOTARCHIVE -eq 1; then
|
---|
718 | update_boot_archive
|
---|
719 | fi
|
---|
720 |
|
---|
721 | return 0
|
---|
722 | }
|
---|
723 |
|
---|
724 | # install_python_bindings(pythonbin)
|
---|
725 | # remarks: changes pwd
|
---|
726 | # failure: non fatal
|
---|
727 | install_python_bindings()
|
---|
728 | {
|
---|
729 | # The python binary might not be there, so just exit silently
|
---|
730 | if test -z "$1"; then
|
---|
731 | return 0
|
---|
732 | fi
|
---|
733 |
|
---|
734 | if test -z "$2"; then
|
---|
735 | errorprint "missing argument to install_python_bindings"
|
---|
736 | exit 1
|
---|
737 | fi
|
---|
738 |
|
---|
739 | pythonbin=$1
|
---|
740 | pythondesc=$2
|
---|
741 | if test -x "$pythonbin"; then
|
---|
742 | VBOX_INSTALL_PATH="$DIR_VBOXBASE"
|
---|
743 | export VBOX_INSTALL_PATH
|
---|
744 | cd $DIR_VBOXBASE/sdk/installer
|
---|
745 | $pythonbin ./vboxapisetup.py install > /dev/null
|
---|
746 | if test "$?" -eq 0; then
|
---|
747 | subprint "Installed: Bindings for $pythondesc"
|
---|
748 | fi
|
---|
749 | return 0
|
---|
750 | fi
|
---|
751 | return 1
|
---|
752 | }
|
---|
753 |
|
---|
754 | # stop_process(processname)
|
---|
755 | # failure: depends on [fatal]
|
---|
756 | stop_process()
|
---|
757 | {
|
---|
758 | if test -z "$1"; then
|
---|
759 | errorprint "missing argument to stop_process()"
|
---|
760 | exit 1
|
---|
761 | fi
|
---|
762 |
|
---|
763 | procname=$1
|
---|
764 | procpid=`ps -eo pid,fname | grep $procname | grep -v grep | awk '{ print $1 }'`
|
---|
765 | if test ! -z "$procpid" && test "$procpid" -ge 0; then
|
---|
766 | $BIN_PKILL "$procname"
|
---|
767 | sleep 2
|
---|
768 | procpid=`ps -eo pid,fname | grep $procname | grep -v grep | awk '{ print $1 }'`
|
---|
769 | if test ! -z "$procpid" && test "$procpid" -ge 0; then
|
---|
770 | subprint "Terminating: $procname ...FAILED!"
|
---|
771 | if test "$fatal" = "$FATALOP"; then
|
---|
772 | exit 1
|
---|
773 | fi
|
---|
774 | else
|
---|
775 | subprint "Terminated: $procname"
|
---|
776 | fi
|
---|
777 | fi
|
---|
778 | }
|
---|
779 |
|
---|
780 |
|
---|
781 | # stop_service(servicename, shortFMRI-suitable for grep, full FMRI)
|
---|
782 | # failure: non fatal
|
---|
783 | stop_service()
|
---|
784 | {
|
---|
785 | if test -z "$1" || test -z "$2" || test -z "$3"; then
|
---|
786 | errorprint "missing argument to stop_service()"
|
---|
787 | exit 1
|
---|
788 | fi
|
---|
789 | servicefound=`$BIN_SVCS -a | grep "$2" 2>/dev/null`
|
---|
790 | if test ! -z "$servicefound"; then
|
---|
791 | $BIN_SVCADM disable -s "$3"
|
---|
792 | # Don't delete the manifest, this is handled by the manifest class action
|
---|
793 | # $BIN_SVCCFG delete "$3"
|
---|
794 | if test "$?" -eq 0; then
|
---|
795 | subprint "Unloaded: $1"
|
---|
796 | else
|
---|
797 | subprint "Unloading: $1 ...ERROR(S)."
|
---|
798 | fi
|
---|
799 | fi
|
---|
800 | }
|
---|
801 |
|
---|
802 |
|
---|
803 | # cleanup_install([fatal])
|
---|
804 | # failure: depends on [fatal]
|
---|
805 | cleanup_install()
|
---|
806 | {
|
---|
807 | fatal=$1
|
---|
808 |
|
---|
809 | # No-Op for remote installs
|
---|
810 | if test "$REMOTEINST" -eq 1; then
|
---|
811 | return 0
|
---|
812 | fi
|
---|
813 |
|
---|
814 | # stop the services
|
---|
815 | stop_service "Web service" "virtualbox/webservice" "svc:/application/virtualbox/webservice:default"
|
---|
816 | stop_service "Balloon control service" "virtualbox/balloonctrl" "svc:/application/virtualbox/balloonctrl:default"
|
---|
817 | stop_service "Zone access service" "virtualbox/zoneaccess" "svc:/application/virtualbox/zoneaccess:default"
|
---|
818 |
|
---|
819 | # unplumb all vboxnet instances for non-remote installs
|
---|
820 | inst=0
|
---|
821 | while test $inst -ne $MOD_VBOXNET_INST; do
|
---|
822 | vboxnetup=`$BIN_IFCONFIG vboxnet$inst >/dev/null 2>&1`
|
---|
823 | if test "$?" -eq 0; then
|
---|
824 | $BIN_IFCONFIG vboxnet$inst unplumb
|
---|
825 | if test "$?" -ne 0; then
|
---|
826 | errorprint "VirtualBox NetAdapter 'vboxnet$inst' couldn't be unplumbed (probably in use)."
|
---|
827 | if test "$fatal" = "$FATALOP"; then
|
---|
828 | exit 1
|
---|
829 | fi
|
---|
830 | fi
|
---|
831 | fi
|
---|
832 |
|
---|
833 | # unplumb vboxnet0 ipv6
|
---|
834 | vboxnetup=`$BIN_IFCONFIG vboxnet$inst inet6 >/dev/null 2>&1`
|
---|
835 | if test "$?" -eq 0; then
|
---|
836 | $BIN_IFCONFIG vboxnet$inst inet6 unplumb
|
---|
837 | if test "$?" -ne 0; then
|
---|
838 | errorprint "VirtualBox NetAdapter 'vboxnet$inst' IPv6 couldn't be unplumbed (probably in use)."
|
---|
839 | if test "$fatal" = "$FATALOP"; then
|
---|
840 | exit 1
|
---|
841 | fi
|
---|
842 | fi
|
---|
843 | fi
|
---|
844 |
|
---|
845 | inst=`expr $inst + 1`
|
---|
846 | done
|
---|
847 |
|
---|
848 | # Stop our other daemons, non-fatal
|
---|
849 | stop_process VBoxSVC
|
---|
850 | stop_process VBoxNetDHCP
|
---|
851 | }
|
---|
852 |
|
---|
853 |
|
---|
854 | # postinstall()
|
---|
855 | # !! failure is always fatal
|
---|
856 | postinstall()
|
---|
857 | {
|
---|
858 | infoprint "Detected Solaris $HOST_OS_MAJORVERSION Version $HOST_OS_MINORVERSION"
|
---|
859 | infoprint "Loading VirtualBox kernel modules..."
|
---|
860 | install_drivers
|
---|
861 |
|
---|
862 | if test "$?" -eq 0; then
|
---|
863 | if test -f "$DIR_CONF/vboxnet.conf"; then
|
---|
864 | # nwam/dhcpagent fix
|
---|
865 | nwamfile="$PKG_INSTALL_ROOT/etc/nwam/llp"
|
---|
866 | nwambackupfile=$nwamfile.vbox
|
---|
867 | if test -f "$nwamfile"; then
|
---|
868 | sed -e '/vboxnet/d' $nwamfile > $nwambackupfile
|
---|
869 |
|
---|
870 | # add all vboxnet instances as static to nwam
|
---|
871 | inst=0
|
---|
872 | networkn=56
|
---|
873 | while test $inst -ne 1; do
|
---|
874 | echo "vboxnet$inst static 192.168.$networkn.1" >> $nwambackupfile
|
---|
875 | inst=`expr $inst + 1`
|
---|
876 | networkn=`expr $networkn + 1`
|
---|
877 | done
|
---|
878 | mv -f $nwambackupfile $nwamfile
|
---|
879 | fi
|
---|
880 |
|
---|
881 | # plumb and configure vboxnet0 for non-remote installs
|
---|
882 | if test "$REMOTEINST" -eq 0; then
|
---|
883 | # S11 175a renames vboxnet0 as 'netX', undo this and rename it back
|
---|
884 | if test "$HOST_OS_MAJORVERSION" = "5.11" && test "$HOST_OS_MINORVERSION" -gt 174; then
|
---|
885 | vanityname=`dladm show-phys -po link,device | grep vboxnet0 | cut -f1 -d':'`
|
---|
886 | if test $? -eq 0 && test ! -z "$vanityname" && test "$vanityname" != "vboxnet0"; then
|
---|
887 | dladm rename-link "$vanityname" vboxnet0
|
---|
888 | if test $? -ne 0; then
|
---|
889 | errorprint "Failed to rename vanity interface ($vanityname) to vboxnet0"
|
---|
890 | fi
|
---|
891 | fi
|
---|
892 | fi
|
---|
893 |
|
---|
894 | $BIN_IFCONFIG vboxnet0 plumb
|
---|
895 | $BIN_IFCONFIG vboxnet0 up
|
---|
896 | if test "$?" -eq 0; then
|
---|
897 | $BIN_IFCONFIG vboxnet0 192.168.56.1 netmask 255.255.255.0 up
|
---|
898 |
|
---|
899 | # /etc/netmasks is a symlink, older installers replaced this with
|
---|
900 | # a copy of the actual file, repair that behaviour here.
|
---|
901 | recreatelink=0
|
---|
902 | if test -h "$PKG_INSTALL_ROOT/etc/netmasks"; then
|
---|
903 | nmaskfile="$PKG_INSTALL_ROOT/etc/inet/netmasks"
|
---|
904 | else
|
---|
905 | nmaskfile="$PKG_INSTALL_ROOT/etc/netmasks"
|
---|
906 | recreatelink=1
|
---|
907 | fi
|
---|
908 |
|
---|
909 | # add the netmask to stay persistent across host reboots
|
---|
910 | nmaskbackupfile=$nmaskfile.vbox
|
---|
911 | if test -f $nmaskfile; then
|
---|
912 | sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
|
---|
913 |
|
---|
914 | if test $recreatelink -eq 1; then
|
---|
915 | # Check after removing our settings if /etc/netmasks is identifcal to /etc/inet/netmasks
|
---|
916 | anydiff=`diff $nmaskbackupfile "$PKG_INSTALL_ROOT/etc/inet/netmasks"`
|
---|
917 | if test ! -z "$anydiff"; then
|
---|
918 | # User may have some custom settings in /etc/netmasks, don't overwrite /etc/netmasks!
|
---|
919 | recreatelink=2
|
---|
920 | fi
|
---|
921 | fi
|
---|
922 |
|
---|
923 | echo "#VirtualBox_SectionStart" >> $nmaskbackupfile
|
---|
924 | inst=0
|
---|
925 | networkn=56
|
---|
926 | while test $inst -ne 1; do
|
---|
927 | echo "192.168.$networkn.0 255.255.255.0" >> $nmaskbackupfile
|
---|
928 | inst=`expr $inst + 1`
|
---|
929 | networkn=`expr $networkn + 1`
|
---|
930 | done
|
---|
931 | echo "#VirtualBox_SectionEnd" >> $nmaskbackupfile
|
---|
932 | mv -f $nmaskbackupfile $nmaskfile
|
---|
933 |
|
---|
934 | # Recreate /etc/netmasks as a link if necessary
|
---|
935 | if test $recreatelink -eq 1; then
|
---|
936 | cp -f "$PKG_INSTALL_ROOT/etc/netmasks" "$PKG_INSTALL_ROOT/etc/inet/netmasks"
|
---|
937 | ln -sf ./inet/netmasks "$PKG_INSTALL_ROOT/etc/netmasks"
|
---|
938 | elif test $recreatelink -eq 2; then
|
---|
939 | warnprint "/etc/netmasks is a symlink (to /etc/inet/netmasks) that older"
|
---|
940 | warnprint "VirtualBox installers incorrectly overwrote. Now the contents"
|
---|
941 | warnprint "of /etc/netmasks and /etc/inet/netmasks differ, therefore "
|
---|
942 | warnprint "VirtualBox will not attempt to overwrite /etc/netmasks as a"
|
---|
943 | warnprint "symlink to /etc/inet/netmasks. Please resolve this manually"
|
---|
944 | warnprint "by updating /etc/inet/netmasks and creating /etc/netmasks as a"
|
---|
945 | warnprint "symlink to /etc/inet/netmasks"
|
---|
946 | fi
|
---|
947 | fi
|
---|
948 | else
|
---|
949 | # Should this be fatal?
|
---|
950 | warnprint "Failed to bring up vboxnet0!!"
|
---|
951 | fi
|
---|
952 | fi
|
---|
953 | fi
|
---|
954 |
|
---|
955 | if test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-webservice.xml" || test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml"; then
|
---|
956 | infoprint "Configuring services..."
|
---|
957 | if test "$REMOTEINST" -eq 1; then
|
---|
958 | subprint "Skipped for targetted installs."
|
---|
959 | else
|
---|
960 | # Enable Zone access service for non-remote installs, other services (Webservice) are delivered disabled by the manifest class action
|
---|
961 | servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" | grep "disabled" 2>/dev/null`
|
---|
962 | if test ! -z "$servicefound"; then
|
---|
963 | $BIN_SVCADM enable -s svc:/application/virtualbox/zoneaccess
|
---|
964 | if test "$?" -eq 0; then
|
---|
965 | subprint "Loaded: Zone access service"
|
---|
966 | else
|
---|
967 | subprint "Loading Zone access service ...FAILED."
|
---|
968 | fi
|
---|
969 | fi
|
---|
970 | fi
|
---|
971 | fi
|
---|
972 |
|
---|
973 | # Update mime and desktop databases to get the right menu entries
|
---|
974 | # and icons. There is still some delay until the GUI picks it up,
|
---|
975 | # but that cannot be helped.
|
---|
976 | if test -d "$PKG_INSTALL_ROOT/usr/share/icons"; then
|
---|
977 | infoprint "Installing MIME types and icons..."
|
---|
978 | if test "$REMOTEINST" -eq 0; then
|
---|
979 | /usr/bin/update-mime-database /usr/share/mime >/dev/null 2>&1
|
---|
980 | /usr/bin/update-desktop-database -q 2>/dev/null
|
---|
981 | else
|
---|
982 | subprint "Skipped for targetted installs."
|
---|
983 | fi
|
---|
984 | fi
|
---|
985 |
|
---|
986 | # Install python bindings for non-remote installs
|
---|
987 | if test "$REMOTEINST" -eq 0; then
|
---|
988 | if test -f "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py" || test -h "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py"; then
|
---|
989 | PYTHONBIN=`which python 2> /dev/null`
|
---|
990 | if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
|
---|
991 | infoprint "Installing Python bindings..."
|
---|
992 |
|
---|
993 | INSTALLEDIT=1
|
---|
994 | PYTHONBIN=`which python2.4 2>/dev/null`
|
---|
995 | install_python_bindings "$PYTHONBIN" "Python 2.4"
|
---|
996 | if test "$?" -eq 0; then
|
---|
997 | INSTALLEDIT=0
|
---|
998 | fi
|
---|
999 | PYTHONBIN=`which python2.5 2>/dev/null`
|
---|
1000 | install_python_bindings "$PYTHONBIN" "Python 2.5"
|
---|
1001 | if test "$?" -eq 0; then
|
---|
1002 | INSTALLEDIT=0
|
---|
1003 | fi
|
---|
1004 | PYTHONBIN=`which python2.6 2>/dev/null`
|
---|
1005 | install_python_bindings "$PYTHONBIN" "Python 2.6"
|
---|
1006 | if test "$?" -eq 0; then
|
---|
1007 | INSTALLEDIT=0
|
---|
1008 | fi
|
---|
1009 |
|
---|
1010 | # remove files installed by Python build
|
---|
1011 | rm -rf $DIR_VBOXBASE/sdk/installer/build
|
---|
1012 |
|
---|
1013 | if test "$INSTALLEDIT" -ne 0; then
|
---|
1014 | warnprint "No suitable Python version found. Required Python 2.4, 2.5 or 2.6."
|
---|
1015 | warnprint "Skipped installing the Python bindings."
|
---|
1016 | fi
|
---|
1017 | else
|
---|
1018 | warnprint "Python not found, skipped installed Python bindings."
|
---|
1019 | fi
|
---|
1020 | fi
|
---|
1021 | else
|
---|
1022 | warnprint "Skipped installing Python bindings. Run, as root, 'vboxapisetup.py install' manually from the booted system."
|
---|
1023 | fi
|
---|
1024 |
|
---|
1025 | update_boot_archive
|
---|
1026 |
|
---|
1027 | return 0
|
---|
1028 | else
|
---|
1029 | errorprint "Failed to install drivers"
|
---|
1030 | exit 666
|
---|
1031 | fi
|
---|
1032 | return 1
|
---|
1033 | }
|
---|
1034 |
|
---|
1035 | # preremove([fatal])
|
---|
1036 | # failure: depends on [fatal]
|
---|
1037 | preremove()
|
---|
1038 | {
|
---|
1039 | fatal=$1
|
---|
1040 |
|
---|
1041 | cleanup_install "$fatal"
|
---|
1042 |
|
---|
1043 | remove_drivers "$fatal"
|
---|
1044 | if test "$?" -eq 0; then
|
---|
1045 | return 0;
|
---|
1046 | fi
|
---|
1047 | return 1
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 |
|
---|
1051 | # And it begins...
|
---|
1052 | if test "x${PKG_INSTALL_ROOT:=/}" != "x/"; then
|
---|
1053 | BASEDIR_OPT="-b $PKG_INSTALL_ROOT"
|
---|
1054 | BASEDIR_PKGOPT="-R $PKG_INSTALL_ROOT"
|
---|
1055 | REMOTEINST=1
|
---|
1056 | fi
|
---|
1057 | find_bins
|
---|
1058 | check_root
|
---|
1059 | check_isa
|
---|
1060 | check_zone
|
---|
1061 | get_sysinfo
|
---|
1062 |
|
---|
1063 |
|
---|
1064 | # Get command line options
|
---|
1065 | while test $# -gt 0;
|
---|
1066 | do
|
---|
1067 | case "$1" in
|
---|
1068 | --postinstall | --preremove | --installdrivers | --removedrivers | --setupdrivers)
|
---|
1069 | drvop="$1"
|
---|
1070 | ;;
|
---|
1071 | --fatal)
|
---|
1072 | fatal="$FATALOP"
|
---|
1073 | ;;
|
---|
1074 | --silent)
|
---|
1075 | ISSILENT="$SILENTOP"
|
---|
1076 | ;;
|
---|
1077 | --ips)
|
---|
1078 | ISIPS="$IPSOP"
|
---|
1079 | ;;
|
---|
1080 | --altkerndir)
|
---|
1081 | # Use alternate kernel driver config folder (dev only)
|
---|
1082 | DIR_CONF="/usr/kernel/drv"
|
---|
1083 | ;;
|
---|
1084 | --help)
|
---|
1085 | printusage
|
---|
1086 | exit 1
|
---|
1087 | ;;
|
---|
1088 | *)
|
---|
1089 | break
|
---|
1090 | ;;
|
---|
1091 | esac
|
---|
1092 | shift
|
---|
1093 | done
|
---|
1094 |
|
---|
1095 | case "$drvop" in
|
---|
1096 | --postinstall)
|
---|
1097 | check_module_arch
|
---|
1098 | postinstall
|
---|
1099 | ;;
|
---|
1100 | --preremove)
|
---|
1101 | preremove "$fatal"
|
---|
1102 | ;;
|
---|
1103 | --installdrivers)
|
---|
1104 | check_module_arch
|
---|
1105 | install_drivers
|
---|
1106 | ;;
|
---|
1107 | --removedrivers)
|
---|
1108 | remove_drivers "$fatal"
|
---|
1109 | ;;
|
---|
1110 | --setupdrivers)
|
---|
1111 | remove_drivers "$fatal"
|
---|
1112 | infoprint "Installing VirtualBox drivers:"
|
---|
1113 | install_drivers
|
---|
1114 | ;;
|
---|
1115 | *)
|
---|
1116 | printusage
|
---|
1117 | exit 1
|
---|
1118 | esac
|
---|
1119 |
|
---|
1120 | exit "$?"
|
---|
1121 |
|
---|