virtualbox-ose-3-wrapper 2.9 KB

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