virtualbox-ose-5-wrapper 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/bin/sh
  2. ## @file
  3. # Oracle VM VirtualBox startup script, Linux hosts.
  4. #
  5. #
  6. # Copyright (C) 2006-2015 Oracle Corporation
  7. #
  8. # This file is part of VirtualBox Open Source Edition (OSE), as
  9. # available from http://www.virtualbox.org. This file is free software;
  10. # you can redistribute it and/or modify it under the terms of the GNU
  11. # General Public License (GPL) as published by the Free Software
  12. # Foundation, in version 2 as it comes in the "COPYING" file of the
  13. # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
  14. # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
  15. #
  16. PATH="/usr/bin:/bin:/usr/sbin:/sbin"
  17. CONFIG="/etc/vbox/vbox.cfg"
  18. test -r "${CONFIG}" &&
  19. . "${CONFIG}"
  20. test -z "${INSTALL_DIR}" &&
  21. if test -f /usr/lib/virtualbox/VirtualBox &&
  22. test -x /usr/lib/virtualbox/VirtualBox; then
  23. INSTALL_DIR=/usr/lib/virtualbox
  24. else
  25. echo "Could not find VirtualBox installation. Please reinstall."
  26. exit 1
  27. fi
  28. # Note: This script must not fail if the module was not successfully installed
  29. # because the user might not want to run a VM but only change VM params!
  30. if [ "$1" = "shutdown" ]; then
  31. SHUTDOWN="true"
  32. elif ! lsmod|grep -q vboxdrv; then
  33. cat << EOF
  34. WARNING: The vboxdrv kernel module is not loaded. Either there is no module
  35. available for the current kernel (`uname -r`) or it failed to
  36. load. Please recompile the kernel module and install it by
  37. for m in vbox{drv,netadp,netflt}; do modprobe \$m; done
  38. You will not be able to start VMs until this problem is fixed.
  39. EOF
  40. elif [ ! -c /dev/vboxdrv ]; then
  41. cat << EOF
  42. WARNING: The character device /dev/vboxdrv does not exist.
  43. Please try to reload all the needed kernel modules by:
  44. for m in vbox{netflt,netadp,drv}; do rmmod \$m; done
  45. for m in vbox{drv,netadp,netflt}; do modprobe \$m; done
  46. and if that is not successful, try to re-install the package by:
  47. emerge -1av app-emulation/virtualbox-modules
  48. You will not be able to start VMs until this problem is fixed.
  49. EOF
  50. fi
  51. SERVER_PID=`ps -U \`whoami\` | grep VBoxSVC | awk '{ print $1 }'`
  52. if [ -z "$SERVER_PID" ]; then
  53. # Server not running yet/anymore, cleanup socket path.
  54. # See IPC_GetDefaultSocketPath()!
  55. if [ -n "$LOGNAME" ]; then
  56. rm -rf /tmp/.vbox-$LOGNAME-ipc > /dev/null 2>&1
  57. else
  58. rm -rf /tmp/.vbox-$USER-ipc > /dev/null 2>&1
  59. fi
  60. fi
  61. if [ "$SHUTDOWN" = "true" ]; then
  62. if [ -n "$SERVER_PID" ]; then
  63. kill -TERM $SERVER_PID
  64. sleep 2
  65. fi
  66. exit 0
  67. fi
  68. APP=`basename $0`
  69. case "$APP" in
  70. VirtualBox|virtualbox)
  71. exec "$INSTALL_DIR/VirtualBox" "$@"
  72. ;;
  73. VBoxManage|vboxmanage)
  74. exec "$INSTALL_DIR/VBoxManage" "$@"
  75. ;;
  76. VBoxSDL|vboxsdl)
  77. exec "$INSTALL_DIR/VBoxSDL" "$@"
  78. ;;
  79. VBoxVRDP|VBoxHeadless|vboxheadless)
  80. exec "$INSTALL_DIR/VBoxHeadless" "$@"
  81. ;;
  82. VBoxAutostart|vboxautostart)
  83. exec "$INSTALL_DIR/VBoxAutostart" "$@"
  84. ;;
  85. VBoxBalloonCtrl|vboxballoonctrl)
  86. exec "$INSTALL_DIR/VBoxBalloonCtrl" "$@"
  87. ;;
  88. VBoxDTrace|vboxdtrace)
  89. exec "$INSTALL_DIR/VBoxDTrace" "$@"
  90. ;;
  91. vboxwebsrv)
  92. exec "$INSTALL_DIR/vboxwebsrv" "$@"
  93. ;;
  94. *)
  95. echo "Unknown application - $APP"
  96. exit 1
  97. ;;
  98. esac
  99. exit 0