#!/bin/bash

# VirtualBox is installed in /opt/virtualbox
cd /opt/virtualbox

# Is vboxdrv module loaded?
if lsmod | grep vboxdrv > /dev/null
then
	echo OK, vboxdrv is loaded.
else
	echo vboxdrv module is not loaded, trying to load it ...
	modprobe vboxdrv
	echo OK, vboxdrv is loaded.
fi

# Is VBoxSVC running?
if ps -e | grep VBoxSVC > /dev/null
then 
	echo OK, VBoxSVC is running.
else
	echo VBoxSVC is not running, tryng to start VBoxSVC ...
	LD_LIBRARY_PATH=. ./VBoxSVC&
	echo OK, VBoxSVC is running.
fi

echo OK, VirtualBox is starting ...
LD_LIBRARY_PATH=. ./VirtualBox
