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