From 9099277a2dab6743534a54fa860b412f51fb5977 Mon Sep 17 00:00:00 2001 From: Jack <31696646+myspaghetti@users.noreply.github.com> Date: Mon, 27 Sep 2021 11:41:05 +0300 Subject: [PATCH] better WSLg detection, still extremely slow If you're using WSLg, consider using KVM instead of VirtualBox --- macos-guest-virtualbox.sh | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/macos-guest-virtualbox.sh b/macos-guest-virtualbox.sh index 775c627..872ad8b 100755 --- a/macos-guest-virtualbox.sh +++ b/macos-guest-virtualbox.sh @@ -2,7 +2,7 @@ # Push-button installer of macOS on VirtualBox # (c) myspaghetti, licensed under GPL2.0 or higher # url: https://github.com/myspaghetti/macos-virtualbox -# version 0.99.1.1 +# version 0.99.1.2 # Dependencies: bash coreutils gzip unzip wget xxd dmg2img # Optional features: tesseract-ocr tesseract-ocr-eng @@ -280,6 +280,21 @@ if [[ -n "$(cygcheck -V 2>/dev/null)" ]]; then exit fi fi +# Windows Subsystem for Linux 2 (WSL2 or WSLg) +elif [[ "$(cat /proc/sys/kernel/osrelease 2>/dev/null)" =~ WSL[2Gg] ]]; then # WSL2 or WSLg + if [[ -n "$(VBoxManage -v 2>/dev/null)" ]]; then + if [[ ! "$(lsmod)" =~ vboxdrv ]]; then # if the vboxdrv kernel module is not present + echo "The script appears to be executed on WSL2 or WSLg." + echo "Mind that WSL2 and WSLg require kernel module compilation and" + echo "custom configuration that is not supported by the script." + echo "If the script does not detect the ${highlight_color}vboxdrv${default_color} kernel module, it exits." + exit + fi + else + echo "Please make sure VirtualBox version 5.2 or higher is installed," + echo "and that the path to the VBoxManage executable is in the PATH variable." + exit + fi # Windows Subsystem for Linux (WSL "1") elif [[ "$(cat /proc/sys/kernel/osrelease 2>/dev/null)" =~ [Mm]icrosoft ]]; then if [[ -n "$(VBoxManage.exe -v 2>/dev/null)" ]]; then @@ -297,22 +312,10 @@ elif [[ "$(cat /proc/sys/kernel/osrelease 2>/dev/null)" =~ [Mm]icrosoft ]]; then } echo "Found VBoxManage" else - if [[ "$(cat /proc/sys/kernel/osrelease 2>/dev/null)" =~ WSL[2Gg] ]]; then # WSL2 or WSLg - if [[ -n "$(VBoxManage -v 2>/dev/null)" ]]; then - true # do nothing - else - echo "Please make sure VirtualBox version 5.2 or higher is installed," - echo "and that the path to the VBoxManage executable is in the PATH variable." - echo "Mind that WSL2 and WSLg require kernel module compilation and custom" - echo "configuration that is not supported by the script." - exit - fi - else - echo "Please make sure VirtualBox is installed on Windows, and that the path to the" - echo "VBoxManage.exe executable is in the PATH variable, or assigned in the script" - echo -e "to the variable \"${highlight_color}wsl_path_VBoxManage${default_color}\" including the name of the executable." - exit - fi + echo "Please make sure VirtualBox is installed on Windows, and that the path to the" + echo "VBoxManage.exe executable is in the PATH variable, or assigned in the script" + echo -e "to the variable \"${highlight_color}wsl_path_VBoxManage${default_color}\" including the name of the executable." + exit fi fi # everything else (not cygwin and not wsl)