VirtualBoxStartup.sh revision 66ab05d147fcb24a5fec1cd3c37a1799db26c804
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#!/bin/sh
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# $Id$
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync## @file
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# Startup service for loading the kernel extensions and select the set of VBox
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# binaries that matches the kernel architecture.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# Copyright (C) 2007-2013 Oracle Corporation
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# available from http://www.virtualbox.org. This file is free software;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# you can redistribute it and/or modify it under the terms of the GNU
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# General Public License (GPL) as published by the Free Software
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncif false; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync . /etc/rc.common
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncelse
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync # Fake the startup item functions we're using.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage()
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync {
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if [ "$1" != "-f" ]; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync echo "$@"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync else
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync shift
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync echo "Fatal error: $@"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync exit 1;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync }
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RunService()
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync {
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync case "$1" in
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync "start")
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync StartService
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync exit $?;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ;;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync "stop")
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync StopService
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync exit $?;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ;;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync "restart")
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RestartService
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync exit $?;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ;;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync "launchd")
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if RestartService; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync while true;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync do
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync sleep 3600
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync done
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync exit $?;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ;;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync **)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync echo "Error: Unknown action '$1'"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync exit 1;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync esac
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync }
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncfi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncStartService()
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync{
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=0
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOXDRV="VBoxDrv"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOXUSB="VBoxUSB"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync #
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync # Switch the binaries to the right architecture.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync #
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_ARCH=`uname -m`
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if test "$VBOX_ARCH" = "x86_64"; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_ARCH="amd64"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync else
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_ARCH="x86"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync for VBOX_TRG in `ls /Applications/VirtualBox.app/Contents/MacOS/*-${VBOX_ARCH}`;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync do
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_LINKNAME=`echo "$VBOX_TRG" | sed -e 's|-'"${VBOX_ARCH}"'$||' `
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if test "$VBOX_LINKNAME" != "$VBOX_TRG"; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync rm -f "$VBOX_LINKNAME"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if ! ln -vh "$VBOX_TRG" "$VBOX_LINKNAME"; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: ln -vh $VBOX_TRG $VBOX_LINKNAME failed"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync else
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: Script error VBOX_TRG=$VBOX_TRG"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync done
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync #
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync # Check that all the directories exist first.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync #
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if [ ! -d "/Library/Application Support/VirtualBox/${VBOXDRV}.kext" ]; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: /Library/Application Support/VirtualBox/${VBOXDRV}.kext is missing"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if [ ! -d "/Library/Application Support/VirtualBox/${VBOXUSB}.kext" ]; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: /Library/Application Support/VirtualBox/${VBOXUSB}.kext is missing"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if [ ! -d "/Library/Application Support/VirtualBox/VBoxNetFlt.kext" ]; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: /Library/Application Support/VirtualBox/VBoxNetFlt.kext is missing"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if [ ! -d "/Library/Application Support/VirtualBox/VBoxNetAdp.kext" ]; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: /Library/Application Support/VirtualBox/VBoxNetAdp.kext is missing"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync #
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync # Check that no drivers are currently running.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync # (Try stop the service if this is the case.)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync #
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if [ $VBOX_RC -eq 0 ]; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if kextstat -lb org.virtualbox.kext.VBoxDrv 2>&1 | grep -q org.virtualbox.kext.VBoxDrv; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: ${VBOXDRV}.kext is already loaded"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if kextstat -lb org.virtualbox.kext.VBoxUSB 2>&1 | grep -q org.virtualbox.kext.VBoxUSB; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: ${VBOXUSB}.kext is already loaded"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if kextstat -lb org.virtualbox.kext.VBoxNetFlt 2>&1 | grep -q org.virtualbox.kext.VBoxNetFlt; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: VBoxNetFlt.kext is already loaded"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if kextstat -lb org.virtualbox.kext.VBoxNetAdp 2>&1 | grep -q org.virtualbox.kext.VBoxNetAdp; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: VBoxNetAdp.kext is already loaded"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync #
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync # Load the drivers.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync #
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if [ $VBOX_RC -eq 0 ]; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Loading ${VBOXDRV}.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if ! kextload "/Library/Application Support/VirtualBox/${VBOXDRV}.kext"; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: Failed to load /Library/Application Support/VirtualBox/${VBOXDRV}.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Loading ${VBOXUSB}.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if ! kextload -d "/Library/Application Support/VirtualBox/${VBOXDRV}.kext" "/Library/Application Support/VirtualBox/${VBOXUSB}.kext"; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: Failed to load /Library/Application Support/VirtualBox/${VBOXUSB}.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Loading VBoxNetFlt.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if ! kextload -d "/Library/Application Support/VirtualBox/${VBOXDRV}.kext" "/Library/Application Support/VirtualBox/VBoxNetFlt.kext"; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: Failed to load /Library/Application Support/VirtualBox/VBoxNetFlt.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Loading VBoxNetAdp.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if ! kextload -d "/Library/Application Support/VirtualBox/${VBOXDRV}.kext" "/Library/Application Support/VirtualBox/VBoxNetAdp.kext"; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: Failed to load /Library/Application Support/VirtualBox/VBoxNetAdp.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if [ $VBOX_RC -ne 0 ]; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync # unload the drivers (ignoring failures)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync kextunload -b org.virtualbox.kext.VBoxNetAdp
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync kextunload -b org.virtualbox.kext.VBoxNetFlt
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync kextunload -b org.virtualbox.kext.VBoxUSB
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync kextunload -b org.virtualbox.kext.VBoxDrv
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync #
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync # Set the error on failure.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync #
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if [ "$VBOX_RC" -ne "0" ]; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage -f VirtualBox
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync exit $VBOX_RC
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync}
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncStopService()
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync{
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=0
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOXDRV="VBoxDrv"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOXUSB="VBoxUSB"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if kextstat -lb org.virtualbox.kext.VBoxUSB 2>&1 | grep -q org.virtualbox.kext.VBoxUSB; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Unloading ${VBOXUSB}.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if ! kextunload -m org.virtualbox.kext.VBoxUSB; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: Failed to unload VBoxUSB.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if kextstat -lb org.virtualbox.kext.VBoxNetFlt 2>&1 | grep -q org.virtualbox.kext.VBoxNetFlt; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Unloading VBoxNetFlt.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if ! kextunload -m org.virtualbox.kext.VBoxNetFlt; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: Failed to unload VBoxNetFlt.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if kextstat -lb org.virtualbox.kext.VBoxNetAdp 2>&1 | grep -q org.virtualbox.kext.VBoxNetAdp; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Unloading VBoxNetAdp.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if ! kextunload -m org.virtualbox.kext.VBoxNetAdp; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: Failed to unload VBoxNetAdp.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync # This must come last because of dependencies.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if kextstat -lb org.virtualbox.kext.VBoxDrv 2>&1 | grep -q org.virtualbox.kext.VBoxDrv; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Unloading ${VBOXDRV}.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if ! kextunload -m org.virtualbox.kext.VBoxDrv; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage "Error: Failed to unload VBoxDrv.kext"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync VBOX_RC=1
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync # Set the error on failure.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if [ "$VBOX_RC" -ne "0" ]; then
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync ConsoleMessage -f VirtualBox
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync exit $VBOX_RC
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync fi
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync}
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncRestartService()
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync{
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync StopService
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync StartService
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync}
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncRunService "$1"
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync