summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app-emulation/virtualbox-bin/files/virtualbox-bin-wrapper')
-rw-r--r--app-emulation/virtualbox-bin/files/virtualbox-bin-wrapper66
1 files changed, 66 insertions, 0 deletions
diff --git a/app-emulation/virtualbox-bin/files/virtualbox-bin-wrapper b/app-emulation/virtualbox-bin/files/virtualbox-bin-wrapper
new file mode 100644
index 0000000..79c4e3d
--- /dev/null
+++ b/app-emulation/virtualbox-bin/files/virtualbox-bin-wrapper
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+INSTALL_DIR=/opt/VirtualBox
+USER=$( whoami )
+
+SERVER_PID=$( ps -U $USER | grep VBoxSVC | awk '{ print $1 }' )
+
+if [ "$1" = shutdown ]; then
+ if [ "$SERVER_PID" != "" ]; then
+ kill -TERM $SERVER_PID
+ sleep 2
+ fi
+ exit 0
+fi
+
+[ "$VBOX_USER_HOME" = "" ] && VBOX_USER_HOME="$HOME/.VirtualBox"
+
+mkdir -p "$VBOX_USER_HOME"
+LOG="$VBOX_USER_HOME/VBoxSVC.log"
+
+if [[ -e /proc/modules && ! -e /dev/vboxdrv ]] ; then
+ echo "Error: vboxdrv kernel module is not loaded..."
+ echo "Please load the module before starting VirtualBox."
+ exit 1
+elif [ ! -w /dev/vboxdrv ]; then
+ if [ "`id | grep vboxusers`" = "" ]; then
+ echo "Error: You are not a member of the \"vboxusers\" group..."
+ echo "Please add yourself to this group before starting VirtualBox."
+ else
+ echo "Error: /dev/vboxdrv is not writable for some reason..."
+ echo "If you recently added the current user to the vboxusers group,"
+ echo "then you have to logout and re-login to take the change effect."
+ fi
+ exit 1
+fi
+
+export LD_LIBRARY_PATH="$INSTALL_DIR"
+
+if [ "$SERVER_PID" = "" ]; then
+ rm -rf /tmp/.vbox-$USER-ipc
+ [ -f "$LOG.1" ] && mv "$LOG.1" "$LOG.2"
+ [ -f "$LOG.0" ] && mv "$LOG.0" "$LOG.1"
+ [ -f "$LOG" ] && mv "$LOG" "$LOG.0"
+ /opt/VirtualBox/VBoxSVC --daemonize >"$LOG" 2>&1
+fi
+
+APP=$( which $0 )
+APP=${APP##/*/}
+case "$APP" in
+ virtualbox)
+ exec "$INSTALL_DIR/VirtualBox" "$@"
+ ;;
+ vboxmanage)
+ exec "$INSTALL_DIR/VBoxManage" "$@"
+ ;;
+ vboxsdl)
+ exec "$INSTALL_DIR/VBoxSDL" "$@"
+ ;;
+ vboxvrdp)
+ exec "$INSTALL_DIR/VBoxVRDP" "$@"
+ ;;
+ *)
+ echo "Error: Unknown application - $APP"
+ exit 1
+ ;;
+esac