Changeset 22080 in vbox for trunk/src/VBox/Installer
- Timestamp:
- Aug 7, 2009 4:44:38 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/solaris/vboxconfig.sh
r22067 r22080 21 21 22 22 23 # Never use exit 2 or exit 20 etc., the return codes are used in 24 # SRv4 postinstall procedures which carry special meaning. Just use exit 1 for failure. 25 set -x 26 23 27 HOST_OS_VERSION=`uname -r` 24 28 … … 40 44 # "vboxdrv" is also used in sed lines here (change those as well if it ever changes) 41 45 MOD_VBOXDRV=vboxdrv 46 DESC_VBOXDRV="VirtualBox HostDriver" 47 42 48 MOD_VBOXNET=vboxnet 49 DESC_VBOXNET="VirtualBox NetAdapter" 50 43 51 MOD_VBOXFLT=vboxflt 52 DESC_VBOXFLT="VirtualBox NetFilter" 53 44 54 MOD_VBI=vbi 55 DESC_VBI="VirtualBox Kernel Interface" 56 45 57 MOD_VBOXUSBMON=vboxusbmon 58 DESC_VBOXUSBMON="VirtualBox USBMonitor" 59 46 60 FATALOP=fatal 47 61 SILENTOP=silent 62 ISSILENT= 48 63 49 64 infoprint() 50 65 { 51 echo 1>&2 "$1" 66 if test "$ISSILENT" != "$SILENTOP"; then 67 echo 1>&2 "$1" 68 fi 52 69 } 53 70 54 71 warnprint() 55 72 { 56 echo 1>&2 "* Warning!! $1" 73 if test "$ISSILENT" != "$SILENTOP"; then 74 echo 1>&2 "* Warning!! $1" 75 fi 57 76 } 58 77 59 78 success() 60 79 { 61 echo 1>&2 "$1" 80 if test "$ISSILENT" != "$SILENTOP"; then 81 echo 1>&2 "$1" 82 fi 62 83 } 63 84 … … 74 95 if test -z "$1"; then 75 96 errorprint "missing argument to check_bin_path()" 76 exit 5097 exit 1 77 98 fi 78 99 79 100 if test ! -x "$1"; then 80 101 errorprint "$1 missing or is not an executable" 81 exit 51102 exit 1 82 103 fi 83 104 return 0 … … 122 143 if test `$idbin -u` -ne 0; then 123 144 errorprint "This script must be run with administrator privileges." 124 exit 2145 exit 1 125 146 fi 126 147 } … … 133 154 if test "$currentzone" != "global"; then 134 155 errorprint "This script must be run from the global zone." 135 exit 3156 exit 1 136 157 fi 137 158 } … … 144 165 if test "$currentisa" = "i86xpv"; then 145 166 errorprint "VirtualBox cannot run under xVM Dom0! Fatal Error, Aborting installation!" 146 exit 4167 exit 1 147 168 fi 148 169 } … … 158 179 elif test "$cputype" != "i386"; then 159 180 errorprint "VirtualBox works only on i386/amd64 architectures, not $cputype" 160 exit 98181 exit 1 161 182 fi 162 183 … … 172 193 if test -f "$modulepath"; then 173 194 errorprint "Found 32-bit module instead of 64-bit. Please install the amd64 package!" 174 exit 97195 exit 1 175 196 fi 176 197 else … … 179 200 if test -f "$modulepath"; then 180 201 errorprint "Found 64-bit module instead of 32-bit. Please install the x86 package!" 181 exit 96202 exit 1 182 203 fi 183 204 fi … … 185 206 # Shouldn't really happen... 186 207 errorprint "VirtualBox Host kernel module NOT installed." 187 exit 99208 exit 1 188 209 } 189 210 … … 194 215 if test -z "$1"; then 195 216 errorprint "missing argument to module_added()" 196 exit 5217 exit 1 197 218 fi 198 219 199 220 loadentry=`cat /etc/name_to_major | grep $1` 200 221 if test -z "$loadentry"; then 201 return 0202 fi 203 return 1222 return 1 223 fi 224 return 0 204 225 } 205 226 … … 210 231 if test -z "$1"; then 211 232 errorprint "missing argument to module_loaded()" 212 exit 6233 exit 1 213 234 fi 214 235 … … 217 238 loadentry=`$BIN_MODINFO | grep $modname` 218 239 if test -z "$loadentry"; then 219 return 0220 fi 221 return 1222 } 223 224 # add_driver(modname, [driverperm], [fatal])240 return 1 241 fi 242 return 0 243 } 244 245 # add_driver(modname, moddesc, [driverperm], [fatal]) 225 246 # failure: depends on [fatal] 226 247 add_driver() 227 248 { 228 if test -z "$1" ; then249 if test -z "$1" || test -z "$2"; then 229 250 errorprint "missing argument to add_driver()" 230 exit 7 231 fi 232 233 modname=$1 234 modperm=$2 235 fatal=$3 251 exit 1 252 fi 253 254 modname="$1" 255 moddesc="$2" 256 modperm="$3" 257 if test "$3" = "$FATALOP"; then 258 fatal="$FATALOP" 259 modperm="" 260 fi 261 if test "$4" = "$FATALOP"; then 262 fatal="$FATALOP" 263 fi 264 236 265 if test -n "$modperm"; then 237 $BIN_ADDDRV -m '$modperm'$modname266 $BIN_ADDDRV -m"$modperm" $modname 238 267 else 239 268 $BIN_ADDDRV $modname … … 241 270 242 271 if test $? -ne 0; then 243 errorprint " Failed to load: $modname"272 errorprint "Adding: $moddesc module ...FAILED!" 244 273 if test "$fatal" = "$FATALOP"; then 245 exit 8274 exit 1 246 275 fi 247 276 return 1 … … 250 279 } 251 280 252 # rem_driver(modname, [fatal])281 # rem_driver(modname, moddesc, [fatal]) 253 282 # failure: depends on [fatal] 254 283 rem_driver() 255 284 { 256 if test -z "$1" ; then285 if test -z "$1" || test -z "$2"; then 257 286 errorprint "missing argument to rem_driver()" 258 exit 9287 exit 1 259 288 fi 260 289 261 290 modname=$1 262 fatal=$2 291 moddesc=$2 292 fatal=$3 263 293 module_added $modname 264 294 if test "$?" -eq 0; then 265 295 $BIN_REMDRV $modname 266 296 if test $? -eq 0; then 267 success "Removed: $modname successfully"297 success "Removed: $moddesc module" 268 298 return 0 269 299 else 270 errorprint " Failed to remove: $modname"300 errorprint "Removing: $moddesc ...FAILED!" 271 301 if test "$fatal" = "$FATALOP"; then 272 exit 1 0302 exit 1 273 303 fi 274 304 return 1 … … 277 307 } 278 308 279 # unload_module(modname, [fatal])309 # unload_module(modname, moddesc, [fatal]) 280 310 # failure: fatal 281 311 unload_module() 282 312 { 283 if test -z "$1" ; then313 if test -z "$1" || test -z "$2"; then 284 314 errorprint "missing argument to unload_module()" 285 exit 1 1315 exit 1 286 316 fi 287 317 288 318 modname=$1 289 fatal=$2 319 moddesc=$2 320 fatal=$3 290 321 modid=`$BIN_MODINFO | grep $modname | cut -f 1 -d ' ' ` 291 322 if test -n "$modid"; then 292 323 $BIN_MODUNLOAD -i $modid 293 324 if test $? -eq 0; then 294 success "Unloaded: $modname successfully"325 success "Unloaded: $moddesc module" 295 326 else 296 errorprint " Failed to unload: $modname"327 errorprint "Unloading: $moddesc ...FAILED!" 297 328 if test "$fatal" = "$FATALOP"; then 298 exit 1 2329 exit 1 299 330 fi 300 331 return 1 … … 304 335 } 305 336 306 # load_module(modname )337 # load_module(modname, moddesc, [fatal]) 307 338 # pass "drv/modname" or "misc/vbi" etc. 308 339 # failure: fatal 309 340 load_module() 310 341 { 311 if test -z "$1" ; then342 if test -z "$1" || test -z "$2"; then 312 343 errorprint "missing argument to load_module()" 313 exit 1 4344 exit 1 314 345 fi 315 346 316 347 modname=$1 317 fatal=$2 348 moddesc=$2 349 fatal=$3 318 350 $BIN_MODLOAD -p $modname 319 351 if test $? -eq 0; then 320 success "Loaded: $modname successfully"352 success "Loaded: $moddesc module" 321 353 return 0 322 354 else 323 errorprint " Failed to load: $modname"355 errorprint "Loading: $modesc ...FAILED!" 324 356 if test "$fatal" = "$FATALOP"; then 325 exit 1 5357 exit 1 326 358 fi 327 359 return 1 … … 333 365 install_drivers() 334 366 { 335 infoprint "Loading Host Driver..." 336 add_driver $MOD_VBOXDRV "* 0600 root sys" fatal 337 load_module $MOD_VBOXDRV fatal 367 if test -n "_HARDENED_"; then 368 add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "'* 0600 root sys'" "$FATALOP" 369 else 370 add_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "'* 0666 root sys'" "$FATALOP" 371 fi 372 load_module "drv/$MOD_VBOXDRV" "$DESC_VBOXDRV" "$FATALOP" 338 373 339 374 # Add vboxdrv to devlink.tab … … 343 378 344 379 # Create the device link 345 /usr/sbin/devfsadm -i $MOD_VBOXDRV380 /usr/sbin/devfsadm -i "$MOD_VBOXDRV" 346 381 347 382 if test $? -eq 0; then 348 383 349 384 if test -f /platform/i86pc/kernel/drv/vboxnet.conf; then 350 infoprint "Loading NetAdapter..." 351 add_drv $MOD_VBOXNET fatal 352 load_module $MOD_VBOXNET fatal 385 add_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP" 386 load_module "drv/$MOD_VBOXNET" "$DESC_VBOXNET" "$FATALOP" 353 387 fi 354 388 355 389 if test -f /platform/i86pc/kernel/drv/vboxflt.conf; then 356 infoprint "Loading NetFilter..." 357 add_driver $MOD_VBOXFLT fatal 358 load_module $MOD_VBOXFLT fatal 390 add_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP" 391 load_module "drv/$MOD_VBOXFLT" "$DESC_VBOXFLT" "$FATALOP" 359 392 fi 360 393 361 394 if test -f /platform/i86pc/kernel/drv/vboxusbmon.conf && test "$HOST_OS_VERSION" != "5.10"; then 362 infoprint "Loading USBMonitor..." 363 add_driver $MOD_VBOXUSBMON fatal 364 load_module $MOD_VBOXUSBMON fatal 395 add_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP" 396 load_module "drv/$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$FATALOP" 365 397 366 398 # Add vboxusbmon to devlink.tab 367 399 sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox 368 400 echo "type=ddi_pseudo;name=vboxusbmon \D" >> /etc/devlink.vbox 401 mv -f /etc/devlink.vbox /etc/devlink.tab 369 402 370 403 # Create the device link 371 /usr/sbin/devfsadm -i $MOD_VBOXUSBMON404 /usr/sbin/devfsadm -i "$MOD_VBOXUSBMON" 372 405 if test $? -ne 0; then 373 406 errorprint "Failed to create device link for $MOD_VBOXUSBMON." 374 exit 1 6407 exit 1 375 408 fi 376 409 fi 377 410 else 378 411 errorprint "Failed to create device link for $MOD_VBOXDRV." 379 exit 1 7412 exit 1 380 413 fi 381 414 … … 387 420 remove_drivers() 388 421 { 389 $fatal=$1422 fatal=$1 390 423 # Remove vboxdrv from devlink.tab 391 sed -e '/name=vboxdrv/d' /etc/devlink.tab > /etc/devlink.vbox 392 mv -f /etc/devlink.vbox /etc/devlink.tab 424 devlinkfound=`cat /etc/devlink.tab | grep vboxdrv` 425 if test -n "$devlinkfound"; then 426 sed -e '/name=vboxdrv/d' /etc/devlink.tab > /etc/devlink.vbox 427 mv -f /etc/devlink.vbox /etc/devlink.tab 428 fi 393 429 394 430 # Remove vboxusbmon from devlink.tab 395 sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox 396 mv -f /etc/devlink.vbox /etc/devlink.tab 431 devlinkfound=`cat /etc/devlink.tab | grep vboxusbmon` 432 if test -n "$devlinkfound"; then 433 sed -e '/name=vboxusbmon/d' /etc/devlink.tab > /etc/devlink.vbox 434 mv -f /etc/devlink.vbox /etc/devlink.tab 435 fi 397 436 398 437 # USBMonitor might not even be installed, but anyway... 399 438 if test -f /platform/i86pc/kernel/drv/vboxusbmon.conf && test "$HOST_OS_VERSION" != "5.10"; then 400 infoprint "Unloading USBMonitor..." 401 unload_module $MOD_VBOXUSBMON "$fatal" 402 rem_driver $MOD_VBOXUSBMON "$fatal" 403 fi 404 405 infoprint "Unloading NetFilter..." 406 unload_module $MOD_VBOXFLT "$fatal" 407 rem_driver $MOD_VBOXFLT "$fatal" 408 409 infoprint "Unloading NetAdapter..." 410 unload_module $MOD_VBOXNET "$fatal" 411 rem_driver $MOD_VBOXNET "$fatal" 412 413 infoprint "Unloading Host Driver..." 414 unload_module $MOD_VBOXDRV "$fatal" 415 rem_driver $MOD_VBOXDRV "$fatal" 416 417 infoprint "Unloading VBI..." 418 unload_module $MOD_VBI "$fatal" 439 unload_module "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal" 440 rem_driver "$MOD_VBOXUSBMON" "$DESC_VBOXUSBMON" "$fatal" 441 fi 442 443 unload_module "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal" 444 rem_driver "$MOD_VBOXFLT" "$DESC_VBOXFLT" "$fatal" 445 446 unload_module "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal" 447 rem_driver "$MOD_VBOXNET" "$DESC_VBOXNET" "$fatal" 448 449 unload_module "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal" 450 rem_driver "$MOD_VBOXDRV" "$DESC_VBOXDRV" "$fatal" 451 452 unload_module "$MOD_VBI" "$DESC_VBI" "$fatal" 453 454 # remove devlinks 455 if test -h "/dev/vboxdrv" || test -f "/dev/vboxdrv"; then 456 rm -f /dev/vboxdrv 457 fi 458 if test -h "/dev/vboxusbmon" || test -f "/dev/vboxusbmon"; then 459 rm -f /dev/vboxusbmon 460 fi 419 461 420 462 return 0 … … 445 487 446 488 # stop and unregister webservice SMF 447 servicefound=`$BIN_SVCS -a | grep "virtualbox/webservice" `489 servicefound=`$BIN_SVCS -a | grep "virtualbox/webservice" 2>/dev/null` 448 490 if test ! -z "$servicefound"; then 449 491 $BIN_SVCADM disable -s svc:/application/virtualbox/webservice:default … … 452 494 453 495 # stop and unregister zoneaccess SMF 454 servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" `496 servicefound=`$BIN_SVCS -a | grep "virtualbox/zoneaccess" 2>/dev/null` 455 497 if test ! -z "$servicefound"; then 456 498 $BIN_SVCADM disable -s svc:/application/virtualbox/zoneaccess … … 465 507 errorprint "VirtualBox NetAdapter 'vboxnet0' couldn't be unplumbed (probably in use)." 466 508 if test "$fatal" = "$FATALOP"; then 467 exit 33509 exit 1 468 510 fi 469 511 fi … … 497 539 warnprint "Failed to bring up vboxnet0!!" 498 540 fi 541 fi 542 543 if test -f /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml || test -f /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml; then 544 infoprint "Configuring services..." 545 fi 546 547 # Web service 548 if test -f /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml; then 549 /usr/sbin/svccfg import /var/svc/manifest/application/virtualbox/virtualbox-webservice.xml 550 /usr/sbin/svcadm disable -s svc:/application/virtualbox/webservice:default 551 fi 552 553 # Zone access service 554 if test -f /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml; then 555 /usr/sbin/svccfg import /var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml 556 /usr/sbin/svcadm enable -s svc:/application/virtualbox/zoneaccess 499 557 fi 500 558 … … 552 610 fatal=$1 553 611 554 cleanup_install 612 cleanup_install "$fatal" 555 613 556 614 remove_drivers "$fatal" … … 570 628 571 629 drvop=$1 572 fatal=$2 630 if test "$2" = "$FATALOP" || test "$3" = "$FATALOP"; then 631 fatal=$FATALOP 632 fi 633 if test "$2" = "$SILENTOP" || test "$3" = "$SILENTOP"; then 634 ISSILENT=$SILENTOP 635 fi 636 573 637 case "$drvop" in 574 638 post_install) … … 588 652 *) 589 653 echo "Usage: $0 post_install|pre_remove|install_drivers|remove_drivers [fatal]" 590 exit 1 3654 exit 1 591 655 esac 592 656 593 if test "$?" -eq 0; then 594 exit 0 595 fi 596 597 exit 1 598 657 exit "$?" 658
Note:
See TracChangeset
for help on using the changeset viewer.