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