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