Advertisement
adamchilcott

dstroot.sh

Mar 31st, 2018
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.01 KB | None | 0 0
  1. ########################################
  2. # brew cask reinstall --force virtualbox
  3. ########################################
  4.  
  5. #!/bin/bash
  6.  
  7. unload() {
  8.         if [ `ps -ef | grep -c VirtualBox$` -ne 0 ]
  9.         then
  10.                 echo "VirtualBox still seems to be running. Please investigate!!"
  11.                 exit 1;
  12.         elif [ `ps -ef | grep -c [V]ir` -gt 0 ]
  13.         then
  14.                 echo "Stopping running processes before unloading Kernel Extensions"
  15.                 ps -ef | grep [V]ir | awk '{print $2}' | xargs kill
  16.         fi
  17.         echo "Unloading Kernel Extensions"
  18.         kextstat | grep "org.virtualbox.kext.VBoxUSB" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxUSB
  19.         kextstat | grep "org.virtualbox.kext.VBoxNetFlt" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetFlt
  20.         kextstat | grep "org.virtualbox.kext.VBoxNetAdp" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetAdp
  21.         kextstat | grep "org.virtualbox.kext.VBoxDrv" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxDrv
  22. }
  23.  
  24. load() {
  25.         echo "Loading Kernel Extentions"
  26.         sudo kextload "/Library/Application Support/VirtualBox/VBoxDrv.kext" -r "/Library/Application Support/VirtualBox/"
  27.         sudo kextload "/Library/Application Support/VirtualBox/VBoxNetAdp.kext" -r "/Library/Application Support/VirtualBox/"
  28.         sudo kextload "/Library/Application Support/VirtualBox/VBoxNetFlt.kext" -r "/Library/Application Support/VirtualBox/"
  29.         sudo kextload "/Library/Application Support/VirtualBox/VBoxUSB.kext" -r "/Library/Application Support/VirtualBox/"
  30. }
  31.  
  32. case "$1" in
  33.         unload|remove)
  34.                 unload
  35.                 ;;
  36.         load)
  37.                 load
  38.                 ;;
  39.         *|reload)
  40.                 unload
  41.                 load
  42.                 ;;
  43. esac
  44.  
  45. #############
  46. # START NOTES
  47. #############
  48.  
  49. ## Reference:
  50. ## <https://github.com/caskroom/homebrew-cask/issues/39369>
  51.  
  52. ###########
  53. # END NOTES
  54. ###########
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement