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