Skip to content

Instantly share code, notes, and snippets.

@darkman66
Created January 24, 2017 17:44
Show Gist options
  • Save darkman66/2075a68e5232d0850bdb266213537906 to your computer and use it in GitHub Desktop.
Save darkman66/2075a68e5232d0850bdb266213537906 to your computer and use it in GitHub Desktop.
#!/bin/bash
function status() {
kextstat | grep org.virtualbox.kext > /dev/null 2>&1 ;
vbox=$((1-$?))
kextstat | grep com.github.osxfuse > /dev/null 2>&1 ;
fuse=$((1-$?))
}
status
if [ "$1" == "vbox" ] ; then
if [ $vbox == 1 ] ; then
echo "Already vbox"
else
sudo kextunload -b com.github.osxfuse.filesystems.osxfuse
sudo kextutil "/Library/Application Support/VirtualBox/VBoxDrv.kext" -r "/Library/Application Support/VirtualBox"
sudo kextutil "/Library/Application Support/VirtualBox/VBoxNetAdp.kext" -r "/Library/Application Support/VirtualBox"
sudo kextutil "/Library/Application Support/VirtualBox/VBoxNetFlt.kext" -r "/Library/Application Support/VirtualBox"
sudo kextutil "/Library/Application Support/VirtualBox/VBoxUSB.kext" -r "/Library/Application Support/VirtualBox"
fi
elif [ "$1" == "fuse" ] ; then
if [ $fuse == 1 ] ; then
echo "Already fuse"
else
sudo kextunload -b org.virtualbox.kext.VBoxUSB -b org.virtualbox.kext.VBoxNetFlt -b org.virtualbox.kext.VBoxNetAdp
sudo kextunload -b org.virtualbox.kext.VBoxDrv
sudo kextutil /Library/Filesystems/osxfuse.fs/Contents/Extensions/10.12/osxfuse.kext
fi
elif [ "$1" == "status" ] ; then
echo "vbox = $vbox"
echo "fuse = $fuse"
else
echo "Run $0 <vbox|fuse|status>"
fi
@bdurrow
Copy link

bdurrow commented Apr 6, 2019

I made a small modification to this script to allow more intelligently choose a path to osxfuse.kext when not running on macOS 10.12:

-        sudo kextutil /Library/Filesystems/osxfuse.fs/Contents/Extensions/10.12/osxfuse.kext
+        sudo kextutil /Library/Filesystems/osxfuse.fs/Contents/Extensions/$(sw_vers | sed -nE 's/^ProductVersion:.*(\1\0\.[0-9]*)\..*/\1/p')/osxfuse.kext

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment