diff --git a/.gitignore b/.gitignore
index 1f6acd8..7f7e13b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
/vm-files/*.fd
/vm-files/*.iso
/vm-files/*.img
+/vm-files/*.vfd
/vm-files/*.aml
/vm-files/patched-ovmf-files
/vm-files/MAC_ADDRESS.txt
@@ -11,8 +12,12 @@
/thirdparty
/user.conf
/helper-iso-files/bin
-/utils/nvflash_linux
/helper-iso-files/drivers
+/helper-iso-files/.checksum
+/live-iso-files/*.iso
+/live-iso-files/scripts/chocolatey-install.ps1
+/utils/nvflash_linux
+/tmp
.*.swp
.*.swo
*.asc
diff --git a/README.md b/README.md
index f42a6af..b449b8b 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,21 @@
# MobilePassThrough
## Introduction
-The goal of this project is to make GPU passthrough on notebooks as easy and accessible as possible.
-To achieve that goal I have written a collection of scripts [accessible via mbpt.sh](https://github.com/T-vK/MobilePassThrough#how-to-use-mbptsh) that:
+The goal of this project is to make GPU passthrough on x64 notebooks/tablets as easy and accessible as possible.
+To achieve that goal I have written a collection of scripts [accessible via mbpt.sh](https://github.com/T-vK/MobilePassThrough#how-to-use-mbptsh)
+
+### MBPT vs MBPT Live
+
+- You can either flash the MBPT Live ISO to a USB device and boot it to try it out without actually messing with your system. ([Download here](https://github.com/T-vK/MobilePassThrough/releases) or run `./mbpt.sh live build` to build it yourself.)
+- Or you can let `./mbpt.sh auto` set everything up on your exisitng Linux installation.
+
+Either way it is 100% automated, no user interaction required:
### On the host system (Linux):
- [x] Automatically install the required dependencies
- [x] Automatically configure the kernel parameters to support GPU passthrough
-- [x] Automatically install Bumblebee and the Nvidia GPU driver if required
+- [ ] Automatically install Bumblebee and the Nvidia GPU driver if required (I removed this feature because it was too error-prone. Instead we'll just use nouveau or whatever is installed already.)
- [x] Automatically check if and to what extend your device is compatible with GPU passthrough.
- [x] Automatically create and configure a virtual machine that is fully configured for GPU passthrough.
- [x] Automatically download the Windows 10 installation iso from Microsoft.
@@ -18,7 +25,7 @@ To achieve that goal I have written a collection of scripts [accessible via mbpt
### In the virtual machine (Windows)
-- [x] Automatically install the required drivers (ivshmem and other vfio drivers)
+- [x] Automatically install the required drivers (ivshmem, other vfio drivers, Intel/Nvidia display drivers)
- [x] Automatically compile/install/start LookingGlass
- [x] Automatically configure the network
- [x] Automatically set up RDP
@@ -36,13 +43,13 @@ And there is also a lot of advanced stuff that I managed to fully automate, like
## Currently supported distributions
- Fedora 34
- - Ubuntu 21.04
+ - Ubuntu 21.04 (Currently not working. Some dependencies won't be installed automatically.)
## Limitations
-- The project is currently only compatible with Fedora and Ubuntu out of the box (Support for older Fedora/Ubuntu versions may break over time because I don't test changes made to this repo against older distributions.). (To add support for a new distro, copy one of the folders found in [utils](utils)) and adjust it for your distro.)
+- The project is currently only really being tested on Fedora and Ubuntu (currently broken). But it has been written in a somewhat distribution-agnostic way, meaning it might just work on other distributions and if not, you might just have to add a new script to `scripts/utils/manager-specific/`. (For example the project currently supports the package managers `dnf` and `apt`, if your distro uses `pacman`, you have to add a pacman script that can be called the same way as the [apt script](scripts/utils/manager-specific/package/apt).)
- This project currently only supports Windows 10 x64 VMs and hopefully Windows 11 x64 VMs at some point. (For older Windows versions you have to figure out the driver installation etc. on your own.)
-- Only tested for Intel+Nvidea and Intel+AMD systems. (Although the compatibility-check (./mbpt.sh check) should actually work on any hardware.)
+- Only tested for Intel+Nvidia and Intel+AMD systems. (Although the compatibility-check (./mbpt.sh check) should actually work on any hardware.)
- Expect bugs. I have only tested this on a handful of devices and I have constantly changed the scripts without testing everything every time.
- Automated vBIOS ROM extraction will fail in most cases. You might have to extract it from a BIOS update. (You may not need the vBIOS ROM though.)
- This project takes a couple of measures to circumvent Nvidia's infamous Error 43, which you normally see in the Windows device manager when you pass a mobile Nvidia GPU through to a Windows VM. But even with these measures, some systems will still show Error 43.
@@ -55,81 +62,39 @@ And there is also a lot of advanced stuff that I managed to fully automate, like
- Provide the VM with a fake battery
- Provide the VM with the vBios ROMs
- Patch OVMF, hardcoding your dGPU vBIOS ROM in it
- - (Another measure you can scripttake yourself is installing a recent Nvidia driver in your VM. See [this](https://nvidia.custhelp.com/app/answers/detail/a_id/5173/~/geforce-gpu-passthrough-for-windows-virtual-machine-%28beta%29))
+ - Installing the latest Nvidia driver
+ - (Another measure you can take yourself is installing a recent Nvidia driver in your VM. See [this](https://nvidia.custhelp.com/app/answers/detail/a_id/5173/~/geforce-gpu-passthrough-for-windows-virtual-machine-%28beta%29))
- Other projects that may help, but are very outdated and currently don't work: [NVIDIA-vBIOS-VFIO-Patcher](https://github.com/Matoking/NVIDIA-vBIOS-VFIO-Patcher), [nvidia-kvm-patcher](https://github.com/sk1080/nvidia-kvm-patcher).
## How to use?
### BIOS/UEFI configuration
+- Enable `Intel VT-x` / `AMD-V` as well as `Intel VT-d` / AMD's `IOMMU` in the BIOS / UEFI.
- On some (gaming) notebooks the integrated graphics of the CPU are disabled. If that is the case for you, you need to enable them in the BIOS/UEFI.
(Some vendors actually disable the CPU integrated GPU completely and don't offer UEFI options to enable it. Modding your BIOS could potentially fix that. See the "UEFI / BIOS modding" for more information on that.)
- You might also have to disable secure boot in the UEFI.
(Mainly to use Nvida's proprietary driver on Linux while your VM is not running.)
- It might also be necessary to disable fastboot in the UEFI.
-- It is highly recommended to have your Linux installed in UEFI mode (rather than in legacy mode).
- If you drive doesn't show up during the installation in UEFI mode, make sure the SATA mode is set to AHCI in the UEFI, even if you don't use SATA.
+- It is highly recommended to have your Linux installed/booted in UEFI mode (rather than in legacy mode).
+- If your drive doesn't show up during the installation in UEFI mode, make sure the SATA mode is set to AHCI in the UEFI, even if you don't use SATA.
### Installation and configuration
-- Download and install [standard Fedora](https://getfedora.org/) or the [KDE version](https://spins.fedoraproject.org/kde/) or [Ubuntu](https://ubuntu.com/download/desktop) (ideally in UEFI mode!)
-- Make sure to create a user account (with administrator rights) (in case you are asked)
-- Open a terminal and install git by typing the following, pressing enter after each line:
-
-``` bash
-sudo dnf install git -y # Install git
-git clone https://github.com/T-vK/MobilePassThrough.git # Clone the project
-cd MobilePassThrough # Enter the project directory
-./mbpt.sh setup # Dependency installation; kernel param config; bumblebee / nvidia driver installation; and much more ...
-```
-
-- Reboot your system
-- Open a new terminal and type:
-
-``` bash
-cd MobilePassThrough # Enter the project directory
-./mbpt.sh check # Check if your system is compatible
-# If the script says that your system is compatible you may proceed:
-./mbpt.sh configure # Create a config file
-# Follow the instructions in your terminal! Then continue:
-./mbpt.sh iso # Generate an iso file containing tools, installers, drivers and a Batch script that we need later
-```
-
-### Installation of Windows 10 in the VM
-
-- Open TWO terminals, in the first one type:
-``` bash
-cd MobilePassThrough # Enter the project directory
-./mbpt.sh start # Start the VM for the first time
-# Make sure you didn't get any critical errors
-```
-
-- In the second one quickly type:
-``` bash
-spicy -h localhost -p 5900
-```
-- window should appear giving a GUI to interact with the VM and it will say something like "press any key to boot from cd now".
-- Press any key quickly!
-- The Windows installer will show. Go through it, it should be simple enough.
-- During the installation you may have to manually pick a disk driver for the virtual disk to be recognized. Click "Browse" and select `amd64\w10` from the `virtio-win` CD Drive.
-- You should set a password for your user account otherwise you'll have trouble with RDP.
-- Once Windows is installed, go to the virtual CD drive that contains the start.bat file and right-click it and click `Run as administrator` and make sure you didn't get any errors.
-- Reboot the VM.
-
-In the future when you want to start the VM, you can open 2 terminals:
-
-- In the first one run:
-``` bash
-cd MobilePassThrough # Enter the project directory
-./mbpt.sh start
-```
-
-- Open Remmina and connect to `rdp://192.168.99.2`
-
+- Open a terminal and install git and MobilePassThrough by typing the following, pressing enter after each line:
+ ``` Bash
+ sudo dnf install git -y # Install git
+ git clone https://github.com/T-vK/MobilePassThrough.git # Clone the project
+ cd MobilePassThrough # Enter the project directory
+ ./mbpt.sh configure # Create a custom config file interactively (optional)
+ ./mbpt.sh auto # Dependency installation; kernel param config; bumblebee / nvidia driver installation; windows ISO download; reboot to load new kernel params; create a helper iso with drivers and autounattended config for Windows; create and start VM; install Windows in the VM fully unattended; install drivers and looking glass in the VM automatically; check for error 43 automatically and show a warning if it occurs
+ ```
+- Once the installation finished you should be able to open Remmina and connect to `rdp://192.168.99.2`
- Then in the second terminal run:
-``` bash
-cd MobilePassThrough # Enter the project directory
-cd ./thirdparty/LookingGlass/client/build/ # Enter the directoy containing the looking glass client executable
-./looking-glass-client # Run the looking glass client
-```
+ ``` Bash
+ cd MobilePassThrough # Enter the project directory
+ cd ./thirdparty/LookingGlass/client/build/ # Enter the directoy containing the looking glass client executable
+ ./looking-glass-client # Run the looking glass client
+ ```
+- From now on, start the VM with `./mbpt.sh start`
## How to use mbpt.sh
@@ -142,14 +107,15 @@ mbpt.sh is a wrapper script for a collection of tools that help with GPU passthr
Options:
-h, --help Print usage
- -v, --version Print version information
Commands:
- setup Install required dependencies and set required kernel parameters
- check Check if and to what degree your notebook is capable of running a GPU passthrough setup
+ auto Automatically run check, setup and install
configure Interactively guides you through the creation of your config file
- iso Generate a helper iso file that contains required drivers and a helper-script for your Windows VM
- start Start your VM
+ check Check if and to what degree your notebook is capable of running a GPU passthrough setup
+ setup Install required dependencies and set required kernel parameters
+ install Create and install the VM
+ start Start the VM
+ live Create / Flash a Live ISO image of this project
vbios Dump the vBIOS ROM from the running system or extract it from a BIOS update
Examples:
@@ -160,14 +126,35 @@ Examples:
mbpt.sh check
# Interactively guides you through the creation of your config file
- mbpt.sh confi`gure
+ mbpt.sh configure
# Generate a helper iso file that contains required drivers and a helper-script for your Windows VM
mbpt.sh iso
- # Start your VM
+ # Create the VM and install Windows in it (Will overwrite an older instance if one exists!)
+ mbpt.sh install
+
+ # Start the VM
mbpt.sh start
+ # Create a Live ISO
+ mbpt.sh live buid
+
+ # Flash a Live ISO to the USB drive /dev/sdx
+ mbpt.sh live flash /dev/sdx
+
+ # Print the qemu command that would have been used to start the VM
+ mbpt.sh start dry-run
+
+ # Print the qemu command that would have been used to install the VM
+ mbpt.sh install dry-run
+
+ # Print the libvirt XML that would have been used to start the VM
+ mbpt.sh start get-xml
+
+ # Print the libvirt XML that would have been used to install the VM
+ mbpt.sh install get-xml
+
# Dump the vBIOS ROM of the GPU with the PCI address 01:00.0 to ./my-vbios.rom (This will most likely fail)
mbpt.sh vbios dump 01:00.0 ./my-vbios.rom
@@ -175,7 +162,7 @@ Examples:
mbpt.sh vbios extract /path/to/my-bios-update.exe ./my-roms
```
-## Requirements to get GPU-passthrough to work on mobile
+## Hardware requirements to get GPU-passthrough to work on mobile
- Device needs to be (mostly) compatible with Linux.
Note: most Laptops should be these days
@@ -206,12 +193,7 @@ Examples:
Possible workaround: Modding your BIOS/UEFI using tools like UEFITool, AMIBCP etc. (See "UEFI / BIOS modding" below)
- The GPU you want to pass through, has to be in an IOMMU group that doesn't have other devices in it that the host system needs.
- Possible workaround: You might be able to tear the groups further apart using the ACS override patch, but it's no magic cure, there are drawbacks.
-
-
-The last point really seems to be the biggest hurdle, but since it's just a software issue, it should be possible to get this to work.
-We just need some smart people to fix one of these patches or to make them more accessible.
-
+ Possible workaround: You might be able to tear the groups further apart using the ACS override patch, but it's no magic cure, there are drawbacks.
## Potentially useful hardware tools
@@ -227,21 +209,6 @@ Check out: https://gpu-passthrough.com/
By modding your BIOS/UEFI, you can make features available and change settings that are hidden or non-existent by default. For example: show VT-d settings, show secure boot settings, show muxing related settings and much more. There is a good collection of modding tools on [this site here in the BIOS / UEFI tools section](https://forums.tweaktown.com/gigabyte/30530-overclocking-programs-system-info-benchmarking-stability-tools-post284763.html#post284763).
There are many BIOS modding forums out there with lots of people who are more than willing to help even if you're a complete beginner.
-# Configuring the Windows VM manually
-
- - (During the installation you may have to manually pick a disk driver for the virtual disk to be recognized. Click "Browse" and Select ?:\viostor\w10\amd64\ from the virtio-win CD Drive.)
- - After the installation open the Windows Device Manager and manually install missing drivers by rightclicking the devices with a warning symbol (not the graphics card though) -> "Update Driver" -> "Browse my computer for driver software" -> Click "Browse..." -> Select the virtio-win CD Drive -> Click OK -> Click Next.
- - If under "System devices" you have a device called "PCI standard RAM Controller", then you have to install a different driver for that by downloading [these drivers](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/upstream-virtio/virtio-win10-prewhql-0.1-161.zip), extracting them and then do the previous step for this device, but browse to the extracted folder instead and select that instead. The device should then show up as "IVSHMEM Device".
- - I also advice you to enable Widnows Remote Desktop ("Allow remote connections to this computer" in the System Properties)
- - For RDP to work properly you might have to set up a password for your Windows user
- - I'd also advice you to disable UAC by setting "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA" to 0 because the propts are hidden to Looking Glass.
- - Set a static IP for the virtio (TAP) Ethernet adapter in Windows. E.g. 192.168.99.2
- - If you want to use Looking Glass download and install the [Microsoft Visual C++ 2017 Redistributables Package](https://download.microsoft.com/download/8/9/D/89D195E1-1901-4036-9A75-FBE46443FC5A/VC_redist.x64.exe) and download the [latest release of the Looking Glass host](https://github.com/gnif/LookingGlass/releases)
- - I'd also put Looking Glass into the startup folder so that it runs automatically every time.
-
-## Known issues
-- Sometimes the `./mbpt.sh start` command will fail to start the VM because of this error: "echo: write error: No space left on device". It happens while attempting to create a vGPU for the iGPU. I have no clue why this happens. Sometimes it works if you just try it again, sometimes you need to wait a few minutes before retrying, but other times you actually have to reboot the host system.
-
## Credits
Credits to [Wendell from Level1Techs](https:`//level1techs.com/) for his GPU passthrough guides/videos and [Misairu-G for his Optimus laptop dGPU passthrough guide](https://gist.github.com/Misairu-G/616f7b2756c488148b7309addc940b28).
@@ -249,18 +216,34 @@ Without them I would have never even thought about creating this project. Thank
Credits to [korewaChino](https://github.com/T-vK/MobilePassThrough/pull/13) for adding support for Ubuntu!
+Credits to [Cole Robinson](https://blog.wikichoon.com/) for giving me a lot of incredibly valuable hard to find information on `virt-install`!
+
## TODO
-- Add nuveau driver compatibility
+### High prio
+- Fix for Ubuntu (Fix file dependency installation)
+- Document all the new features
+- Create a first Beta release
+- Test with an Nvidia notebook
+- Fix automatic Nvidia driver installation in the VM (fix chocolatey)
+- Fix RDP
+- Fix Samba sharing
+- Add virt-install version check because 2.2.1 doesn't seem to support the --xml flag
+
+### Low prio
+- Add nouveau driver compatibility
- Allow the user to decide if he wants bumblebee or not (for Nvidia GPUs)
- More detailed output about how the device is muxed
-- Fix unattended Windows installation
-- Create a bootable live version of this project
+- Test service auto reboot
- Create packages (deb, rpm, etc)
-- Add compatibility for Arch, Debian, etc...
+- Add compatibility for Arch, Debian, Pop OS etc...
- Make this project work better on systems that already have a non-default GPU driver installed
- Make it easy to uninstall the dependencies and undo the changes to the systm config (like kernel parameters)
- Find a way to circumvent Error 43 for AMD GPUs like the `Radeon RX Vega M GL`
-- Reduce the size of the ovmf-vbios-patch Docker image
+- Reduce the size of the ovmf-vbios-patch Docker image or build it completely outside of docker
- Make the USB passthrough device selection easier (i.e. display a list of devices that can be selected)
-- Look into hotplugging and check if the GPU can be hotplugged during VM runtime
\ No newline at end of file
+- Look into hotplugging and check if the GPU can be hotplugged during VM runtime
+- Check if required dependencies are installed for each script
+- Add support for multiple VMs
+- Add support for Linux guests
+- Add support for Desktop PCs
diff --git a/default.conf b/default.conf
index e319658..1bfdf85 100644
--- a/default.conf
+++ b/default.conf
@@ -1,58 +1,50 @@
-VM_NAME="WindowsVM" # Required
+# Predefined variables: PROJECT_DIR (contains the path to the MobilePassthrough project)
-CPU_CORE_COUNT=1 # Required
-RAM_SIZE=8G # Required
-VM_DISK_SIZE=40G # Required once, Changing this after the drive image has been created has no effect
+# Variables that require a reinstall when changed (./mbpt.sh install)
+VM_NAME="MBPT_WindowsVM" # Can't be empty; no spaces allowed
+VM_FILES_DIR="${PROJECT_DIR}/vm-files" # The folder into which all files for your VM will be saved (Can't be an empty string)
+DRIVE_IMG="${VM_FILES_DIR}/${VM_NAME}.img" # The location of your VM disk (Can't be an empty string)
+VM_DISK_SIZE="40G" # Required once; changing this after the drive image has been created has no effect, unless you reinstall (E.g. "40G", "250G", ...); At least "40G" is highly recommended; "30G" will probably work, but Windows will break if you use it all
+INSTALL_IMG="${VM_FILES_DIR}/windows10.iso" # Path of Windows 10 ISO used during installation (Will be downloaded to that location if it doesn't exist; Can't be an empty string)
-VM_FILES_DIR="${PROJECT_DIR}/vm-files" # Required ; The folder into which all files for your VM will be saved
+# Variables that can be changed between VM starts (./mbpt.sh start)
+CPU_CORE_COUNT="auto" # "auto" is recommended (e.g. "8", "12" or "auto"); "auto" uses all, but one core, but no more than 16
+RAM_SIZE="auto" # "auto" is recommended (e.g. "8G", "10G" or "auto"); "auto" uses [all free RAM]-1GB, but no more than 16GB
-DRIVE_IMG="${VM_FILES_DIR}/${VM_NAME}.img" # Required ; The location of your VM disk
+DGPU_PCI_ADDRESS="auto" # E.g. "01:00:0" or "auto", "auto" will use the fist dGPU it finds (if more than one, you will be asked which one to use; after 10 seconds it will timeout and use the fist one); see output of lspci
+IGPU_PCI_ADDRESS="auto" # Only Intel iGPUs supported atm; recommended to leave on "auto"; Use "" to disable or "auto" to automatically detect it (recommended); required for mediated iGPU passthrough. you can check your iGPU PCI address using lspci
+DGPU_PASSTHROUGH="auto" # "auto", "true" or "false" ("auto" Recommended) "auto" will enable it if the system has more than one GPU
+SHARE_IGPU="auto" # "auto", "true", or "false"; only works for Intel iGPUs atm; "auto" will enable it automatically if an Intel iGPU is detected; Recommended to save battery life (this is mediated iGPU passthrough using GVT-g)
-INSTALL_IMG="${VM_FILES_DIR}/windows10.iso" # Required for Windows installation
+DGPU_ROM="" # Optional (Can help getting rid of error 43); Use "" to not load a vBIOS ROM or specify a path to one (e.g. "${VM_FILES_DIR}/vbios-roms/vbios.rom")
+IGPU_ROM="" # Optional (Can help getting rid of error 43); Use "" to not load a vBIOS ROM or specify a path to one (e.g. "${VM_FILES_DIR}/vbios-roms/igpu-vbios.rom")
+PATCH_OVMF_WITH_VROM="true" # "true" or "false"; Recommended to avoid Error 43; (Doesn't do anything, unless you specify a DGPU_ROM or IGPU_ROM)
-DGPU_ROM="" # Optional; for example "${VM_FILES_DIR}/vbios-roms/vbios.rom"
-IGPU_ROM="" # Optional; for example "${VM_FILES_DIR}/vbios-roms/igpu-vbios.rom"
+MAC_ADDRESS="auto" # Required (E.g. 00:11:22:33:44:55 or auto to generate a new one with every VM start)
+NETWORK_MODE="bridged" # Supports bridged or none
+SMB_SHARE_FOLDER="" # Optional; for example "${VM_FILES_DIR}/vmshare" or "" to not use it
-SMB_SHARE_FOLDER="" # Optional; for example "${VM_FILES_DIR}/vmshare"
+VIRTUAL_INPUT_TYPE="virtio" # "usb-tablet", "virtio" or "". If keyboard input doesn't work properly for you, you may want to use "virtio" instead of "usb-tablet"
-OVMF_CODE="/usr/share/OVMF/OVMF_CODE.fd" # Required
-OVMF_VARS="/usr/share/OVMF/OVMF_VARS.fd" # Required
-OVMF_VARS_VM="${VM_FILES_DIR}/OVMF_VARS_VM.fd" # Required
+OVMF_CODE="/usr/share/OVMF/OVMF_CODE.fd" # Path to the unmodified OVMF_CODE image
+OVMF_VARS="/usr/share/OVMF/OVMF_VARS.fd" # Path to the unmodified OVMF_VARS image
+OVMF_VARS_VM="${VM_FILES_DIR}/OVMF_VARS_VM.fd" # Path to where a copy of the unmodified OVMF_VARS image will be created automatically
-VIRTIO_WIN_IMG="/usr/share/virtio-win/virtio-win.iso" # Required for driver installation
+HELPER_ISO="${VM_FILES_DIR}/mobile-passthrough-helper.iso" # Required for automated driver installation, looking glass setup, IP setup, remote desktop setup etc. inside of the VM
-HELPER_ISO="${VM_FILES_DIR}/mobile-passthrough-helper.iso" # Required for automated driver installation, looking glass setup, IP setup, remote desktop setup etc inseide of the VM
+LOOKING_GLASS_MAX_SCREEN_WIDTH="1920" # 1920 Recommended (bigger resolutions will result in a bigger buffer with worse performance)
+LOOKING_GLASS_MAX_SCREEN_HEIGHT="1080" # 1080 Recommended (bigger resolutions will result in a bigger buffer with worse performance)
+LOOKING_GLASS_VERSION="B4" # B4 Recommended
-DGPU_PCI_ADDRESS=01:00.0 # Required; If you don't use Bumblebee, you have to set this to the correct PCI address of your dGPU (see output of lspci)
-# This project has only been tested with Bumblebee enabled.
-IGPU_PCI_ADDRESS=00:02.0 # Recommended; required for mediated iGPU passthrough. you can cehck your iGPU PCI address using lspci
+DISPLAY_MODE="4" # ("4" is the only working one atm) Display mode to use (e.g. 1 or 2 ... see scripts/utils/common/plugins)
-DGPU_PASSTHROUGH=true # Recommended
-
-SHARE_IGPU=true # Recommended to save battery life (this is mediated iGPU passthrough using GVT-g)
-
-HOST_DGPU_DRIVER=nvidia # Only tested with "nvidia" and "amdgpu", not tested with "nouveau"
-
-VIRTUAL_INPUT_TYPE="usb-tablet" # "usb-tablet", "virtio" or "". If keyboard input doesn't work properly for you, you may want to use "virtio" instead of "usb-tablet"
-
-MAC_ADDRESS="" # Required
-NETWORK_MODE=TAP # Currently only supports TAP (bridged, NAT and none don't work atm)
-
-USE_LOOKING_GLASS=true # Optional
-LOOKING_GLASS_MAX_SCREEN_WIDTH=1920 # Recommended (bigger resolutions will result in a bigger buffer with worse performance)
-LOOKING_GLASS_MAX_SCREEN_HEIGHT=1080 # Recommended (bigger resolutions will result in a bigger buffer with worse performance)
-LOOKING_GLASS_VERSION=B3 # Recommended
-
-USE_SPICE=true # Required for Windows installation and recommended for Looking Glass
-SPICE_PORT=5900 # 5900 is recommended
-
-USE_DMA_BUF=true # Optional
-
-USE_QXL=true # Required for RDP
+USE_SPICE="true" # Recommended for Windows installation and required for Looking Glass and QXL
+SPICE_PORT="5904" # 5900 is the normal port, but it may already be used by something else on your system like VNC
+USE_SPICE_CLIENT="true" # Recommended for installation
USE_FAKE_BATTERY="true" # Recommended to avoid Error 43
-PATCH_OVMF_WITH_VROM="true" # Recommended to avoid Error 43
+VM_START_MODE="qemu" # "qemu" is recommended ("qemu" or "virt-install")
# USB devices to pass through automatically while the VM is running. Separated by semicolons!
# (See output of lsusb for vendorid/productid or hostbus/hostaddr)
@@ -60,11 +52,3 @@ USB_DEVICES=""
# example1: USB_DEVICES="hostbus=3,hostaddr=9"
# example2: USB_DEVICES="vendorid=0x0b95,productid=0x1790"
# example3: USB_DEVICES="vendorid=0x0b12,productid=0x9348;vendorid=0x0b95,productid=0x1790;hostbus=3,hostaddr=9"
-
-####### This part of the config get's burned into the helper iso that you can generate using generate-helper-iso.sh ######
-# Not implemented yet; Please change the helper-iso-files/start.bat file manually, if you need to change the IPs
-#V_NETWORK_GATEWAY_IP=192.168.99.1 # Recommended (Leave this as is unless you know what you're doing)
-#V_NETWORK_DNS_IP=192.168.99.1 # Recommended (Leave this as is unless you know what you're doing)
-#V_NETWORK_IP=192.168.99.2 # Recommended (Leave this as is unless you know what you're doing)
-# TODO: add DHCP
-##########################################################################################################################
diff --git a/helper-iso-files/Autounattend.xml b/helper-iso-files/Autounattend.xml
new file mode 100644
index 0000000..d6b0f5d
--- /dev/null
+++ b/helper-iso-files/Autounattend.xml
@@ -0,0 +1,169 @@
+
+
+
+
+
+
+ E:\bin\virtio-drivers\Win10\amd64
+
+
+
+
+
+ en-GB
+
+ en-GB
+ en-GB
+ en-GB
+ en-GB
+ en-GB
+
+
+
+
+ 0
+ true
+
+
+ 1
+ EFI
+ 100
+
+
+ 2
+ MSR
+ 4096
+
+
+ 3
+ Primary
+ true
+
+
+
+
+ 1
+ 1
+
+ FAT32
+
+
+ 2
+ 3
+
+ C
+ NTFS
+
+
+
+ OnError
+
+
+
+ OnError
+
+
+ /IMAGE/NAME
+ Windows 10 Pro
+
+
+
+ 0
+ 3
+
+
+
+
+ true
+
+
+
+
+ Never
+
+
+
+ false
+ Never
+
+ false
+ C:\Log
+
+
+
+
+ false
+
+
+
+
+ 1
+
+
+
+
+
+
+
+ admin
+ true
+
+
+
+
+ admin
+ true
+
+ Administrator
+ 99
+ true
+
+
+ true
+ true
+ true
+ true
+ true
+ Work
+ 3
+ true
+ true
+
+ UTC
+
+
+ cmd /q /c "FOR %i IN (A B C D E F G H I J K L N M O P Q R S T U V W X Y Z) DO IF EXIST %i:\mbpt-helper.bat cmd /c %i:\mbpt-helper.bat"
+ Install drivers, guest tools, looking glass, enable RDP, etc.
+ 1
+ false
+
+
+
+
+
+
diff --git a/helper-iso-files/RedHat.cer b/helper-iso-files/RedHat.cer
new file mode 100644
index 0000000..91c8be6
Binary files /dev/null and b/helper-iso-files/RedHat.cer differ
diff --git a/helper-iso-files/mbpt-helper.bat b/helper-iso-files/mbpt-helper.bat
new file mode 100644
index 0000000..e30a0fc
--- /dev/null
+++ b/helper-iso-files/mbpt-helper.bat
@@ -0,0 +1,66 @@
+cd /D %~dp0
+
+echo "Set poweshell execution policy to unrestricted..."
+powershell -Command "Set-ExecutionPolicy Unrestricted
+
+echo "Disable password expiration for Administrator user..."
+wmic useraccount where "name='Administrator'" set PasswordExpires=FALSE
+
+echo "Installing required Visual C++ Redistributable Package..."
+.\bin\VC_redist.x64.exe /install /passive /norestart
+
+echo "Install vfio drivers..."
+certutil -addstore "TrustedPublisher" .\RedHat.cer
+%WINDIR%\system32\pnputil.exe /add-driver .\bin\virtio-drivers\Win10\amd64\*.inf /subdirs /install
+
+echo "Disable mouse acceleration..."
+powershell -executionpolicy unrestricted -file .\scripts\disable-mouse-acceleration.ps1
+
+echo "Install Spice guest tools..."
+.\bin\spice-guest-tools.exe /S
+
+echo "Install Spice WebDAV daemon..."
+.\bin\spice-webdavd.msi /passive /norestart
+
+echo "Install Looking Glass to Program Files ..."
+.\bin\looking-glass-host-setup.exe /S
+
+echo "Changing the virtual Ethernet adapter to a private one to allow RDP access..."
+for /F "skip=3 tokens=1,2,3* delims= " %%G in ('netsh interface show interface') DO (
+ echo "Setting %%J to private..."
+ powershell -command Set-NetConnectionProfile -InterfaceAlias "Network" -NetworkCategory Private
+)
+
+echo "Enable remote desktop..."
+reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
+netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
+
+echo "Copy gpu-check script to startup..."
+md "%APPDATA%\mbpt"
+copy .\scripts\gpu-check.ps1 "%APPDATA%\mbpt"
+copy .\scripts\mbpt-startup.bat "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup"
+
+echo "Wait until we're connected to the Internet..."
+powershell -executionpolicy unrestricted -file .\scripts\network-check.ps1
+
+echo "Install Chocolatey if possible..."
+powershell -executionpolicy unrestricted -file .\scripts\chocolatey-install.ps1
+
+echo "Run GPU check..."
+powershell -executionpolicy unrestricted -file .\scripts\gpu-check.ps1 unattended
+
+echo "Done! Shutting down the VM in 30 seconds..."
+
+shutdown -s
+
+pause
+
+::echo "Set static IP for vfio network device..."
+:: TODO: Find the correct network adapter name
+::netsh int ip set address "Ethernet" static 192.168.99.2 255.255.255.0 192.168.99.1 1
+::netsh int ip set dns "Ethernet" static 192.168.99.1 primary
+:: netsh int ip set address "Local Area Connection" static 192.168.99.2 255.255.255.0 192.168.99.1 1
+:: netsh int ip set dns "Local Area Connection" static 192.168.99.1 primary
+
+::echo "Waiting for 5 seconds..."
+::timeout /t 5 /nobreak > nul
\ No newline at end of file
diff --git a/helper-iso-files/scripts/chocolatey-install.ps1 b/helper-iso-files/scripts/chocolatey-install.ps1
new file mode 100644
index 0000000..34c9908
--- /dev/null
+++ b/helper-iso-files/scripts/chocolatey-install.ps1
@@ -0,0 +1,698 @@
+<#
+ .SYNOPSIS
+ Downloads and installs Chocolatey on the local machine.
+
+ .DESCRIPTION
+ Retrieves the Chocolatey nupkg for the latest or a specified version, and
+ downloads and installs the application to the local machine.
+
+ .NOTES
+ =====================================================================
+ Copyright 2017 - 2020 Chocolatey Software, Inc, and the
+ original authors/contributors from ChocolateyGallery
+ Copyright 2011 - 2017 RealDimensions Software, LLC, and the
+ original authors/contributors from ChocolateyGallery
+ at https://github.com/chocolatey/chocolatey.org
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ =====================================================================
+
+ Environment Variables, specified as $env:NAME in PowerShell.exe and %NAME% in cmd.exe.
+ For explicit proxy, please set $env:chocolateyProxyLocation and optionally $env:chocolateyProxyUser and $env:chocolateyProxyPassword
+ For an explicit version of Chocolatey, please set $env:chocolateyVersion = 'versionnumber'
+ To target a different url for chocolatey.nupkg, please set $env:chocolateyDownloadUrl = 'full url to nupkg file'
+ NOTE: $env:chocolateyDownloadUrl does not work with $env:chocolateyVersion.
+ To use built-in compression instead of 7zip (requires additional download), please set $env:chocolateyUseWindowsCompression = 'true'
+ To bypass the use of any proxy, please set $env:chocolateyIgnoreProxy = 'true'
+
+ .LINK
+ For organizational deployments of Chocolatey, please see https://docs.chocolatey.org/en-us/guides/organizations/organizational-deployment-guide
+
+#>
+[CmdletBinding(DefaultParameterSetName = 'Default')]
+param(
+ # The URL to download Chocolatey from. This defaults to the value of
+ # $env:chocolateyDownloadUrl, if it is set, and otherwise falls back to the
+ # official Chocolatey community repository to download the Chocolatey package.
+ [Parameter(Mandatory = $false)]
+ [string]
+ $ChocolateyDownloadUrl = $env:chocolateyDownloadUrl,
+
+ # Specifies a target version of Chocolatey to install. By default, the latest
+ # stable version is installed. This will use the value in
+ # $env:chocolateyVersion by default, if that environment variable is present.
+ # This parameter is ignored if -ChocolateyDownloadUrl is set.
+ [Parameter(Mandatory = $false)]
+ [string]
+ $ChocolateyVersion = $env:chocolateyVersion,
+
+ # If set, uses built-in Windows decompression tools instead of 7zip when
+ # unpacking the downloaded nupkg. This will be set by default if
+ # $env:chocolateyUseWindowsCompression is set to a value other than 'false' or '0'.
+ #
+ # This parameter will be ignored in PS 5+ in favour of using the
+ # Expand-Archive built in PowerShell cmdlet directly.
+ [Parameter(Mandatory = $false)]
+ [switch]
+ $UseNativeUnzip = $(
+ $envVar = "$env:chocolateyUseWindowsCompression".Trim()
+ $value = $null
+ if ([bool]::TryParse($envVar, [ref] $value)) {
+ $value
+ } elseif ([int]::TryParse($envVar, [ref] $value)) {
+ [bool]$value
+ } else {
+ [bool]$envVar
+ }
+ ),
+
+ # If set, ignores any configured proxy. This will override any proxy
+ # environment variables or parameters. This will be set by default if
+ # $env:chocolateyIgnoreProxy is set to a value other than 'false' or '0'.
+ [Parameter(Mandatory = $false)]
+ [switch]
+ $IgnoreProxy = $(
+ $envVar = "$env:chocolateyIgnoreProxy".Trim()
+ $value = $null
+ if ([bool]::TryParse($envVar, [ref] $value)) {
+ $value
+ }
+ elseif ([int]::TryParse($envVar, [ref] $value)) {
+ [bool]$value
+ }
+ else {
+ [bool]$envVar
+ }
+ ),
+
+ # Specifies the proxy URL to use during the download. This will default to
+ # the value of $env:chocolateyProxyLocation, if any is set.
+ [Parameter(ParameterSetName = 'Proxy', Mandatory = $false)]
+ [string]
+ $ProxyUrl = $env:chocolateyProxyLocation,
+
+ # Specifies the credential to use for an authenticated proxy. By default, a
+ # proxy credential will be constructed from the $env:chocolateyProxyUser and
+ # $env:chocolateyProxyPassword environment variables, if both are set.
+ [Parameter(ParameterSetName = 'Proxy', Mandatory = $false)]
+ [System.Management.Automation.PSCredential]
+ $ProxyCredential
+)
+
+#region Functions
+
+function Get-Downloader {
+ <#
+ .SYNOPSIS
+ Gets a System.Net.WebClient that respects relevant proxies to be used for
+ downloading data.
+
+ .DESCRIPTION
+ Retrieves a WebClient object that is pre-configured according to specified
+ environment variables for any proxy and authentication for the proxy.
+ Proxy information may be omitted if the target URL is considered to be
+ bypassed by the proxy (originates from the local network.)
+
+ .PARAMETER Url
+ Target URL that the WebClient will be querying. This URL is not queried by
+ the function, it is only a reference to determine if a proxy is needed.
+
+ .EXAMPLE
+ Get-Downloader -Url $fileUrl
+
+ Verifies whether any proxy configuration is needed, and/or whether $fileUrl
+ is a URL that would need to bypass the proxy, and then outputs the
+ already-configured WebClient object.
+ #>
+ [CmdletBinding()]
+ param(
+ [Parameter(Mandatory = $false)]
+ [string]
+ $Url,
+
+ [Parameter(Mandatory = $false)]
+ [string]
+ $ProxyUrl,
+
+ [Parameter(Mandatory = $false)]
+ [System.Management.Automation.PSCredential]
+ $ProxyCredential
+ )
+
+ $downloader = New-Object System.Net.WebClient
+
+ $defaultCreds = [System.Net.CredentialCache]::DefaultCredentials
+ if ($defaultCreds) {
+ $downloader.Credentials = $defaultCreds
+ }
+
+ if ($ProxyUrl) {
+ # Use explicitly set proxy.
+ Write-Host "Using explicit proxy server '$ProxyUrl'."
+ $proxy = New-Object System.Net.WebProxy -ArgumentList $ProxyUrl, <# bypassOnLocal: #> $true
+
+ $proxy.Credentials = if ($ProxyCredential) {
+ $ProxyCredential.GetNetworkCredential()
+ } elseif ($defaultCreds) {
+ $defaultCreds
+ } else {
+ Write-Warning "Default credentials were null, and no explicitly set proxy credentials were found. Attempting backup method."
+ (Get-Credential).GetNetworkCredential()
+ }
+
+ if (-not $proxy.IsBypassed($Url)) {
+ $downloader.Proxy = $proxy
+ }
+ } else {
+ Write-Host "Not using proxy."
+ }
+
+ $downloader
+}
+
+function Request-String {
+ <#
+ .SYNOPSIS
+ Downloads content from a remote server as a string.
+
+ .DESCRIPTION
+ Downloads target string content from a URL and outputs the resulting string.
+ Any existing proxy that may be in use will be utilised.
+
+ .PARAMETER Url
+ URL to download string data from.
+
+ .PARAMETER ProxyConfiguration
+ A hashtable containing proxy parameters (ProxyUrl and ProxyCredential)
+
+ .EXAMPLE
+ Request-String https://community.chocolatey.org/install.ps1
+
+ Retrieves the contents of the string data at the targeted URL and outputs
+ it to the pipeline.
+ #>
+ [CmdletBinding()]
+ param(
+ [Parameter(Mandatory = $true)]
+ [string]
+ $Url,
+
+ [Parameter(Mandatory = $false)]
+ [hashtable]
+ $ProxyConfiguration
+ )
+
+ (Get-Downloader $url @ProxyConfiguration).DownloadString($url)
+}
+
+function Request-File {
+ <#
+ .SYNOPSIS
+ Downloads a file from a given URL.
+
+ .DESCRIPTION
+ Downloads a target file from a URL to the specified local path.
+ Any existing proxy that may be in use will be utilised.
+
+ .PARAMETER Url
+ URL of the file to download from the remote host.
+
+ .PARAMETER File
+ Local path for the file to be downloaded to.
+
+ .PARAMETER ProxyConfiguration
+ A hashtable containing proxy parameters (ProxyUrl and ProxyCredential)
+
+ .EXAMPLE
+ Request-File -Url https://community.chocolatey.org/install.ps1 -File $targetFile
+
+ Downloads the install.ps1 script to the path specified in $targetFile.
+ #>
+ [CmdletBinding()]
+ param(
+ [Parameter(Mandatory = $false)]
+ [string]
+ $Url,
+
+ [Parameter(Mandatory = $false)]
+ [string]
+ $File,
+
+ [Parameter(Mandatory = $false)]
+ [hashtable]
+ $ProxyConfiguration
+ )
+
+ Write-Host "Downloading $url to $file"
+ (Get-Downloader $url @ProxyConfiguration).DownloadFile($url, $file)
+}
+
+function Set-PSConsoleWriter {
+ <#
+ .SYNOPSIS
+ Workaround for a bug in output stream handling PS v2 or v3.
+
+ .DESCRIPTION
+ PowerShell v2/3 caches the output stream. Then it throws errors due to the
+ FileStream not being what is expected. Fixes "The OS handle's position is
+ not what FileStream expected. Do not use a handle simultaneously in one
+ FileStream and in Win32 code or another FileStream." error.
+
+ .EXAMPLE
+ Set-PSConsoleWriter
+
+ .NOTES
+ General notes
+ #>
+
+ [CmdletBinding()]
+ param()
+ if ($PSVersionTable.PSVersion.Major -gt 3) {
+ return
+ }
+
+ try {
+ # http://www.leeholmes.com/blog/2008/07/30/workaround-the-os-handles-position-is-not-what-filestream-expected/ plus comments
+ $bindingFlags = [Reflection.BindingFlags] "Instance,NonPublic,GetField"
+ $objectRef = $host.GetType().GetField("externalHostRef", $bindingFlags).GetValue($host)
+
+ $bindingFlags = [Reflection.BindingFlags] "Instance,NonPublic,GetProperty"
+ $consoleHost = $objectRef.GetType().GetProperty("Value", $bindingFlags).GetValue($objectRef, @())
+ [void] $consoleHost.GetType().GetProperty("IsStandardOutputRedirected", $bindingFlags).GetValue($consoleHost, @())
+
+ $bindingFlags = [Reflection.BindingFlags] "Instance,NonPublic,GetField"
+ $field = $consoleHost.GetType().GetField("standardOutputWriter", $bindingFlags)
+ $field.SetValue($consoleHost, [Console]::Out)
+
+ [void] $consoleHost.GetType().GetProperty("IsStandardErrorRedirected", $bindingFlags).GetValue($consoleHost, @())
+ $field2 = $consoleHost.GetType().GetField("standardErrorWriter", $bindingFlags)
+ $field2.SetValue($consoleHost, [Console]::Error)
+ } catch {
+ Write-Warning "Unable to apply redirection fix."
+ }
+}
+
+function Test-ChocolateyInstalled {
+ [CmdletBinding()]
+ param()
+
+ $checkPath = if ($env:ChocolateyInstall) { $env:ChocolateyInstall } else { "$env:PROGRAMDATA\chocolatey" }
+
+ if ($Command = Get-Command choco -CommandType Application -ErrorAction Ignore) {
+ # choco is on the PATH, assume it's installed
+ Write-Warning "'choco' was found at '$($Command.Path)'."
+ $true
+ }
+ elseif (-not (Test-Path $checkPath)) {
+ # Install folder doesn't exist
+ $false
+ }
+ elseif (-not (Get-ChildItem -Path $checkPath)) {
+ # Install folder exists but is empty
+ $false
+ }
+ else {
+ # Install folder exists and is not empty
+ Write-Warning "Files from a previous installation of Chocolatey were found at '$($CheckPath)'."
+ $true
+ }
+}
+
+function Install-7zip {
+ [CmdletBinding()]
+ param(
+ [Parameter(Mandatory = $true)]
+ [string]
+ $Path,
+
+ [Parameter(Mandatory = $false)]
+ [hashtable]
+ $ProxyConfiguration
+ )
+
+ if (-not (Test-Path ($Path))) {
+ Write-Host "Downloading 7-Zip commandline tool prior to extraction."
+ Request-File -Url 'https://community.chocolatey.org/7za.exe' -File $Path -ProxyConfiguration $ProxyConfiguration
+
+ }
+ else {
+ Write-Host "7zip already present, skipping installation."
+ }
+}
+
+#endregion Functions
+
+#region Pre-check
+
+# Ensure we have all our streams setup correctly, needed for older PSVersions.
+Set-PSConsoleWriter
+
+if (Test-ChocolateyInstalled) {
+ $message = @(
+ "An existing Chocolatey installation was detected. Installation will not continue."
+ "For security reasons, this script will not overwrite existing installations."
+ ""
+ "Please use `choco upgrade chocolatey` to handle upgrades of Chocolatey itself."
+ ) -join [Environment]::NewLine
+
+ Write-Warning $message
+
+ return
+}
+
+#endregion Pre-check
+
+#region Setup
+
+$proxyConfig = if ($IgnoreProxy -or -not $ProxyUrl) {
+ @{}
+} else {
+ $config = @{
+ ProxyUrl = $ProxyUrl
+ }
+
+ if ($ProxyCredential) {
+ $config['ProxyCredential'] = $ProxyCredential
+ } elseif ($env:chocolateyProxyUser -and $env:chocolateyProxyPassword) {
+ $securePass = ConvertTo-SecureString $env:chocolateyProxyPassword -AsPlainText -Force
+ $config['ProxyCredential'] = [System.Management.Automation.PSCredential]::new($env:chocolateyProxyUser, $securePass)
+ }
+
+ $config
+}
+
+# Attempt to set highest encryption available for SecurityProtocol.
+# PowerShell will not set this by default (until maybe .NET 4.6.x). This
+# will typically produce a message for PowerShell v2 (just an info
+# message though)
+try {
+ # Set TLS 1.2 (3072) as that is the minimum required by Chocolatey.org.
+ # Use integers because the enumeration value for TLS 1.2 won't exist
+ # in .NET 4.0, even though they are addressable if .NET 4.5+ is
+ # installed (.NET 4.5 is an in-place upgrade).
+ Write-Host "Forcing web requests to allow TLS v1.2 (Required for requests to Chocolatey.org)"
+ [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
+}
+catch {
+ $errorMessage = @(
+ 'Unable to set PowerShell to use TLS 1.2. This is required for contacting Chocolatey as of 03 FEB 2020.'
+ 'https://blog.chocolatey.org/2020/01/remove-support-for-old-tls-versions/.'
+ 'If you see underlying connection closed or trust errors, you may need to do one or more of the following:'
+ '(1) upgrade to .NET Framework 4.5+ and PowerShell v3+,'
+ '(2) Call [System.Net.ServicePointManager]::SecurityProtocol = 3072; in PowerShell prior to attempting installation,'
+ '(3) specify internal Chocolatey package location (set $env:chocolateyDownloadUrl prior to install or host the package internally),'
+ '(4) use the Download + PowerShell method of install.'
+ 'See https://docs.chocolatey.org/en-us/choco/setup for all install options.'
+ ) -join [Environment]::NewLine
+ Write-Warning $errorMessage
+}
+
+if ($ChocolateyDownloadUrl) {
+ if ($ChocolateyVersion) {
+ Write-Warning "Ignoring -ChocolateyVersion parameter ($ChocolateyVersion) because -ChocolateyDownloadUrl is set."
+ }
+
+ Write-Host "Downloading Chocolatey from: $ChocolateyDownloadUrl"
+} elseif ($ChocolateyVersion) {
+ Write-Host "Downloading specific version of Chocolatey: $ChocolateyVersion"
+ $ChocolateyDownloadUrl = "https://community.chocolatey.org/api/v2/package/chocolatey/$ChocolateyVersion"
+} else {
+ Write-Host "Getting latest version of the Chocolatey package for download."
+ $queryString = [uri]::EscapeUriString("((Id eq 'chocolatey') and (not IsPrerelease)) and IsLatestVersion")
+ $queryUrl = 'https://community.chocolatey.org/api/v2/Packages()?$filter={0}' -f $queryString
+
+ [xml]$result = Request-String -Url $queryUrl -ProxyConfiguration $proxyConfig
+ $ChocolateyDownloadUrl = $result.feed.entry.content.src
+}
+
+if (-not $env:TEMP) {
+ $env:TEMP = Join-Path $env:SystemDrive -ChildPath 'temp'
+}
+
+$chocoTempDir = Join-Path $env:TEMP -ChildPath "chocolatey"
+$tempDir = Join-Path $chocoTempDir -ChildPath "chocoInstall"
+
+if (-not (Test-Path $tempDir -PathType Container)) {
+ $null = New-Item -Path $tempDir -ItemType Directory
+}
+
+$file = Join-Path $tempDir "chocolatey.zip"
+
+#endregion Setup
+
+#region Download & Extract Chocolatey
+
+Write-Host "Getting Chocolatey from $ChocolateyDownloadUrl."
+Request-File -Url $ChocolateyDownloadUrl -File $file -ProxyConfiguration $proxyConfig
+
+Write-Host "Extracting $file to $tempDir"
+if ($PSVersionTable.PSVersion.Major -lt 5) {
+ # Determine unzipping method
+ # 7zip is the most compatible pre-PSv5.1 so use it unless asked to use builtin
+ if ($UseNativeUnzip) {
+ Write-Host 'Using built-in compression to unzip'
+
+ try {
+ $shellApplication = New-Object -ComObject Shell.Application
+ $zipPackage = $shellApplication.NameSpace($file)
+ $destinationFolder = $shellApplication.NameSpace($tempDir)
+ $destinationFolder.CopyHere($zipPackage.Items(), 0x10)
+ } catch {
+ Write-Warning "Unable to unzip package using built-in compression. Set `$env:chocolateyUseWindowsCompression = ''` or omit -UseNativeUnzip and retry to use 7zip to unzip."
+ throw $_
+ }
+ } else {
+ $7zaExe = Join-Path $tempDir -ChildPath '7za.exe'
+ Install-7zip -Path $7zaExe -ProxyConfiguration $proxyConfig
+
+ $params = 'x -o"{0}" -bd -y "{1}"' -f $tempDir, $file
+
+ # use more robust Process as compared to Start-Process -Wait (which doesn't
+ # wait for the process to finish in PowerShell v3)
+ $process = New-Object System.Diagnostics.Process
+
+ try {
+ $process.StartInfo = New-Object System.Diagnostics.ProcessStartInfo -ArgumentList $7zaExe, $params
+ $process.StartInfo.RedirectStandardOutput = $true
+ $process.StartInfo.UseShellExecute = $false
+ $process.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden
+
+ $null = $process.Start()
+ $process.BeginOutputReadLine()
+ $process.WaitForExit()
+
+ $exitCode = $process.ExitCode
+ }
+ finally {
+ $process.Dispose()
+ }
+
+ $errorMessage = "Unable to unzip package using 7zip. Perhaps try setting `$env:chocolateyUseWindowsCompression = 'true' and call install again. Error:"
+ if ($exitCode -ne 0) {
+ $errorDetails = switch ($exitCode) {
+ 1 { "Some files could not be extracted" }
+ 2 { "7-Zip encountered a fatal error while extracting the files" }
+ 7 { "7-Zip command line error" }
+ 8 { "7-Zip out of memory" }
+ 255 { "Extraction cancelled by the user" }
+ default { "7-Zip signalled an unknown error (code $exitCode)" }
+ }
+
+ throw ($errorMessage, $errorDetails -join [Environment]::NewLine)
+ }
+ }
+} else {
+ Microsoft.PowerShell.Archive\Expand-Archive -Path $file -DestinationPath $tempDir -Force
+}
+
+#endregion Download & Extract Chocolatey
+
+#region Install Chocolatey
+
+Write-Host "Installing Chocolatey on the local machine"
+$toolsFolder = Join-Path $tempDir -ChildPath "tools"
+$chocoInstallPS1 = Join-Path $toolsFolder -ChildPath "chocolateyInstall.ps1"
+
+& $chocoInstallPS1
+
+Write-Host 'Ensuring Chocolatey commands are on the path'
+$chocoInstallVariableName = "ChocolateyInstall"
+$chocoPath = [Environment]::GetEnvironmentVariable($chocoInstallVariableName)
+
+if (-not $chocoPath) {
+ $chocoPath = "$env:ALLUSERSPROFILE\Chocolatey"
+}
+
+if (-not (Test-Path ($chocoPath))) {
+ $chocoPath = "$env:PROGRAMDATA\chocolatey"
+}
+
+$chocoExePath = Join-Path $chocoPath -ChildPath 'bin'
+
+# Update current process PATH environment variable if it needs updating.
+if ($env:Path -notlike "*$chocoExePath*") {
+ $env:Path = [Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine);
+}
+
+Write-Host 'Ensuring chocolatey.nupkg is in the lib folder'
+$chocoPkgDir = Join-Path $chocoPath -ChildPath 'lib\chocolatey'
+$nupkg = Join-Path $chocoPkgDir -ChildPath 'chocolatey.nupkg'
+
+if (-not (Test-Path $chocoPkgDir -PathType Container)) {
+ $null = New-Item -ItemType Directory -Path $chocoPkgDir
+}
+
+Copy-Item -Path $file -Destination $nupkg -Force -ErrorAction SilentlyContinue
+
+#endregion Install Chocolatey
+
+# SIG # Begin signature block
+# MIIZvwYJKoZIhvcNAQcCoIIZsDCCGawCAQExDzANBglghkgBZQMEAgEFADB5Bgor
+# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
+# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBiXTlbpVQOoJeX
+# rGtqATyaDXeEHi6Q2pKb3p02Iq/tc6CCFKgwggT+MIID5qADAgECAhANQkrgvjqI
+# /2BAIc4UAPDdMA0GCSqGSIb3DQEBCwUAMHIxCzAJBgNVBAYTAlVTMRUwEwYDVQQK
+# EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xMTAvBgNV
+# BAMTKERpZ2lDZXJ0IFNIQTIgQXNzdXJlZCBJRCBUaW1lc3RhbXBpbmcgQ0EwHhcN
+# MjEwMTAxMDAwMDAwWhcNMzEwMTA2MDAwMDAwWjBIMQswCQYDVQQGEwJVUzEXMBUG
+# A1UEChMORGlnaUNlcnQsIEluYy4xIDAeBgNVBAMTF0RpZ2lDZXJ0IFRpbWVzdGFt
+# cCAyMDIxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwuZhhGfFivUN
+# CKRFymNrUdc6EUK9CnV1TZS0DFC1JhD+HchvkWsMlucaXEjvROW/m2HNFZFiWrj/
+# ZwucY/02aoH6KfjdK3CF3gIY83htvH35x20JPb5qdofpir34hF0edsnkxnZ2OlPR
+# 0dNaNo/Go+EvGzq3YdZz7E5tM4p8XUUtS7FQ5kE6N1aG3JMjjfdQJehk5t3Tjy9X
+# tYcg6w6OLNUj2vRNeEbjA4MxKUpcDDGKSoyIxfcwWvkUrxVfbENJCf0mI1P2jWPo
+# GqtbsR0wwptpgrTb/FZUvB+hh6u+elsKIC9LCcmVp42y+tZji06lchzun3oBc/gZ
+# 1v4NSYS9AQIDAQABo4IBuDCCAbQwDgYDVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQC
+# MAAwFgYDVR0lAQH/BAwwCgYIKwYBBQUHAwgwQQYDVR0gBDowODA2BglghkgBhv1s
+# BwEwKTAnBggrBgEFBQcCARYbaHR0cDovL3d3dy5kaWdpY2VydC5jb20vQ1BTMB8G
+# A1UdIwQYMBaAFPS24SAd/imu0uRhpbKiJbLIFzVuMB0GA1UdDgQWBBQ2RIaOpLqw
+# Zr68KC0dRDbd42p6vDBxBgNVHR8EajBoMDKgMKAuhixodHRwOi8vY3JsMy5kaWdp
+# Y2VydC5jb20vc2hhMi1hc3N1cmVkLXRzLmNybDAyoDCgLoYsaHR0cDovL2NybDQu
+# ZGlnaWNlcnQuY29tL3NoYTItYXNzdXJlZC10cy5jcmwwgYUGCCsGAQUFBwEBBHkw
+# dzAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuZGlnaWNlcnQuY29tME8GCCsGAQUF
+# BzAChkNodHRwOi8vY2FjZXJ0cy5kaWdpY2VydC5jb20vRGlnaUNlcnRTSEEyQXNz
+# dXJlZElEVGltZXN0YW1waW5nQ0EuY3J0MA0GCSqGSIb3DQEBCwUAA4IBAQBIHNy1
+# 6ZojvOca5yAOjmdG/UJyUXQKI0ejq5LSJcRwWb4UoOUngaVNFBUZB3nw0QTDhtk7
+# vf5EAmZN7WmkD/a4cM9i6PVRSnh5Nnont/PnUp+Tp+1DnnvntN1BIon7h6JGA078
+# 9P63ZHdjXyNSaYOC+hpT7ZDMjaEXcw3082U5cEvznNZ6e9oMvD0y0BvL9WH8dQgA
+# dryBDvjA4VzPxBFy5xtkSdgimnUVQvUtMjiB2vRgorq0Uvtc4GEkJU+y38kpqHND
+# Udq9Y9YfW5v3LhtPEx33Sg1xfpe39D+E68Hjo0mh+s6nv1bPull2YYlffqe0jmd4
+# +TaY4cso2luHpoovMIIFMDCCBBigAwIBAgIQBAkYG1/Vu2Z1U0O1b5VQCDANBgkq
+# hkiG9w0BAQsFADBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5j
+# MRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBB
+# c3N1cmVkIElEIFJvb3QgQ0EwHhcNMTMxMDIyMTIwMDAwWhcNMjgxMDIyMTIwMDAw
+# WjByMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
+# ExB3d3cuZGlnaWNlcnQuY29tMTEwLwYDVQQDEyhEaWdpQ2VydCBTSEEyIEFzc3Vy
+# ZWQgSUQgQ29kZSBTaWduaW5nIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
+# CgKCAQEA+NOzHH8OEa9ndwfTCzFJGc/Q+0WZsTrbRPV/5aid2zLXcep2nQUut4/6
+# kkPApfmJ1DcZ17aq8JyGpdglrA55KDp+6dFn08b7KSfH03sjlOSRI5aQd4L5oYQj
+# ZhJUM1B0sSgmuyRpwsJS8hRniolF1C2ho+mILCCVrhxKhwjfDPXiTWAYvqrEsq5w
+# MWYzcT6scKKrzn/pfMuSoeU7MRzP6vIK5Fe7SrXpdOYr/mzLfnQ5Ng2Q7+S1TqSp
+# 6moKq4TzrGdOtcT3jNEgJSPrCGQ+UpbB8g8S9MWOD8Gi6CxR93O8vYWxYoNzQYIH
+# 5DiLanMg0A9kczyen6Yzqf0Z3yWT0QIDAQABo4IBzTCCAckwEgYDVR0TAQH/BAgw
+# BgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYwEwYDVR0lBAwwCgYIKwYBBQUHAwMweQYI
+# KwYBBQUHAQEEbTBrMCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC5kaWdpY2VydC5j
+# b20wQwYIKwYBBQUHMAKGN2h0dHA6Ly9jYWNlcnRzLmRpZ2ljZXJ0LmNvbS9EaWdp
+# Q2VydEFzc3VyZWRJRFJvb3RDQS5jcnQwgYEGA1UdHwR6MHgwOqA4oDaGNGh0dHA6
+# Ly9jcmw0LmRpZ2ljZXJ0LmNvbS9EaWdpQ2VydEFzc3VyZWRJRFJvb3RDQS5jcmww
+# OqA4oDaGNGh0dHA6Ly9jcmwzLmRpZ2ljZXJ0LmNvbS9EaWdpQ2VydEFzc3VyZWRJ
+# RFJvb3RDQS5jcmwwTwYDVR0gBEgwRjA4BgpghkgBhv1sAAIEMCowKAYIKwYBBQUH
+# AgEWHGh0dHBzOi8vd3d3LmRpZ2ljZXJ0LmNvbS9DUFMwCgYIYIZIAYb9bAMwHQYD
+# VR0OBBYEFFrEuXsqCqOl6nEDwGD5LfZldQ5YMB8GA1UdIwQYMBaAFEXroq/0ksuC
+# MS1Ri6enIZ3zbcgPMA0GCSqGSIb3DQEBCwUAA4IBAQA+7A1aJLPzItEVyCx8JSl2
+# qB1dHC06GsTvMGHXfgtg/cM9D8Svi/3vKt8gVTew4fbRknUPUbRupY5a4l4kgU4Q
+# pO4/cY5jDhNLrddfRHnzNhQGivecRk5c/5CxGwcOkRX7uq+1UcKNJK4kxscnKqEp
+# KBo6cSgCPC6Ro8AlEeKcFEehemhor5unXCBc2XGxDI+7qPjFEmifz0DLQESlE/Dm
+# ZAwlCEIysjaKJAL+L3J+HNdJRZboWR3p+nRka7LrZkPas7CM1ekN3fYBIM6ZMWM9
+# CBoYs4GbT8aTEAb8B4H6i9r5gkn3Ym6hU/oSlBiFLpKR6mhsRDKyZqHnGKSaZFHv
+# MIIFMTCCBBmgAwIBAgIQCqEl1tYyG35B5AXaNpfCFTANBgkqhkiG9w0BAQsFADBl
+# MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
+# d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv
+# b3QgQ0EwHhcNMTYwMTA3MTIwMDAwWhcNMzEwMTA3MTIwMDAwWjByMQswCQYDVQQG
+# EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl
+# cnQuY29tMTEwLwYDVQQDEyhEaWdpQ2VydCBTSEEyIEFzc3VyZWQgSUQgVGltZXN0
+# YW1waW5nIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvdAy7kvN
+# j3/dqbqCmcU5VChXtiNKxA4HRTNREH3Q+X1NaH7ntqD0jbOI5Je/YyGQmL8TvFfT
+# w+F+CNZqFAA49y4eO+7MpvYyWf5fZT/gm+vjRkcGGlV+Cyd+wKL1oODeIj8O/36V
+# +/OjuiI+GKwR5PCZA207hXwJ0+5dyJoLVOOoCXFr4M8iEA91z3FyTgqt30A6XLdR
+# 4aF5FMZNJCMwXbzsPGBqrC8HzP3w6kfZiFBe/WZuVmEnKYmEUeaC50ZQ/ZQqLKfk
+# dT66mA+Ef58xFNat1fJky3seBdCEGXIX8RcG7z3N1k3vBkL9olMqT4UdxB08r8/a
+# rBD13ays6Vb/kwIDAQABo4IBzjCCAcowHQYDVR0OBBYEFPS24SAd/imu0uRhpbKi
+# JbLIFzVuMB8GA1UdIwQYMBaAFEXroq/0ksuCMS1Ri6enIZ3zbcgPMBIGA1UdEwEB
+# /wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgGGMBMGA1UdJQQMMAoGCCsGAQUFBwMI
+# MHkGCCsGAQUFBwEBBG0wazAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuZGlnaWNl
+# cnQuY29tMEMGCCsGAQUFBzAChjdodHRwOi8vY2FjZXJ0cy5kaWdpY2VydC5jb20v
+# RGlnaUNlcnRBc3N1cmVkSURSb290Q0EuY3J0MIGBBgNVHR8EejB4MDqgOKA2hjRo
+# dHRwOi8vY3JsNC5kaWdpY2VydC5jb20vRGlnaUNlcnRBc3N1cmVkSURSb290Q0Eu
+# Y3JsMDqgOKA2hjRodHRwOi8vY3JsMy5kaWdpY2VydC5jb20vRGlnaUNlcnRBc3N1
+# cmVkSURSb290Q0EuY3JsMFAGA1UdIARJMEcwOAYKYIZIAYb9bAACBDAqMCgGCCsG
+# AQUFBwIBFhxodHRwczovL3d3dy5kaWdpY2VydC5jb20vQ1BTMAsGCWCGSAGG/WwH
+# ATANBgkqhkiG9w0BAQsFAAOCAQEAcZUS6VGHVmnN793afKpjerN4zwY3QITvS4S/
+# ys8DAv3Fp8MOIEIsr3fzKx8MIVoqtwU0HWqumfgnoma/Capg33akOpMP+LLR2HwZ
+# YuhegiUexLoceywh4tZbLBQ1QwRostt1AuByx5jWPGTlH0gQGF+JOGFNYkYkh2OM
+# kVIsrymJ5Xgf1gsUpYDXEkdws3XVk4WTfraSZ/tTYYmo9WuWwPRYaQ18yAGxuSh1
+# t5ljhSKMYcp5lH5Z/IwP42+1ASa2bKXuh1Eh5Fhgm7oMLSttosR+u8QlK0cCCHxJ
+# rhO24XxCQijGGFbPQTS2Zl22dHv1VjMiLyI2skuiSpXY9aaOUjCCBTkwggQhoAMC
+# AQICEAq50xD7ISvojIGz0sLozlEwDQYJKoZIhvcNAQELBQAwcjELMAkGA1UEBhMC
+# VVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3LmRpZ2ljZXJ0
+# LmNvbTExMC8GA1UEAxMoRGlnaUNlcnQgU0hBMiBBc3N1cmVkIElEIENvZGUgU2ln
+# bmluZyBDQTAeFw0yMTA0MjcwMDAwMDBaFw0yNDA0MzAyMzU5NTlaMHcxCzAJBgNV
+# BAYTAlVTMQ8wDQYDVQQIEwZLYW5zYXMxDzANBgNVBAcTBlRvcGVrYTEiMCAGA1UE
+# ChMZQ2hvY29sYXRleSBTb2Z0d2FyZSwgSW5jLjEiMCAGA1UEAxMZQ2hvY29sYXRl
+# eSBTb2Z0d2FyZSwgSW5jLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
+# AKFxp42p47c7eHNsNhgxzG+/9A1I8Th+kj40YQJH4Vh0M7a61f39I/FELNYGuyCe
+# 0+z/sg+T+4VmT/JMiI2hc75yokTjkv3Yt1+fqABzCMadr+PZ/9ttIVJ5db3P2Uzc
+# Ml5wXBdCV5ZH/w4oKcP53VmYcHQEDm/RtAJ9TxlPtLS734oAqrKqBmsnJCI98FWp
+# d6z1FK5rv7RJVeZoGsl/2eMcB/ko0Vj9MSCbWvXNjDF9yy4Tl5h2vb+y7K1Qmk3X
+# yb0OYB1ibva9rQozGgogEa5DL0OdoMj6cyJ6Cx2GQv2wjKwiKfs9zCOTDH2VGa0i
+# okDbsd+BvUxovQ6eSnBFj5UCAwEAAaOCAcQwggHAMB8GA1UdIwQYMBaAFFrEuXsq
+# CqOl6nEDwGD5LfZldQ5YMB0GA1UdDgQWBBRO8wUYXZXrKVBqUW35p9FeNJoEgzAO
+# BgNVHQ8BAf8EBAMCB4AwEwYDVR0lBAwwCgYIKwYBBQUHAwMwdwYDVR0fBHAwbjA1
+# oDOgMYYvaHR0cDovL2NybDMuZGlnaWNlcnQuY29tL3NoYTItYXNzdXJlZC1jcy1n
+# MS5jcmwwNaAzoDGGL2h0dHA6Ly9jcmw0LmRpZ2ljZXJ0LmNvbS9zaGEyLWFzc3Vy
+# ZWQtY3MtZzEuY3JsMEsGA1UdIAREMEIwNgYJYIZIAYb9bAMBMCkwJwYIKwYBBQUH
+# AgEWG2h0dHA6Ly93d3cuZGlnaWNlcnQuY29tL0NQUzAIBgZngQwBBAEwgYQGCCsG
+# AQUFBwEBBHgwdjAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuZGlnaWNlcnQuY29t
+# ME4GCCsGAQUFBzAChkJodHRwOi8vY2FjZXJ0cy5kaWdpY2VydC5jb20vRGlnaUNl
+# cnRTSEEyQXNzdXJlZElEQ29kZVNpZ25pbmdDQS5jcnQwDAYDVR0TAQH/BAIwADAN
+# BgkqhkiG9w0BAQsFAAOCAQEAoXGdwcDMMV6xQldozbWoxGTn6chlwO4hJ8aAlwOM
+# wexEvDudrlifsiGI1j46wqc9WR8+Ev8w1dIcbqif4inGIHb8GvL22Goq+lB08F7y
+# YU3Ry0kOCtJx7JELlID0SI7bYndg17TJUQoAb5iTYD9aEoHMIKlGyQyVGvsp4ubo
+# O8CC8Owx+Qq148yXY+to4360U2lzZvUtMpPiiSJTm4BamNgC32xgGwpN5lvk0m3R
+# lDdqQQQgBCzrf+ZIMBmXMw4kxY0r/K/g1TkKI9VyiEnRaNQlQisAyYBWVnaHw2EJ
+# ck6/bxwdYSA+Sz/Op0N0iEl8MX4At3XQlMGvAI1xhAbrwDGCBG0wggRpAgEBMIGG
+# MHIxCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsT
+# EHd3dy5kaWdpY2VydC5jb20xMTAvBgNVBAMTKERpZ2lDZXJ0IFNIQTIgQXNzdXJl
+# ZCBJRCBDb2RlIFNpZ25pbmcgQ0ECEAq50xD7ISvojIGz0sLozlEwDQYJYIZIAWUD
+# BAIBBQCggYQwGAYKKwYBBAGCNwIBDDEKMAigAoAAoQKAADAZBgkqhkiG9w0BCQMx
+# DAYKKwYBBAGCNwIBBDAcBgorBgEEAYI3AgELMQ4wDAYKKwYBBAGCNwIBFTAvBgkq
+# hkiG9w0BCQQxIgQgey25OsHafMX1HWLKRJb0Sf/lMMX5vF0EAhjyQlfUDzgwDQYJ
+# KoZIhvcNAQEBBQAEggEAC0wtyHWaoYbiMY8PXKaNf16zoeuj5jYAuvx0B/nzJ27A
+# tP/Mo9SC1Z4M2iEps/LDScRoy3N8pCI8NQBDjWGGkjW5ScFvF7a042DcurR+LE30
+# aa4d7Y0MT8O+vhQDcVCmB7JB+9E6/7+qpD1vVfs1zYw1cprCZoOejttDCEvlvsAN
+# VrPKixhxbLcLu/5KV9qUBUWW9vEz8/WL1IcNcsfwd61+JWa116CXeyoLKqWXJIPF
+# uNnULZTs/E2BY1JYBKIfzvSi3QWg/uWvJucdGdbLib4d1gEXxLtHk+aDOLTXRG12
+# yjMdCF1FhyeC+hyWSgwyXZ0V9zRGpiS+IjarelHVDqGCAjAwggIsBgkqhkiG9w0B
+# CQYxggIdMIICGQIBATCBhjByMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNl
+# cnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMTEwLwYDVQQDEyhEaWdp
+# Q2VydCBTSEEyIEFzc3VyZWQgSUQgVGltZXN0YW1waW5nIENBAhANQkrgvjqI/2BA
+# Ic4UAPDdMA0GCWCGSAFlAwQCAQUAoGkwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEH
+# ATAcBgkqhkiG9w0BCQUxDxcNMjEwNjE3MDg0MjQzWjAvBgkqhkiG9w0BCQQxIgQg
+# Osdf/2XOopSIGgniCq9vRS6UGDVJ7TingAmrcmwYcWowDQYJKoZIhvcNAQEBBQAE
+# ggEAs50N1tQOpzvCCO9R4hCcaMY0jsOm7QOOk257yySmEFbtgmKUpNmyyfwK0Wl/
+# Ti1IOTOQ1oz7Wz6Q/kEgPoZAbuAhXKH+At6Vwa98Jp3GG6abokNohPI3cWGJbS3u
+# rJEKZay3+1fGNaYOCpIqkhpnVqyTNoLlNBLcGOkq7FgBKsomtQSO9ejFluS1woKY
+# wK7EiXjzDwFG18DmnUuRpO4xrdmcbh7m3MnC95DjYcFFzKr/xxideicJAGZSHOo1
+# nQorVQyPcXQe4Nl2JHAr3R6RTeaXgq6We4LSdMsO5BAyduh/w4nicahwAv5wgIsw
+# cUvCYQiMMXCU2x9vsn8B5wKETQ==
+# SIG # End signature block
diff --git a/helper-iso-files/scripts/disable-mouse-acceleration.ps1 b/helper-iso-files/scripts/disable-mouse-acceleration.ps1
new file mode 100644
index 0000000..f2bb08b
--- /dev/null
+++ b/helper-iso-files/scripts/disable-mouse-acceleration.ps1
@@ -0,0 +1,7 @@
+$code=@'
+[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
+ public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, int[] pvParam, uint fWinIni);
+'@
+Add-Type $code -name Win32 -NameSpace System
+
+[System.Win32]::SystemParametersInfo(4,0,0,2)
\ No newline at end of file
diff --git a/helper-iso-files/scripts/gpu-check.ps1 b/helper-iso-files/scripts/gpu-check.ps1
new file mode 100644
index 0000000..62342ff
--- /dev/null
+++ b/helper-iso-files/scripts/gpu-check.ps1
@@ -0,0 +1,78 @@
+Add-Type -AssemblyName PresentationFramework
+
+#try {
+# choco
+#}
+#catch {
+# Remove-Item C:\ProgramData\chocolatey -Recurse
+# [System.Windows.MessageBox]::Show('Chocolatey installation failed! Make sure the VM has Internet access.', "MobilePassThrough - Error")
+#}
+
+#For formatting:
+ $result = @{Expression = {$_.Name}; Label = "Device Name"},
+ @{Expression = {$_.ConfigManagerErrorCode} ; Label = "Status Code" },
+ @{Expression = {$_.DeviceID} ; Label = "ID" }
+
+$driverlessGpus = Get-WmiObject -Class Win32_PnpEntity -ComputerName localhost -Namespace Root\CIMV2 | Where-Object {$_.ConfigManagerErrorCode -gt 0 } | Format-Table $result -AutoSize | findstr -i "Video Controller" | findstr -i " 28 "
+
+if ($driverlessGpus -like '*VEN_8086*') {
+ Write-Host 'Intel GPU driver missing'
+ try {
+ Write-Host 'Installing the Intel Graphics driver...'
+ choco install intel-graphics-driver
+ #Write-Host 'Automatic GPU driver installation not implemented yet. Please install the Intel Graphics driver manually!'
+ #[System.Windows.MessageBox]::Show('Automatic GPU driver installation not implemented yet. Please install the Intel Graphics driver manually!', "MobilePassThrough - Missing GPU driver")
+ }
+ catch {
+ #If ($Args -ne "unattended") {
+ # [System.Windows.MessageBox]::Show('Failed to automatically install Intel Graphics driver using chocolatey!', "MobilePassThrough - driver installation failed")
+ #}
+ #Write-Host 'Failed to automatically install Intel Graphics driver using chocolatey!'
+ }
+}
+if ($driverlessGpus -like '*VEN_10DE*') {
+ Write-Host 'Nvidia GPU driver missing'
+ try {
+ Write-Host 'Installing the Nvidia Display driver...'
+ choco install nvidia-display-driver
+ #Write-Host 'Automatic GPU driver installation not implemented yet. Please install the Nvidia Display driver manually!'
+ #[System.Windows.MessageBox]::Show('Automatic GPU driver installation not implemented yet. Please install the Nvidia Display driver manually!', "MobilePassThrough - Missing GPU driver")
+ }
+ catch {
+ #If ($Args -ne "unattended") {
+ # [System.Windows.MessageBox]::Show('Failed to automatically install Nvidia Display driver using chocolatey!', "MobilePassThrough - driver installation failed")
+ #}
+ }
+}
+if ($driverlessGpus -like '*VEN_1002*') {
+ Write-Host 'AMD GPU driver missing'
+ Write-Host 'Automatically installing AMD GPU drivers is not supported.'
+
+ If ($Args -ne "unattended") {
+ [System.Windows.MessageBox]::Show("Please install the AMD GPU driver! AMD and Chocolatey unfortunately don't offer a way to do this automatically!", "MobilePassThrough - GPU Driver is missing")
+ }
+}
+
+$driverlessGpus = Get-WmiObject -Class Win32_PnpEntity -ComputerName localhost -Namespace Root\CIMV2 | Where-Object {$_.ConfigManagerErrorCode -gt 0 } | Format-Table $result -AutoSize | findstr -i "Video Controller" | findstr -i " 28 "
+if ($driverlessGpus -like '*VEN_8086*') {
+ Write-Host 'Failed to automatically install Intel Graphics driver using chocolatey!'
+ If ($Args -ne "unattended") {
+ [System.Windows.MessageBox]::Show('Failed to automatically install Intel Graphics driver using chocolatey!', "MobilePassThrough - driver installation failed")
+ }
+}
+if ($driverlessGpus -like '*VEN_10DE*') {
+ Write-Host 'Failed to automatically install Nvidia Display driver using chocolatey!'
+ If ($Args -ne "unattended") {
+ [System.Windows.MessageBox]::Show('Failed to automatically install Nvidia Display driver using chocolatey!', "MobilePassThrough - driver installation failed")
+ }
+}
+
+$error43Devices = Get-WmiObject -Class Win32_PnpEntity -ComputerName localhost -Namespace Root\CIMV2 | Where-Object {$_.ConfigManagerErrorCode -gt 0 } | Format-Table $result -AutoSize | findstr -i "Video Controller" | findstr -i " 43 "
+
+if ($error43Devices) {
+ Write-Host 'Error 43 detected:'
+ Write-Host $error43Devices
+ If ($Args -ne "unattended") {
+ [System.Windows.MessageBox]::Show($error43Devices, "MobilePassThrough - Detected Error 43")
+ }
+}
diff --git a/helper-iso-files/scripts/mbpt-startup.bat b/helper-iso-files/scripts/mbpt-startup.bat
new file mode 100644
index 0000000..ae08cc4
--- /dev/null
+++ b/helper-iso-files/scripts/mbpt-startup.bat
@@ -0,0 +1 @@
+powershell -executionpolicy unrestricted -file %APPDATA%\mbpt\gpu-check.ps1
\ No newline at end of file
diff --git a/helper-iso-files/scripts/network-check.ps1 b/helper-iso-files/scripts/network-check.ps1
new file mode 100644
index 0000000..895bb08
--- /dev/null
+++ b/helper-iso-files/scripts/network-check.ps1
@@ -0,0 +1,53 @@
+Add-Type -AssemblyName PresentationFramework
+
+function wait-for-network ($tries) {
+ while (1) {
+ # Get a list of DHCP-enabled interfaces that have a
+ # non-$null DefaultIPGateway property.
+ $x = gwmi -class Win32_NetworkAdapterConfiguration `
+ -filter DHCPEnabled=TRUE |
+ where { $_.DefaultIPGateway -ne $null }
+
+ # If there is (at least) one available, exit the loop.
+ if ( ($x | measure).count -gt 0 ) {
+ #[System.Windows.MessageBox]::Show("Network connection established!", "MobilePassThrough")
+ Write-Host "Network connection established!"
+ break
+ }
+
+ # If $tries > 0 and we have tried $tries times without
+ # success, throw an exception.
+ if ( $tries -gt 0 -and $try++ -ge $tries ) {
+ Write-Host "Network unavaiable after $try tries."
+ [System.Windows.MessageBox]::Show("Network unavaiable after $try tries.", "MobilePassThrough")
+ throw "Network unavaiable after $try tries."
+ }
+
+ # Wait one second.
+ start-sleep -s 1
+ }
+}
+
+function wait-for-chocolatey ($tries) {
+ while (1) {
+ if ( $tries -gt 0 -and $try++ -ge $tries ) {
+ Write-Host "chocolatey.org unavaiable after $try tries."
+ [System.Windows.MessageBox]::Show("chocolatey.org unavaiable after $try tries.", "MobilePassThrough")
+ throw "chocolatey.org unavaiable after $try tries."
+ }
+ if ((Test-Connection -Quiet chocolatey.org)) {
+ Write-Host "chocolatey.org is reachable!"
+ break
+ }
+ start-sleep -s 1
+ }
+}
+
+Write-Host "Waiting for a network connection. Waiting up to 60 seconds..."
+wait-for-network 60
+
+Write-Host "Setting the Network to private..."
+Set-NetConnectionProfile -Name "Network" -NetworkCategory Private
+
+Write-Host "Waiting for chocoltey.org to be reachable. Waiting up to 30 seconds..."
+wait-for-chocolatey 30
\ No newline at end of file
diff --git a/helper-iso-files/start.bat b/helper-iso-files/start.bat
deleted file mode 100644
index f37f2c8..0000000
--- a/helper-iso-files/start.bat
+++ /dev/null
@@ -1,31 +0,0 @@
-cd /D %~dp0
-
-echo "Installing required Visual C++ Redistributable Package..."
-.\bin\VC_redist.x64.exe /install /passive /norestart
-
-echo "Install Looking Glass to Program Files ..."
-:: mkdir "%ProgramFiles%\LookingGlass"
-:: xcopy /s ".\bin\looking-glass-host.exe" "%ProgramFiles%\LookingGlass\looking-glass-host.exe"
-.\bin\looking-glass-host-setup.exe /S
-
-echo "MobilePassThrough Helper, Register Looking Glass as a startup application..."
-reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "LookingGlass" /t REG_SZ /f /d "%ProgramFiles%\Looking Glass (host)\looking-glass-host.exe -f"
-
-echo "Install vfio drivers..."
-%WINDIR%\system32\pnputil.exe /add-driver .\bin\virtio-drivers\Win10\amd64\*.inf /subdirs /install
-
-echo "Set static IP for vfio network device..."
-:: TODO: Find the correct network adapter name
-netsh int ip set address "Ethernet" static 192.168.99.2 255.255.255.0 192.168.99.1 1
-netsh int ip set dns "Ethernet" static 192.168.99.1 primary
-:: netsh int ip set address "Local Area Connection" static 192.168.99.2 255.255.255.0 192.168.99.1 1
-:: netsh int ip set dns "Local Area Connection" static 192.168.99.1 primary
-
-:: echo "Change the virtual Ethernet adapter to a private one to allow RDP access..."
-:: powershell -command Set-NetConnectionProfile -Name "Network" -NetworkCategory Private
-
-echo "Enable remote desktop..."
-reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
-netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
-
-pause
diff --git a/live-iso-files/get-mbpt.sh b/live-iso-files/get-mbpt.sh
new file mode 100755
index 0000000..19ceb74
--- /dev/null
+++ b/live-iso-files/get-mbpt.sh
@@ -0,0 +1,83 @@
+#!/usr/bin/env bash
+
+echo "> Disabling sleep and force keeping the screen on..."
+sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
+gsettings set org.gnome.desktop.session idle-delay 0
+
+printf "%s" "> Waiting for a device supporting big files with at least 60Gb of free storage to be mounted ..."
+REQUIRED_DISK_SPACE=60 #Gigabytes
+MBPT_BASE_PATH=""
+while sleep 1; do
+ printf "%c" "."
+ devices="$(sudo df --output=avail,target -B 1G 2> /dev/null | sed 's/^ *//')"
+ while IFS= read -r deviceLine; do
+ availableSpace=$(echo "$deviceLine" | cut -d' ' -f1)
+ mountpoint="$(echo "$deviceLine" | cut -d' ' -f2-)"
+ if [ -d "${mountpoint}/mbpt/MobilePassThrough" ]; then
+ MBPT_BASE_PATH="$(echo "${mountpoint}/mbpt" | tr -s '/')"
+ break
+ elif [[ $availableSpace -ge $REQUIRED_DISK_SPACE ]]; then
+ # Test if the device can handle big files (FAT32 for example can't)
+ #if sudo fallocate -l "${REQUIRED_DISK_SPACE}G" "${mountpoint}/size_test.bin" &> /dev/null; then
+ if sudo dd if=/dev/zero of="${mountpoint}/size_test.bin" bs="${REQUIRED_DISK_SPACE}G" seek=60 count=0 &> /dev/null; then
+ sudo rm -f "${mountpoint}/_size_test.bin"
+ MBPT_BASE_PATH="$(echo "${mountpoint}/mbpt" | tr -s '/')"
+ break
+ #else
+ # echo "> Device mounted at '$mountpoint' doesn't support big files"
+ fi
+ fi
+ done <<< "$devices"
+ if [ "$MBPT_BASE_PATH" != "" ]; then
+ break
+ fi
+done
+printf "\n%s\n" "> Device found! Files will be stored under: $MBPT_BASE_PATH"
+sudo mkdir -p "$MBPT_BASE_PATH"
+sudo chown "$(logname):$(id -gn "$(logname)")" "$MBPT_BASE_PATH"
+cd "$MBPT_BASE_PATH"
+
+if [ ! -d "${MBPT_BASE_PATH}/MobilePassThrough" ]; then
+ printf "%s" "> Waiting for an Internet connection ..."
+ while ! timeout 5 ping -c 1 -n github.com &> /dev/null; do
+ printf "%c" "."
+ sleep 1
+ done
+ printf "\n%s\n" "> Connected!"
+
+ requiredDomains="github.com mirrors.fedoraproject.org fedorapeople.org developer.nvidia.com tb.rg-adguard.net software-download.microsoft.com download.microsoft.com chocolatey.org" # www.techpowerup.com
+
+ for domain in $requiredDomains; do
+ printf "%s" "> Waiting for $domain to be available ..."
+ while ! timeout 5 ping -c 1 -n $domain &> /dev/null; do
+ printf "%c" "."
+ sleep 1
+ done
+ printf "\n%s\n" "> $domain is available!"
+ done
+
+ if ! command -v git &> /dev/null; then
+ echo "> Installing git..."
+ sudo dnf install -y git
+ fi
+
+ echo "> Downloading the MobilePassThrough project..."
+ git clone -b "unattended-win-install" https://github.com/T-vK/MobilePassThrough.git
+else
+ echo "[Skipped] MobilePassThrough appears to have been set up already in a previous boot."
+fi
+
+cd MobilePassThrough
+echo "> Running MobilePassThrough compatibility check..."
+./mbpt.sh check
+if [ $? -eq 0 ]; then
+ echo "> Waiting for 10 seconds before continuing..."
+ sleep 10
+else
+ echo "> Waiting for 30 seconds before continuing..."
+ sleep 30
+fi
+echo "> Starting MobilePassThrough in auto mode..."
+./mbpt.sh auto
+
+$SHELL
\ No newline at end of file
diff --git a/live-iso-files/mbpt.desktop b/live-iso-files/mbpt.desktop
new file mode 100644
index 0000000..3ce7d6c
--- /dev/null
+++ b/live-iso-files/mbpt.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Name=MobilePassThrough
+Exec=/usr/bin/gnome-terminal --maximize -- /home/liveuser/get-mbpt.sh
+Terminal=false
+Type=Application
+StartupNotify=true
+NoDisplay=true
+X-GNOME-Autostart-enabled=true
\ No newline at end of file
diff --git a/mbpt.sh b/mbpt.sh
index b71d966..979e818 100755
--- a/mbpt.sh
+++ b/mbpt.sh
@@ -1,11 +1,11 @@
#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}"
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-USER_SCRIPTS_DIR="${PROJECT_DIR}/scripts"
+#####################################################################################################
+# This is the only script that you should really care about as a user of MobilePassThrough.
+# Usage: `./mbpt.sh --help`
+#####################################################################################################
COMMAND="$1"
@@ -17,14 +17,19 @@ function printHelp() {
echo ''
echo 'Options:'
echo ' -h, --help Print usage'
- echo ' -v, --version Print version information'
echo ''
echo 'Commands:'
- echo ' setup Install required dependencies and set required kernel parameters'
- echo ' check Check if and to what degree your notebook is capable of running a GPU passthrough setup'
+ echo ' auto Automatically run check, setup and install'
echo ' configure Interactively guides you through the creation of your config file'
- echo ' iso Generate a helper iso file that contains required drivers and a helper-script for your Windows VM'
- echo ' start Start your VM'
+ echo ' check Check if and to what degree your notebook is capable of running a GPU passthrough setup'
+ echo ' setup Install required dependencies and set required kernel parameters'
+ echo ' install Create and install the VM'
+ echo ' start Start the VM'
+ echo ' live Create / Flash a Live ISO image of this project'
+ # TODO: Split start/install in pre-start, start/install, post-start ()
+ # TODO implement:
+ #echo ' get-xml Print out the VM configuration as XML'
+ #echo ' get-qemu Print out the VM configuration as a qemu-system-x86_64 command'
echo ' vbios Dump the vBIOS ROM from the running system or extract it from a BIOS update'
echo ''
echo 'Examples:'
@@ -40,9 +45,30 @@ function printHelp() {
echo ' # Generate a helper iso file that contains required drivers and a helper-script for your Windows VM'
echo ' mbpt.sh iso'
echo ''
- echo ' # Start your VM'
+ echo ' # Create the VM and install Windows in it (Will overwrite an older instance if one exists!)'
+ echo ' mbpt.sh install'
+ echo ''
+ echo ' # Start the VM'
echo ' mbpt.sh start'
echo ''
+ echo ' # Create a Live ISO'
+ echo ' mbpt.sh live buid'
+ echo ''
+ echo ' # Flash a Live ISO to the USB drive /dev/sdx'
+ echo ' mbpt.sh live flash /dev/sdx'
+ echo ''
+ echo ' # Print the qemu command that would have been used to start the VM'
+ echo ' mbpt.sh start dry-run'
+ echo ''
+ echo ' # Print the qemu command that would have been used to install the VM'
+ echo ' mbpt.sh install dry-run'
+ echo ''
+ echo ' # Print the libvirt XML that would have been used to start the VM'
+ echo ' mbpt.sh start get-xml'
+ echo ''
+ echo ' # Print the libvirt XML that would have been used to install the VM'
+ echo ' mbpt.sh install get-xml'
+ echo ''
echo ' # Dump the vBIOS ROM of the GPU with the PCI address 01:00.0 to ./my-vbios.rom (This will most likely fail)'
echo ' mbpt.sh vbios dump 01:00.0 ./my-vbios.rom'
echo ''
@@ -54,22 +80,43 @@ function printHelp() {
if [ "$COMMAND" = "help" ] || [ "$COMMAND" = "--help" ] || [ "$COMMAND" = "-h" ] || [ "$COMMAND" = "" ]; then
printHelp
elif [ "$COMMAND" = "setup" ]; then
- sudo "${USER_SCRIPTS_DIR}/setup.sh"
+ sudo "${MAIN_SCRIPTS_DIR}/setup.sh"
elif [ "$COMMAND" = "check" ]; then
- sudo "${USER_SCRIPTS_DIR}/compatibility-check.sh"
+ sudo "${MAIN_SCRIPTS_DIR}/compatibility-check.sh"
elif [ "$COMMAND" = "configure" ]; then
- "${USER_SCRIPTS_DIR}/generate-vm-config.sh"
-elif [ "$COMMAND" = "iso" ]; then
- "${USER_SCRIPTS_DIR}/generate-helper-iso.sh"
+ "${MAIN_SCRIPTS_DIR}/generate-vm-config.sh"
+elif [ "$COMMAND" = "helper-iso" ]; then
+ "${MAIN_SCRIPTS_DIR}/generate-helper-iso.sh"
+elif [ "$COMMAND" = "install" ] || [ "$COMMAND" = "create" ]; then
+ sudo "${MAIN_SCRIPTS_DIR}/vm.sh" install $2
+elif [ "$COMMAND" = "remove" ]; then
+ sudo "${MAIN_SCRIPTS_DIR}/vm.sh" remove
elif [ "$COMMAND" = "start" ]; then
- sudo "${USER_SCRIPTS_DIR}/start-vm.sh"
+ sudo "${MAIN_SCRIPTS_DIR}/vm.sh" start $2
+elif [ "$COMMAND" = "live" ]; then
+ sudo "${MAIN_SCRIPTS_DIR}/generate-live-iso.sh" "$2" "$3"
+elif [ "$COMMAND" = "auto" ]; then
+ #sudo "${MAIN_SCRIPTS_DIR}/compatibility-check.sh"
+ sudo "${MAIN_SCRIPTS_DIR}/setup.sh" auto
+ if [ $? -eq 0 ]; then
+ sudo "${MAIN_SCRIPTS_DIR}/iommu-check.sh"
+ if [ $? -eq 0 ]; then
+ sudo "${MAIN_SCRIPTS_DIR}/vm.sh" auto
+ else
+ echo "Exiting..."
+ exit 1
+ fi
+ else
+ echo "Exiting..."
+ exit 1
+ fi
elif [ "$COMMAND" = "vbios" ]; then
- if [ "$2" == "extract" ] ; then
+ if [ "$2" == "extract" ]; then
mkdir -p "$4/"
- cd "${PROJECT_DIR}/thirdparty/VBiosFinder"
+ cd "${THIRDPARTY_DIR}/VBiosFinder"
./vbiosfinder extract "$(readlink -f "$3")"
- mv "${PROJECT_DIR}/thirdparty/VBiosFinder/output/*" "$4/"
- elif [ "$2" == "dump" ] ; then
- sudo "${UTILS_DIR}/extract-vbios" "$3" "$4"
+ mv "${THIRDPARTY_DIR}/VBiosFinder/output/*" "$4/"
+ elif [ "$2" == "dump" ]; then
+ sudo "${COMMON_UTILS_SETUP_DIR}/extract-vbios" "$3" "$4"
fi
-fi
\ No newline at end of file
+fi
diff --git a/requirements.sh b/requirements.sh
new file mode 100644
index 0000000..97925c9
--- /dev/null
+++ b/requirements.sh
@@ -0,0 +1,83 @@
+#####################################################################################################
+# This file is supposed to be `source`d by the `scripts/main/setup.sh` bash script.
+# It specifies which executables and files and kernel parameters which part of this project depends on
+# WARNING: File dependencies can't contain spaces at the moment
+# Usage: `source ./requirements.sh`
+#####################################################################################################
+
+# TODO: #sudo dnf install -y msr-tools tunctl # TODO: check if these are still needed and if so what for
+
+# TODO: check if there even is a case where is would be necessary
+#INITRAMFS_DRIVERS=("vfio_virqfd" "vfio_pci" "vfio_iommu_type1" "addInitramfsDriver" "vfio") #vfio stub drivers
+
+# Docs: https://www.kernel.org/doc/Documentation/admin-guide/kernel-parameters.txt
+# More docs: https://lwn.net/Articles/252826/
+# https://www.kernel.org/doc/Documentation/x86/x86_64/boot-options.txt
+KERNEL_PARAMS_GENERAL=("iommu=1") # '1' is not a documented option. stop confusing me wendell! Maybe the "force" option should be used instead?
+KERNEL_PARAMS_GENERAL+=("kvm.ignore_msrs=1") # prevent bluescreens when a VM does MSR reads / writes directly
+KERNEL_PARAMS_GENERAL+=("rd.driver.pre=vfio-pci") # tell dracut to load vfio-pci first
+#KERNEL_PARAMS_GENERAL+=("pcie_acs_override=downstream") # fix /dev/vfio/1 not found error # shouldn't be necessary
+#KERNEL_PARAMS_GENERAL+=("acpi_osi=!") # may fix problems with AMI style UEFIs
+#KERNEL_PARAMS_GENERAL+=("acpi_osi='Windows 2009'") # may fix problems with AMI style UEFIs
+KERNEL_PARAMS_INTEL_CPU=("intel_iommu=on") # enable Intel VT-D ;# using "intel_iommu=on,igfx_off" iGPU gets no iommu group...
+#KERNEL_PARAMS_INTEL_CPU+=("915.preliminary_hw_support=1") # add skylake support; probably only necessary with older kernels
+KERNEL_PARAMS_AMD_CPU=("amd_iommu=on") # 'on' is not a docuemnted option for this parameter either! This is insanely confusing!
+KERNEL_PARAMS_INTEL_GPU=("i915.enable_gvt=1") # enable mediated iGPU passthrough support (GVT-g) on Intel iGPUs
+#KERNEL_PARAMS_AMD_GPU=()
+#KERNEL_PARAMS_NVIDIA_GPU=()
+#KERNEL_PARAMS_BUMBLEBEE_NVIDIA=("nouveau.modeset=0")
+
+
+# TODO: check if we should use relative paths to be more distribution-gnostic
+#EXEC_DEPS_GENERAL=("sudo" "bash" "mv" "cp" "sed" "awk" "git" "echo" "ls" "echo" "printf" "cd" "mkdir" "chmod" "chown" "grep" "cut" "which")
+EXEC_DEPS_FAKE_BATTERY=("iasl") # acpica-tools
+EXEC_DEPS_OVMF_VBIOS_PATCH=("git" "docker") # git moby-engine
+EXEC_DEPS_GENERATE_CONFIG=("crudini") # crudini
+EXEC_DEPS_VBIOS_FINDER=("git" "wget" "curl" "unzip" "ruby" "gem" "bundle" "7za" "make" "innoextract" "upx") # git wget curl-minimal unzip ruby rubygems rubygem-bundler p7zip make innoextract upx
+FILE_DEPS_VBIOS_FINDER=("/usr/include/rub*/ruby.h") # ruby-devel
+EXEC_DEPS_VIRTUALIZATION=("qemu-system-x86_64" "virsh" "virt-viewer" "virt-install" "spicy" "socat" "fdisk" "dd" "nmap" "driverctl" ) # qemu-system-x86-core libvirt-client virt-viewer virt-install spice-gtk-tools socat coreutils util-linux nmap driverctl
+FILE_DEPS_VIRTUALIZATION=("/usr/share/OVMF/OVMF_CODE.fd" "/usr/share/OVMF/OVMF_VARS.fd" "/usr/share/libvirt/networks/default.xml") # edk2-ovmf libvirt-daemon-config-network
+EXEC_DEPS_RDP=("remmina") # remmina
+EXEC_DEPS_SAMBA=("samba") # samba
+EXEC_DEPS_IGPU_PASSTHROUGH=("uuid" "intel-virtual-output") # uuid xorg-x11-drv-intel
+EXEC_DEPS_HELPER_ISO=("genisoimage") # genisoimage
+EXEC_DEPS_UEFI_CHECK=("systool") # sysfsutils
+EXEC_DEPS_COMPATIBILITY_CHECK=("systool" "lshw" "lspci") # sysfsutils lshw pciutils dmidecode
+EXEC_DEPS_CPU_CHECK=("lscpu") # util-linux
+EXEC_DEPS_GPU_CHECK=("lshw") # lshw
+EXEC_DEPS_LOOKING_GLASS=("cmake" "gcc" "wayland-scanner" "makensis" "x86_64-w64-mingw32-g++") # cmake gcc-g++ wayland-devel mingw32-nsis mingw64-gcc-c++
+FILE_DEPS_LOOKING_GLASS+=("/usr/include/bfd.h" "/usr/lib64/libbfd.a" "/usr/lib64/libiberty.a") # binutils-devel
+FILE_DEPS_LOOKING_GLASS+=("/usr/include/fontconfig/fontconfig.h") # fontconfig-devel
+FILE_DEPS_LOOKING_GLASS+=("/usr/include/spice-1/spice/protocol.h" "/usr/include/spice-1/spice/vd_agent.h" "") # spice-protocol
+FILE_DEPS_LOOKING_GLASS+=("/usr/include/X11/Xlib.h" "/usr/include/X11/Xutil.h") # libX11-devel
+FILE_DEPS_LOOKING_GLASS+=("/usr/include/nettle/asn1.h" "/usr/include/nettle/sha1.h" "/usr/include/nettle/rsa.h" "/usr/include/nettle/bignum.h") # nettle-devel
+FILE_DEPS_LOOKING_GLASS+=("/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml" "/usr/share/wayland-protocols/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml" "/usr/share/wayland-protocols/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml" "/usr/share/wayland-protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml") # wayland-protocols-devel
+FILE_DEPS_LOOKING_GLASS+=("/usr/lib/gcc/x86_64-redhat-linux/*/include/stdatomic.h" "/usr/lib/gcc/x86_64-redhat-linux/*/include/emmintrin.h" "/usr/lib/gcc/x86_64-redhat-linux/*/include/smmintrin.h" "/usr/lib/gcc/x86_64-redhat-linux/*/include/stdarg.h" "/usr/lib/gcc/x86_64-redhat-linux/*/include/stdbool.h" "/usr/lib/gcc/x86_64-redhat-linux/*/include/stddef.h" "/usr/lib/gcc/x86_64-redhat-linux/*/include/stdint.h") # gcc
+FILE_DEPS_LOOKING_GLASS+=("/usr/include/X11/extensions/scrnsaver.h") # libXScrnSaver-devel
+FILE_DEPS_LOOKING_GLASS+=("/usr/include/X11/extensions/Xfixes.h") # libXfixes-devel
+FILE_DEPS_LOOKING_GLASS+=("/usr/include/X11/extensions/XInput2.h") # libXi-devel
+FILE_DEPS_LOOKING_GLASS+=("/usr/include/wayland-client.h" "/usr/include/wayland-cursor.h" "/usr/include/wayland-egl.h") # wayland-devel
+FILE_DEPS_LOOKING_GLASS+=("/usr/include/X11/extensions/Xinerama.h") # libXinerama-devel
+FILE_DEPS_LOOKING_GLASS+=("/usr/include/SDL2/SDL.h" "/usr/include/SDL2/SDL_syswm.h") # SDL2-devel (will be removed in B5 probably)
+FILE_DEPS_LOOKING_GLASS+=("/usr/include/SDL2/SDL_ttf.h") # SDL2_ttf-devel (will be removed in B5 probably)
+#FILE_DEPS_LOOKING_GLASS+=("/usr/share/texlive/texmf-dist/fonts/opentype/public/gnu-freefont/FreeMono.otf") # this file is not actually a dependency # texlive-gnu-freefont # TODO: check if texlive-gnu-freefont is actually a dependency
+EXEC_DEPS_LIVE_ISO+=("wget" "xorriso" "mksquashfs" "unsquashfs") # wget xorriso squashfs-tools
+#############################################################################################################################
+
+ALL_EXEC_DEPS="" # Will contain all content of all variables starting with EXEC_DEPS
+ALL_EXEC_DEPS_VARS="$(set -o posix ; set | grep -P '^EXEC_DEPS' | cut -d'=' -f1 | tr '\n' ' ')"
+for deps in $ALL_EXEC_DEPS_VARS; do
+ ALL_EXEC_DEPS+="$(eval "echo \" \${$deps[*]}\"")"
+done
+
+ALL_FILE_DEPS="" # Will contain all content of all variables starting with FILE_DEPS
+ALL_FILE_DEPS_VARS="$(set -o posix ; set | grep -P '^FILE_DEPS' | cut -d'=' -f1 | tr '\n' ' ')"
+for deps in $ALL_FILE_DEPS_VARS; do
+ ALL_FILE_DEPS+="$(eval "echo \" \${$deps[*]}\"")"
+done
+
+ALL_KERNEL_PARAMS="" # Will contain all content of all variables starting with KERNEL_PARAMS
+ALL_KERNEL_PARAMS_VARS="$(set -o posix ; set | grep -P '^KERNEL_PARAMS' | cut -d'=' -f1 | tr '\n' ' ')"
+for params in $ALL_KERNEL_PARAMS_VARS; do
+ ALL_KERNEL_PARAMS+="$(eval "echo \" \${$params[*]}\"")"
+done
diff --git a/scripts/README.md b/scripts/README.md
new file mode 100644
index 0000000..c6d0b24
--- /dev/null
+++ b/scripts/README.md
@@ -0,0 +1,16 @@
+```
+scripts # All bash scripts called directly or indirectly by `mbpt.sh`. (Some scripts may also be installed in the `thirdparty` directory or may straight up be system dependencies installed using your package manager.)
+├── main # Scripts that can be called directly or by running `mbpt.sh`. They work on any Linux distribution, given that a corresponding `utils/distro-specific/{DISTRIBUTION}/{VERSION}` directory with its scripts exists.
+└── utils # Scripts that are used by other scripts in this project.
+ ├── common # Scripts that work on any Linux distribution, given that a corresponding `utils/distro-specific/{DISTRIBUTION}/{VERSION}` directory with its scripts exists.
+ │ ├── libs # Scripts that are not executable and have to be `source`d.
+ │ ├── setup # Scripts that have dependencies on other scripts (or programs in the `thirdparty` directory) in this project.
+ │ └── tools # Scripts that don't have dependencies on other files in this project and could be moved into their own project at some point.
+ ├── manager-specific # Scripts that are specific to a certain manager like systemd, dracut or grub. This is used to abstract functionality like creating services, adding kernel parameters and adding drivers to initfsram.
+ └── distro-specific # Scripts that are distribution-specific. For every distribution/version the exact same set of scripts
+ ├── Fedora # All `Fedora`-specific scripts.
+ │ ├── 34 # All `Fedora 34`-specific scripts.
+ │ └── 35 # All `Fedora 35`-specific scripts.
+ └── Ubuntu # All `Ubuntu`-specific scripts.
+ └── 21.04 # All `Ubuntu 21.04`-specific scripts.
+```
\ No newline at end of file
diff --git a/scripts/compatibility-check.sh b/scripts/compatibility-check.sh
deleted file mode 100755
index 63f6950..0000000
--- a/scripts/compatibility-check.sh
+++ /dev/null
@@ -1,237 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="$(readlink -f "${SCRIPT_DIR}/..")"
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-LOG_BASE_DIR="${PROJECT_DIR}/logs"
-
-# Enable these to mock the lshw output and iommu groups of other computers for testing purposes
-#MOCK_SET=1
-#LSHW_MOCK="${SCRIPT_DIR}/mock-data/$MOCK_SET-lshw"
-#LSIOMMU_MOCK="${SCRIPT_DIR}/mock-data/$MOCK_SET-lsiommu"
-
-if sudo which optirun &> /dev/null && sudo optirun echo>/dev/null ; then
- USE_BUMBLEBEE=true
- OPTIRUN_PREFIX="optirun "
-else
- USE_BUMBLEBEE=false
- OPTIRUN_PREFIX=""
-fi
-
-if [ -z ${LSIOMMU_MOCK+x} ]; then
- IOMMU_GROUPS=$(sudo ${OPTIRUN_PREFIX}${UTILS_DIR}/lsiommu)
- MOCK_MODE=false
-else
- IOMMU_GROUPS=$(cat "${LSIOMMU_MOCK}")
- MOCK_MODE=true
-fi
-
-if [ -z ${LSHW_MOCK+x} ]; then
- GPU_INFO=$(sudo lshw -class display -businfo)
-else
- GPU_INFO=$(cat "${LSHW_MOCK}")
-fi
-
-LOG_OUTPUT=""
-function log() {
- LOG_OUTPUT="${LOG_OUTPUT}$@\n"
-}
-
-NC='\033[0m' # No Color
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-ORANGE='\033[1;33m'
-
-function log_red() {
- echo -e "${RED}$@${NC}"
- log "$@"
-}
-function log_green() {
- echo -e "${GREEN}$@${NC}"
- log "$@"
-}
-function log_orange() {
- echo -e "${ORANGE}$@${NC}"
- log "$@"
-}
-function log_white() {
- echo -e "$@"
-}
-
-if [ "$MOCK_MODE" = true ]; then
- log_red "[Warning] Using mock data! The following output has nothing to do with this system!"
-fi
-
-# Check if UEFI is configured correctly
-if systool -m kvm_intel -v &> /dev/null || systool -m kvm_amd -v &> /dev/null ; then
- UEFI_VIRTUALIZATION_ENABLED=true
- log_green "[OK] VT-X / AMD-V virtualization is enabled in the UEFI."
-else
- UEFI_VIRTUALIZATION_ENABLED=false
- log_orange "[Warning] VT-X / AMD-V virtualization is not enabled in the UEFI! This is required to run virtual machines!"
-fi
-
-if [ "$IOMMU_GROUPS" != "" ] ; then
- UEFI_IOMMU_ENABLED=true
- log_green "[OK] VT-D / IOMMU is enabled in the UEFI."
-else
- UEFI_IOMMU_ENABLED=false
- log_red "[Error] VT-D / IOMMU is not enabled in the UEFI! This is required to check which devices are in which IOMMU group and to use GPU passthrough!"
-fi
-
-# Check if kernel is configured correctly
-if cat /proc/cmdline | grep --quiet iommu ; then
- KERNEL_IOMMU_ENABLED=true
- log_green "[OK] The IOMMU kernel parameters are set."
-else
- KERNEL_IOMMU_ENABLED=false
- log_red "[Error] The iommu kernel parameters are missing! You have to add them in roder to use GPU passthrough!"
-fi
-
-GPU_IDS=($(echo "${GPU_INFO}" | grep "pci@" | cut -d " " -f 1 | cut -d ":" -f 2-))
-
-GOOD_GPUS=()
-BAD_GPUS=()
-for GPU_ID in "${GPU_IDS[@]}"; do
- GPU_IOMMU_GROUP=$(echo "${IOMMU_GROUPS}" | grep "${GPU_ID}" | cut -d " " -f 3)
-
- if [ "$GPU_IOMMU_GROUP" == "" ] ; then
- log_red "[Error] Failed to find the IOMMU group of the GPU with the ID ${GPU_ID}! Have you enabled iommu in the UEFI and kernel?"
- else
- OTHER_DEVICES_IN_GPU_GROUP=$(echo "${IOMMU_GROUPS}" | grep "IOMMU Group ${GPU_IOMMU_GROUP} " | grep -v ${GPU_ID} | grep -v " Audio device " | grep -v " PCI bridge ")
- OTHER_DEVICES_IN_GPU_GROUP_NO_GPUS=$(echo "${OTHER_DEVICES_IN_GPU_GROUP}" | grep -v " VGA compatible controller " | grep -v " 3D controller ")
-
- if [ "$OTHER_DEVICES_IN_GPU_GROUP" == "" ] ; then
- log_green "[Success] GPU with ID '${GPU_ID}' could be passed through to a virtual machine!"
- GOOD_GPUS+=("$GPU_ID")
- elif [ "$OTHER_DEVICES_IN_GPU_GROUP_NO_GPUS" = "" ] ; then
- log_orange "[Warning] GPU with ID '${GPU_ID}' could be passed through to a virtual machine, but only together with the following devices: "
- log_orange "${OTHER_DEVICES_IN_GPU_GROUP}"
- GOOD_GPUS+=("${GPU_ID}")
- else
- log_orange "[Problem] Other devices have been found in the IOMMU group of the GPU with the ID '${GPU_ID}'. Depending on the devices, this could make it impossible to pass this GPU through to a virtual machine!"
- log_orange "The devices found in this GPU's IOMMU Group are:"
- log_red "${OTHER_DEVICES_IN_GPU_GROUP}"
- log_white "[Info] It might be possible to get it to work by putting the devices in different slots on the motherboard and/or by using the ACS override patch. Otherwise you'll probably have to get a different motherboard. If you're on a laptop, there is nothing you can do as far as I'm aware. Although it would theoretically be possible for ACS support for laptops to exist. TODO: Find a way to check if the current machine has support for that."
- BAD_GPUS+=("${GPU_ID}")
- fi
- fi
-done
-
-GPU_LIST="Is Compatible?|Name|IOMMU_GROUP|PCI Address"
-
-for GPU_ID in "${BAD_GPUS[@]}"; do
- PCI_ADDRESS="pci@0000:${GPU_ID}"
- NAME=$(echo "${GPU_INFO}" | grep "${GPU_ID}" | tr -s " " | cut -d " " -f 3-)
- IOMMU_GROUP=$(echo "${IOMMU_GROUPS}" | grep ${GPU_ID} | cut -d " " -f 3)
- GPU_LIST="${GPU_LIST}\nNo|${NAME}|${IOMMU_GROUP}|${PCI_ADDRESS}"
-done
-
-for GPU_ID in "${GOOD_GPUS[@]}"; do
- PCI_ADDRESS="pci@0000:${GPU_ID}"
- NAME=$(echo "${GPU_INFO}" | grep "${GPU_ID}" | tr -s " " | cut -d " " -f 3-)
- IOMMU_GROUP=$(echo "${IOMMU_GROUPS}" | grep "${GPU_ID}" | cut -d " " -f 3)
- GPU_LIST="${GPU_LIST}\nYes|${NAME}|${IOMMU_GROUP}|${PCI_ADDRESS}"
-done
-
-IOMMU_COMPATIBILITY_LVL=0 # 0: no GPUs to pass through; 1: at least 1 GPU for pt, but no GPU for host left; 2: at least one GPU for pt and at least one GPU for host left
-
-if [ "${#GOOD_GPUS[@]}" == "0" ] ; then
- if [ "${#GPU_IDS[@]}" == "0" ] ; then
- log_red "[Warning] Failed to find any GPUs! Assuning this is correct, GPU passthrough is obviously impossible on this system in the current configuration!"
- else
- log_red "[Warning] This script was not able to identify a GPU in this that could be passed through to a VM!"
- fi
-else
- log_green "[Success] There are ${#GOOD_GPUS[@]} GPU(s) in this system that could be passed through to a VM!"
-
- log_white ""
- GPU_LIST=$(echo -e "${GPU_LIST}" | column -t -s'|')
- while read -r line; do
- if echo "${line}" | grep --quiet Yes ; then
- log_green "${line}"
- elif echo "${line}" | grep --quiet No ; then
- log_red "${line}"
- else
- log_orange "${line}"
- fi
- done <<< "${GPU_LIST}"
- log_white ""
-
- if [ ${#GOOD_GPUS[@]} != 1 ] && grep -qE '^([0-9]+)( \1)*$' <<< $(echo $(echo "${IOMMU_GROUPS}" | grep -E $(echo "${GOOD_GPUS[@]}" | tr ' ' '|') | cut -d " " -f 3)) ; then
- if [ ${#BAD_GPUS[@]} == 0 ] ; then
- IOMMU_COMPATIBILITY_LVL=1
- log_orange "[Warning] All GPUs in this system are in the same IOMMU group. This would make GPU passthrough difficult (not impossible) because your host machine would be left without a GPU!"
- else
- IOMMU_COMPATIBILITY_LVL=2
- log_green "[Warning] Some of your GPUs are in the same IOMMU group. This means they could only be passed through together. You could still use a GPU that's in another group for your host system. (E.g. the one with the PCI address 'pci@0000:'${BAD_GPUS[0]} "
- fi
- else
- if [ "${#GPU_IDS[@]}" == "1" ] ; then
- IOMMU_COMPATIBILITY_LVL=1
- log_orange "[Warning] Only 1 GPU found! (Counting all GPUs, not just dedicated ones.) This would make GPU passthrough difficult (not impossible) because your host machine would be left without a GPU!"
- else
- IOMMU_COMPATIBILITY_LVL=2
- log_green "[OK] You have GPUs that are not in the same IOMMU group. At least one of these could be passed through to a VM and at least one of the remaining ones could be used for the host system."
- fi
- fi
-fi
-
-
-# If the device is a laptop
-#if [ "$(sudo ${OPTIRUN_PREFIX}dmidecode --string chassis-type)" != "Desktop" ] ; then
- DEVICE_NAME=$(sudo ${OPTIRUN_PREFIX}dmidecode -s system-product-name)
- BIOS_VERSION=$(sudo ${OPTIRUN_PREFIX}dmidecode -s bios-version)
- LOG_DIR="${LOG_BASE_DIR}/$DEVICE_NAME/$BIOS_VERSION"
- DATE=`date +%Y-%m-%d`
- mkdir -p "${LOG_DIR}"
-
- log_white "[Info] Device name: $DEVICE_NAME"
- log_white "[Info] BIOS version: $BIOS_VERSION"
-
- if [ $(echo $IOMMU_GROUPS | grep " VGA compatible controller " | wc -l) = "2" ] && ! echo $IOMMU_GROUPS | grep --quiet " Display controller " ; then
- log_white "[Info] This system is probably MUXed. (The connection between the GPU(s) and the [internal display]/[display outputs] is multiplexed.)"
- else
- log_white "[Info] This system is probably MUX-less. (The connection between the GPU(s) and the [internal display]/[display outputs] is not multiplexed.)"
- fi
-
-
-
- echo ${DATE} > "${LOG_DIR}/date.log"
- echo "${IOMMU_GROUPS}" > "${LOG_DIR}/lsiommu.log"
- sudo ${OPTIRUN_PREFIX}dmidecode > "${LOG_DIR}/dmidecode.log"
- sudo ${OPTIRUN_PREFIX}dmesg > "${LOG_DIR}/dmesg.log"
- sudo ${OPTIRUN_PREFIX}lshw > "${LOG_DIR}/lshw.log"
- sudo ${OPTIRUN_PREFIX}lshw -short > "${LOG_DIR}/lshw-short.log"
- sudo ${OPTIRUN_PREFIX}lshw -class display -businfo > "${LOG_DIR}/lshw-gpu-businfo.log"
- sudo ${OPTIRUN_PREFIX}lspci > "${LOG_DIR}/lspci.log"
- sudo ${OPTIRUN_PREFIX}lsusb > "${LOG_DIR}/lsusb.log"
- sudo ${OPTIRUN_PREFIX}lsblk > "${LOG_DIR}/lsblk.log"
- sudo ${OPTIRUN_PREFIX}lscpu > "${LOG_DIR}/lscpu.log"
- sudo ${OPTIRUN_PREFIX}dmidecode -t bios > "${LOG_DIR}/bios.log"
- sudo ${OPTIRUN_PREFIX}cat /proc/cpuinfo > "${LOG_DIR}/cpuinfo.log"
- sudo ${OPTIRUN_PREFIX}cat /proc/meminfo > "${LOG_DIR}/meminfo.log"
- log_green "[OK] Logs have been created in ${LOG_DIR}"
- echo -e ${LOG_OUTPUT} > "${LOG_DIR}/general.log"
-#fi
-
-if [ "${UEFI_VIRTUALIZATION_ENABLED}" = true ] && [ "${UEFI_IOMMU_ENABLED}" = true ] && [ "${KERNEL_IOMMU_ENABLED}" = true ] && [ "${IOMMU_COMPATIBILITY_LVL}" -gt "0" ] ; then
- log_green "If you found a notebook that appears to be GPU passthrough compatible, please open an issue on Github and let me know."
- if [ "${IOMMU_COMPATIBILITY_LVL}" -gt "1" ] ; then
- log_green "You may now proceed and run './mbpt.sh configure' as mentioned in the README."
- fi
-fi
-
-
-#echo "Listing IOMMU Groups..."
-#${SCRIPT_DIR}/utils/lsiommu
-
-#echo "Listing GPU info with lshw..."
-#sudo lshw -class display
-
-#if [ -n ${MOCK_SET+x} ]; then
-if [ "$MOCK_MODE" = true ]; then
- log_red "[Warning] Remember, the above output has been generated using the given mock data and has nothing to do with this system!"
-fi
diff --git a/scripts/generate-helper-iso.sh b/scripts/generate-helper-iso.sh
deleted file mode 100755
index a51cce3..0000000
--- a/scripts/generate-helper-iso.sh
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="$(readlink -f "${SCRIPT_DIR}/..")"
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-
-if [ -f "${PROJECT_DIR}/user.conf" ]; then
- echo "> Loading config from ${PROJECT_DIR}/user.conf"
- source "${PROJECT_DIR}/user.conf"
-elif [ -f "${PROJECT_DIR}/default.conf" ]; then
- echo "> Warning: No user.conf found, falling back to default.conf"
- echo "> Loading config from ${PROJECT_DIR}/default.conf"
- source "${PROJECT_DIR}/default.conf"
-else
- echo "> Error: No user.conf or user.conf found!"
- exit
-fi
-
-mkdir -p "${PROJECT_DIR}/helper-iso-files/bin"
-#if [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/AutoHotkeyU64.exe" ]; then
-# echo "> Downloading AutoHotkey..."
-# rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
-# mkdir -p "${PROJECT_DIR}/helper-iso-files/tmp"
-# wget "https://autohotkey.com/download/ahk.zip" -O "${PROJECT_DIR}/helper-iso-files/tmp/ahk.zip"
-# unzip "${PROJECT_DIR}/helper-iso-files/tmp/ahk.zip" -d "${PROJECT_DIR}/helper-iso-files/tmp/"
-# echo "> Adding AutoHotkey to iso folder..."
-# cp "${PROJECT_DIR}/helper-iso-files/tmp/AutoHotkeyU64.exe" "${PROJECT_DIR}/helper-iso-files/bin/"
-# rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
-#else
-# echo "> AutoHotkey already exist in iso folder..."
-#fi
-
-if [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/VC_redist.x64.exe" ]; then
- echo "> Downloading Visual C++ Redistributable Package 2017 x64 for the Looking Glass Host application..."
- wget "https://download.microsoft.com/download/8/9/D/89D195E1-1901-4036-9A75-FBE46443FC5A/VC_redist.x64.exe" -O "${PROJECT_DIR}/helper-iso-files/bin/VC_redist.x64.exe"
-else
- echo "> Visual C++ Redistributable Package 2017 x64 already exist in iso folder..."
-fi
-
-if [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/looking-glass-host-setup.exe" ]; then
- #echo "> Downloading Looking Glass Host application..."
- #wget "https://github.com/gnif/LookingGlass/releases/download/${LOOKING_GLASS_VERSION}/looking-glass-host.exe" -O "${PROJECT_DIR}/helper-iso-files/bin/looking-glass-host.exe"
- echo "> Copy Looking Glass Host application setup to where we need it..."
- cp "${PROJECT_DIR}/thirdparty/LookingGlass/platform/Windows/looking-glass-host-setup.exe" "${PROJECT_DIR}/helper-iso-files/bin/looking-glass-host-setup.exe"
-else
- echo "> Looking Glass Host application already exist in iso folder..."
-fi
-
-#if [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver/ivshmem.cat" ] || [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver/ivshmem.inf" ] || [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver/ivshmem.pdb" ] || [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver/ivshmem.sys" ]; then
-# echo "> Downloading IVSHMEM driver..."
-# rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
-# mkdir -p "${PROJECT_DIR}/helper-iso-files/tmp"
-# wget "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/upstream-virtio/virtio-win10-prewhql-0.1-161.zip" -O "${PROJECT_DIR}/helper-iso-files/tmp/virtio-win10-prewhql.zip"
-# unzip "${PROJECT_DIR}/helper-iso-files/tmp/virtio-win10-prewhql.zip" -d "${PROJECT_DIR}/helper-iso-files/tmp"
-# rm -f "${PROJECT_DIR}/helper-iso-files/tmp/virtio-win10-prewhql.zip"
-# rm -rf "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver"
-# mkdir -p "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver"
-# cp "${PROJECT_DIR}/helper-iso-files/tmp/Win10/amd64/ivshmem*" "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver/"
-# #cp -r "${PROJECT_DIR}/helper-iso-files/tmp" "${PROJECT_DIR}/helper-iso-files/bin/ivshmem-driver"
-# rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
-#else
-# echo "> IVSHMEM driver already exist in iso folder..."
-#fi
-
-if [ ! -d "${PROJECT_DIR}/helper-iso-files/bin/virtio-drivers/Win10" ]; then
- echo "> Downloading virtio drivers..."
- rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
- mkdir -p "${PROJECT_DIR}/helper-iso-files/tmp"
- wget "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/upstream-virtio/virtio-win10-prewhql-0.1-161.zip" -O "${PROJECT_DIR}/helper-iso-files/tmp/virtio-win10-prewhql.zip"
- mkdir -p "${PROJECT_DIR}/helper-iso-files/bin/virtio-drivers"
- unzip "${PROJECT_DIR}/helper-iso-files/tmp/virtio-win10-prewhql.zip" -d "${PROJECT_DIR}/helper-iso-files/bin/virtio-drivers"
- rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
-else
- echo "> virtio drivers already exist in iso folder..."
-fi
-
-#if [ ! -f "${PROJECT_DIR}/helper-iso-files/bin/devcon.exe" ]; then
-# echo "> Downloading Microsoft's devcon driver tool..."
-# rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
-# mkdir -p "${PROJECT_DIR}/helper-iso-files/tmp"
-# wget "https://download.microsoft.com/download/B/5/8/B58D625D-17D6-47A8-B3D3-668670B6D1EB/wdk/Installers/787bee96dbd26371076b37b13c405890.cab" -O "${PROJECT_DIR}/helper-iso-files/tmp/devcon.cab"
-# cabextract -d "${PROJECT_DIR}/helper-iso-files/tmp" "${PROJECT_DIR}/helper-iso-files/tmp/devcon.cab"
-# cp "${PROJECT_DIR}/helper-iso-files/tmp/devcon.cab" "${PROJECT_DIR}/helper-iso-files/bin/devcon.exe"
-# #TODO: check if installing the cabextract is necessary or if it actually is devcon directly
-# rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
-#else
-# echo "> devcon driver tool already exist in iso folder..."
-#fi
-
-rm -rf "${PROJECT_DIR}/helper-iso-files/tmp"
-
-echo "> Generating new iso..."
-rm -f "${HELPER_ISO}"
-echo "genisoimage -J -joliet-long -r -allow-lowercase -allow-multidot -o \"${HELPER_ISO}\" \"${PROJECT_DIR}/helper-iso-files\""
-genisoimage -J -joliet-long -r -allow-lowercase -allow-multidot -o "${HELPER_ISO}" "${PROJECT_DIR}/helper-iso-files"
diff --git a/scripts/main/compatibility-check.sh b/scripts/main/compatibility-check.sh
new file mode 100755
index 0000000..62df12e
--- /dev/null
+++ b/scripts/main/compatibility-check.sh
@@ -0,0 +1,210 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+
+#####################################################################################################
+# This script checks the device it's executed on for GPU passthrough compatibility and prints a detailed report to the terminal.
+#####################################################################################################
+
+# Enable these to mock the lshw output and iommu groups of other computers for testing purposes
+#MOCK_SET=1
+#LSHW_MOCK="${PROJECT_DIR}/mock-data/$MOCK_SET-lshw"
+#LSIOMMU_MOCK="${PROJECT_DIR}/mock-data/$MOCK_SET-lsiommu"
+
+source "${PROJECT_DIR}/requirements.sh"
+
+if sudo which optirun &> /dev/null && sudo optirun echo>/dev/null ; then
+ USE_BUMBLEBEE=true
+ OPTIRUN_PREFIX="optirun "
+else
+ USE_BUMBLEBEE=false
+ OPTIRUN_PREFIX=""
+fi
+
+alias updatePkgInfo="'${PACKAGE_MANAGER}' update"
+alias getExecPkg="'${PACKAGE_MANAGER}' install --executables"
+alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables"
+alias lsiommu="sudo '${OPTIRUN_PREFIX}${COMMON_UTILS_TOOLS_DIR}/lsiommu'"
+
+MISSING_DEPS=$(getMissingExecutables "${EXEC_DEPS_COMPATIBILITY_CHECK[*]}")
+if [ "$MISSING_DEPS" != "" ]; then
+ echo_white "[Info] Update package info..."
+ updatePkgInfo
+ echo_white "[Info] Trying to install packages providing: $MISSING_DEPS ..."
+ getExecPkg "${EXEC_DEPS_COMPATIBILITY_CHECK[*]}" # Find and install packages needed to run this check
+fi
+MISSING_DEPS=$(getMissingExecutables "${EXEC_DEPS_COMPATIBILITY_CHECK[*]}")
+if [ "$MISSING_DEPS" != "" ]; then
+ echo_red "[Error] Failed to install packages providing: $MISSING_DEPS"
+ echo_red "[Info] Please install them manually and try again!"
+ exit 1
+fi
+
+if [ -z ${LSIOMMU_MOCK+x} ]; then
+ IOMMU_GROUPS=$(lsiommu)
+ MOCK_MODE=false
+else
+ IOMMU_GROUPS=$(cat "${LSIOMMU_MOCK}")
+ MOCK_MODE=true
+fi
+
+if [ -z ${LSHW_MOCK+x} ]; then
+ GPU_INFO=$(sudo lshw -class display -businfo)
+else
+ GPU_INFO=$(cat "${LSHW_MOCK}")
+fi
+
+if [ "$MOCK_MODE" = true ]; then
+ echo_red "[Warning] Using mock data! The following output has nothing to do with this system!"
+fi
+
+# Check if kernel is configured correctly
+if cat /proc/cmdline | grep --quiet iommu ; then
+ KERNEL_IOMMU_ENABLED=true
+ echo_green "[OK] The IOMMU kernel parameters are set."
+else
+ KERNEL_IOMMU_ENABLED=false
+ echo_red "[Error] The iommu kernel parameters are missing! You have to add them in order to use GPU passthrough!"
+fi
+
+# Check if UEFI is configured correctly
+if systool -m kvm_intel -v &> /dev/null || systool -m kvm_amd -v &> /dev/null ; then
+ UEFI_VIRTUALIZATION_ENABLED=true
+ echo_green "[OK] VT-X / AMD-V virtualization is enabled in the UEFI."
+else
+ UEFI_VIRTUALIZATION_ENABLED=false
+ echo_orange "[Warning] VT-X / AMD-V virtualization is not enabled in the UEFI! This feature is required to run virtual machines!"
+fi
+
+if [ "$IOMMU_GROUPS" != "" ] ; then
+ UEFI_IOMMU_ENABLED=true
+ echo_green "[OK] VT-D / IOMMU is enabled in the UEFI."
+else
+ if [ "${KERNEL_IOMMU_ENABLED}" = true ] ; then
+ UEFI_IOMMU_ENABLED=false
+ echo_red "[Error] VT-D / IOMMU is not enabled in the UEFI! This feature is required to check which devices are in which IOMMU group and to use GPU passthrough!"
+ else
+ echo_orange "[Warning] VT-D / IOMMU might possibly not enabled in the UEFI. This feature is required to check which devices are in which IOMMU group and to use GPU passthrough!"
+ fi
+fi
+
+GPU_IDS=($(echo "${GPU_INFO}" | grep "pci@" | cut -d " " -f 1 | cut -d ":" -f 2-))
+
+GOOD_GPUS=()
+BAD_GPUS=()
+for GPU_ID in "${GPU_IDS[@]}"; do
+ GPU_IOMMU_GROUP=$(echo "${IOMMU_GROUPS}" | grep "${GPU_ID}" | cut -d " " -f 3)
+
+ if [ "$GPU_IOMMU_GROUP" == "" ] ; then # Compensate for Intel iGPUs sometimes not having an IOMMU group at all
+ GPU_NAME="$(lspci -s "${GPU_ID}" | cut -d' ' -f2-)"
+ if echo "${GPU_NAME}" | grep --quiet "Intel"; then
+ GPU_IOMMU_GROUP="N/A"
+ IOMMU_GROUPS+=$'\n'"IOMMU GROUP N/A ${GPU_ID} ${GPU_NAME}"
+ fi
+ fi
+
+ if [ "$GPU_IOMMU_GROUP" == "" ] ; then
+ echo_red "[Error] Failed to find the IOMMU group of the GPU with the ID ${GPU_ID}! Have you enabled iommu in the UEFI and kernel?"
+ else
+ OTHER_DEVICES_IN_GPU_GROUP=$(echo "${IOMMU_GROUPS}" | grep "IOMMU Group ${GPU_IOMMU_GROUP} " | grep -v ${GPU_ID} | grep -v " Audio device " | grep -v " PCI bridge ")
+ OTHER_DEVICES_IN_GPU_GROUP_NO_GPUS=$(echo "${OTHER_DEVICES_IN_GPU_GROUP}" | grep -v " VGA compatible controller " | grep -v " 3D controller ")
+
+ if [ "$OTHER_DEVICES_IN_GPU_GROUP" == "" ] ; then
+ echo_green "[Success] GPU with ID '${GPU_ID}' could be passed through to a virtual machine!"
+ GOOD_GPUS+=("$GPU_ID")
+ elif [ "$OTHER_DEVICES_IN_GPU_GROUP_NO_GPUS" = "" ] ; then
+ echo_orange "[Warning] GPU with ID '${GPU_ID}' could be passed through to a virtual machine, but only together with the following devices: "
+ echo_orange "${OTHER_DEVICES_IN_GPU_GROUP}"
+ GOOD_GPUS+=("${GPU_ID}")
+ else
+ echo_orange "[Problem] Other devices have been found in the IOMMU group of the GPU with the ID '${GPU_ID}'. Depending on the devices, this could make it impossible to pass this GPU through to a virtual machine!"
+ echo_orange "The devices found in this GPU's IOMMU Group are:"
+ echo_red "${OTHER_DEVICES_IN_GPU_GROUP}"
+ echo_white "[Info] It might be possible to get it to work by putting the devices in different slots on the motherboard and/or by using the ACS override patch. Otherwise you'll probably have to get a different motherboard. If you're on a laptop, there is nothing you can do as far as I'm aware. Although it would theoretically be possible for ACS support for laptops to exist. TODO: Find a way to check if the current machine has support for that."
+ BAD_GPUS+=("${GPU_ID}")
+ fi
+ fi
+done
+
+GPU_LIST="Is Compatible?|Name|IOMMU_GROUP|PCI Address"
+
+for GPU_ID in "${BAD_GPUS[@]}"; do
+ PCI_ADDRESS="pci@0000:${GPU_ID}"
+ NAME=$(echo "${GPU_INFO}" | grep "${GPU_ID}" | tr -s " " | cut -d " " -f 3-)
+ IOMMU_GROUP=$(echo "${IOMMU_GROUPS}" | grep ${GPU_ID} | cut -d " " -f 3)
+ GPU_LIST="${GPU_LIST}\nNo|${NAME}|${IOMMU_GROUP}|${PCI_ADDRESS}"
+done
+
+for GPU_ID in "${GOOD_GPUS[@]}"; do
+ PCI_ADDRESS="pci@0000:${GPU_ID}"
+ NAME=$(echo "${GPU_INFO}" | grep "${GPU_ID}" | tr -s " " | cut -d " " -f 3-)
+ IOMMU_GROUP=$(echo "${IOMMU_GROUPS}" | grep "${GPU_ID}" | cut -d " " -f 3)
+ GPU_LIST="${GPU_LIST}\nYes|${NAME}|${IOMMU_GROUP}|${PCI_ADDRESS}"
+done
+
+IOMMU_COMPATIBILITY_LVL=0 # 0: no GPUs to pass through; 1: at least 1 GPU for pt, but no GPU for host left; 2: at least one GPU for pt and at least one GPU for host left
+
+if [ "${#GOOD_GPUS[@]}" == "0" ] ; then
+ if [ "${#GPU_IDS[@]}" == "0" ] ; then
+ echo_red "[Warning] Failed to find any GPUs! Assuning this is correct, GPU passthrough is obviously impossible on this system in the current configuration!"
+ else
+ echo_red "[Warning] This script was not able to identify a GPU in this that could be passed through to a VM!"
+ fi
+else
+ echo_green "[Success] There are ${#GOOD_GPUS[@]} GPU(s) in this system that could be passed through to a VM!"
+
+ echo_white ""
+ GPU_LIST=$(echo -e "${GPU_LIST}" | column -t -s'|')
+ while read -r line; do
+ if echo "${line}" | grep --quiet Yes ; then
+ echo_green "${line}"
+ elif echo "${line}" | grep --quiet No ; then
+ echo_red "${line}"
+ else
+ echo_orange "${line}"
+ fi
+ done <<< "${GPU_LIST}"
+ echo_white ""
+
+ if [ ${#GOOD_GPUS[@]} != 1 ] && grep -qE '^([0-9]+)( \1)*$' <<< $(echo $(echo "${IOMMU_GROUPS}" | grep -E $(echo "${GOOD_GPUS[@]}" | tr ' ' '|') | cut -d " " -f 3)) ; then
+ if [ ${#BAD_GPUS[@]} == 0 ] ; then
+ IOMMU_COMPATIBILITY_LVL=1
+ echo_orange "[Warning] All GPUs in this system are in the same IOMMU group. This would make GPU passthrough difficult (not impossible) because your host machine would be left without a GPU!"
+ else
+ IOMMU_COMPATIBILITY_LVL=2
+ echo_green "[Warning] Some of your GPUs are in the same IOMMU group. This means they could only be passed through together. You could still use a GPU that's in another group for your host system. (E.g. the one with the PCI address 'pci@0000:'${BAD_GPUS[0]} "
+ fi
+ else
+ if [ "${#GPU_IDS[@]}" == "1" ] ; then
+ IOMMU_COMPATIBILITY_LVL=1
+ echo_orange "[Warning] Only 1 GPU found! (Counting all GPUs, not just dedicated ones.) This would make GPU passthrough difficult (not impossible) because your host machine would be left without a GPU!"
+ else
+ IOMMU_COMPATIBILITY_LVL=2
+ echo_green "[OK] You have GPUs that are not in the same IOMMU group. At least one of these could be passed through to a VM and at least one of the remaining ones could be used for the host system."
+ fi
+ fi
+fi
+
+# If the device is a laptop
+#if [ "$(sudo ${OPTIRUN_PREFIX}dmidecode --string chassis-type)" != "Desktop" ] ; then
+ if [ $(echo $IOMMU_GROUPS | grep " VGA compatible controller " | wc -l) = "2" ] && ! echo $IOMMU_GROUPS | grep --quiet " Display controller " ; then
+ echo_white "[Info] This system is probably MUXed. (The connection between the GPU(s) and the [internal display]/[display outputs] is multiplexed.)"
+ else
+ echo_white "[Info] This system is probably MUX-less. (The connection between the GPU(s) and the [internal display]/[display outputs] is not multiplexed.)"
+ fi
+#fi
+
+if [ "$MOCK_MODE" = true ]; then
+ echo_red "[Warning] Remember, the above output has been generated using the given mock data and has nothing to do with this system!"
+fi
+
+if [ "${UEFI_VIRTUALIZATION_ENABLED}" = true ] && [ "${UEFI_IOMMU_ENABLED}" = true ] && [ "${KERNEL_IOMMU_ENABLED}" = true ] && [ "${IOMMU_COMPATIBILITY_LVL}" -gt "0" ] ; then
+ echo_green "If you found a notebook that appears to be GPU passthrough compatible, please open an issue on Github and let me know."
+ if [ "${IOMMU_COMPATIBILITY_LVL}" -gt "1" ] ; then
+ echo_green "You may now proceed and run './mbpt.sh configure' if you haven't already."
+ else
+ exit 1
+ fi
+else
+ exit 1
+fi
diff --git a/scripts/main/generate-helper-iso.sh b/scripts/main/generate-helper-iso.sh
new file mode 100755
index 0000000..b20b119
--- /dev/null
+++ b/scripts/main/generate-helper-iso.sh
@@ -0,0 +1,107 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+loadConfig
+#####################################################################################################
+# This script creates a helper ISO file containing scripts and drivers to fully automate the Windows installation within the VM.
+#####################################################################################################
+
+mkdir -p "${HELPER_ISO_FILES_DIR}/bin"
+mkdir -p "${HELPER_ISO_FILES_DIR}/scripts"
+#if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/AutoHotkeyU64.exe" ]; then
+# echo "> Downloading AutoHotkey..."
+# rm -rf "${HELPER_ISO_FILES_DIR}/tmp"
+# mkdir -p "${HELPER_ISO_FILES_DIR}/tmp"
+# wget "https://autohotkey.com/download/ahk.zip" -O "${HELPER_ISO_FILES_DIR}/tmp/ahk.zip"
+# unzip "${HELPER_ISO_FILES_DIR}/tmp/ahk.zip" -d "${HELPER_ISO_FILES_DIR}/tmp/"
+# echo "> Adding AutoHotkey to iso folder..."
+# cp "${HELPER_ISO_FILES_DIR}/tmp/AutoHotkeyU64.exe" "${HELPER_ISO_FILES_DIR}/bin/"
+# rm -rf "${HELPER_ISO_FILES_DIR}/tmp"
+#else
+# echo "> AutoHotkey already exist in iso folder..."
+#fi
+
+if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/VC_redist.x64.exe" ]; then
+ echo "> Downloading Visual C++ Redistributable Package 2017 x64 for the Looking Glass Host application..."
+ wget "https://download.microsoft.com/download/8/9/D/89D195E1-1901-4036-9A75-FBE46443FC5A/VC_redist.x64.exe" -O "${HELPER_ISO_FILES_DIR}/bin/VC_redist.x64.exe"
+else
+ echo "> Visual C++ Redistributable Package 2017 x64 already exist in iso folder..."
+fi
+
+if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/spice-guest-tools.exe" ]; then
+ echo "> Downloading Spice Guest Tools..."
+ wget "https://www.spice-space.org/download/windows/spice-guest-tools/spice-guest-tools-0.141/spice-guest-tools-0.141.exe" -O "${HELPER_ISO_FILES_DIR}/bin/spice-guest-tools.exe"
+else
+ echo "> Spice Guest Tools already exists in iso folder..."
+fi
+
+if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/spice-webdavd.msi" ]; then
+ echo "> Downloading Spice WebDAV daemon..."
+ wget "https://www.spice-space.org/download/windows/spice-webdavd/spice-webdavd-x64-2.4.msi" -O "${HELPER_ISO_FILES_DIR}/bin/spice-webdavd.msi"
+else
+ echo "> Spice WebDAV daemon already exists in iso folder..."
+fi
+
+if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/looking-glass-host-setup.exe" ]; then
+ #echo "> Downloading Looking Glass Host application..."
+ #wget "https://github.com/gnif/LookingGlass/releases/download/${LOOKING_GLASS_VERSION}/looking-glass-host.exe" -O "${HELPER_ISO_FILES_DIR}/bin/looking-glass-host.exe"
+ echo "> Copy Looking Glass Host application setup to where we need it..."
+ cp "${PROJECT_DIR}/thirdparty/LookingGlass/platform/Windows/looking-glass-host-setup.exe" "${HELPER_ISO_FILES_DIR}/bin/looking-glass-host-setup.exe"
+else
+ echo "> Looking Glass Host application already exist in iso folder..."
+fi
+
+#if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver/ivshmem.cat" ] || [ ! -f "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver/ivshmem.inf" ] || [ ! -f "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver/ivshmem.pdb" ] || [ ! -f "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver/ivshmem.sys" ]; then
+# echo "> Downloading IVSHMEM driver..."
+# rm -rf "${HELPER_ISO_FILES_DIR}/tmp"
+# mkdir -p "${HELPER_ISO_FILES_DIR}/tmp"
+# wget "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/upstream-virtio/virtio-win10-prewhql-0.1-161.zip" -O "${HELPER_ISO_FILES_DIR}/tmp/virtio-win10-prewhql.zip"
+# unzip "${HELPER_ISO_FILES_DIR}/tmp/virtio-win10-prewhql.zip" -d "${HELPER_ISO_FILES_DIR}/tmp"
+# rm -f "${HELPER_ISO_FILES_DIR}/tmp/virtio-win10-prewhql.zip"
+# rm -rf "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver"
+# mkdir -p "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver"
+# cp "${HELPER_ISO_FILES_DIR}/tmp/Win10/amd64/ivshmem*" "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver/"
+# #cp -r "${HELPER_ISO_FILES_DIR}/tmp" "${HELPER_ISO_FILES_DIR}/bin/ivshmem-driver"
+# rm -rf "${HELPER_ISO_FILES_DIR}/tmp"
+#else
+# echo "> IVSHMEM driver already exist in iso folder..."
+#fi
+
+if [ ! -d "${HELPER_ISO_FILES_DIR}/bin/virtio-drivers/Win10" ]; then
+ echo "> Downloading virtio drivers..."
+ rm -rf "${HELPER_ISO_FILES_DIR}/tmp"
+ mkdir -p "${HELPER_ISO_FILES_DIR}/tmp"
+ wget "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/upstream-virtio/virtio-win10-prewhql-0.1-161.zip" -O "${HELPER_ISO_FILES_DIR}/tmp/virtio-win10-prewhql.zip"
+ mkdir -p "${HELPER_ISO_FILES_DIR}/bin/virtio-drivers"
+ unzip "${HELPER_ISO_FILES_DIR}/tmp/virtio-win10-prewhql.zip" -d "${HELPER_ISO_FILES_DIR}/bin/virtio-drivers"
+ rm -rf "${HELPER_ISO_FILES_DIR}/tmp"
+else
+ echo "> virtio drivers already exist in iso folder..."
+fi
+
+#if [ ! -f "${HELPER_ISO_FILES_DIR}/bin/devcon.exe" ]; then
+# echo "> Downloading Microsoft's devcon driver tool..."
+# rm -rf "${HELPER_ISO_FILES_DIR}/tmp"
+# mkdir -p "${HELPER_ISO_FILES_DIR}/tmp"
+# wget "https://download.microsoft.com/download/B/5/8/B58D625D-17D6-47A8-B3D3-668670B6D1EB/wdk/Installers/787bee96dbd26371076b37b13c405890.cab" -O "${HELPER_ISO_FILES_DIR}/tmp/devcon.cab"
+# cabextract -d "${HELPER_ISO_FILES_DIR}/tmp" "${HELPER_ISO_FILES_DIR}/tmp/devcon.cab"
+# cp "${HELPER_ISO_FILES_DIR}/tmp/devcon.cab" "${HELPER_ISO_FILES_DIR}/bin/devcon.exe"
+# #TODO: check if installing the cabextract is necessary or if it actually is devcon directly
+# rm -rf "${HELPER_ISO_FILES_DIR}/tmp"
+#else
+# echo "> devcon driver tool already exist in iso folder..."
+#fi
+
+if [ ! -f "${HELPER_ISO_FILES_DIR}/scripts/chocolatey-install.ps1" ]; then
+ echo "> Downloading Chocolatey install script..."
+ wget "https://chocolatey.org/install.ps1" -O "${HELPER_ISO_FILES_DIR}/scripts/chocolatey-install.ps1"
+else
+ echo "> Chocolatey install script already exist in iso folder..."
+fi
+
+rm -rf "${HELPER_ISO_FILES_DIR}/tmp"
+
+rm -f "${HELPER_ISO}"
+
+#echo "genisoimage -quiet -input-charset utf-8 -J -joliet-long -r -allow-lowercase -allow-multidot -o \"${HELPER_ISO}\" \"${HELPER_ISO_FILES_DIR}\""
+genisoimage -quiet -input-charset utf-8 -J -joliet-long -r -allow-lowercase -allow-multidot -o "${HELPER_ISO}" "${HELPER_ISO_FILES_DIR}" |& grep -v "Warning: "
diff --git a/scripts/main/generate-live-iso.sh b/scripts/main/generate-live-iso.sh
new file mode 100755
index 0000000..d817a6d
--- /dev/null
+++ b/scripts/main/generate-live-iso.sh
@@ -0,0 +1,187 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+loadConfig
+
+source "${PROJECT_DIR}/requirements.sh"
+
+alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables"
+alias updatePkgInfo="'${PACKAGE_MANAGER}' update"
+alias getExecPkg="'${PACKAGE_MANAGER}' install --executables"
+
+MODE="$1"
+DRIVE="$2"
+
+ISO_DOWNLOAD_URL="https://download.fedoraproject.org/pub/fedora/linux/releases/34/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-34-1.2.iso"
+ISO_FILE="${LIVE_ISO_FILES_DIR}/Fedora-Workstation-Live-x86_64-34-1.2.iso"
+ISO_FILE_MODIFIED="${LIVE_ISO_FILES_DIR}/Fedora-Workstation-Live-x86_64-34-1.2.modified.iso"
+
+SOURCE_SQUASHFS_IMG="/LiveOS/squashfs.img"
+SQUASHFS_IMG="/tmp/squashfs.img"
+SQUASHFS_EXTRACTED="/tmp/squashfs-extracted"
+SQUASHFS_IMG_MODIFIED="/tmp/squashfs.modified.img"
+
+ROOTFS_IMG="${SQUASHFS_EXTRACTED}/LiveOS/rootfs.img"
+ROOTFS_MOUNTPOINT="/tmp/rootfs-mountpoint"
+
+MISSING_EXECUTABLES="$(getMissingExecutables "$EXEC_DEPS_LIVE_ISO")"
+
+if [ "$MISSING_EXECUTABLES" != "" ]; then
+ echo "> Update package info..."
+ updatePkgInfo
+ echo "> Find and install packages containing executables that we need..."
+ getExecPkg "$ALL_EXEC_DEPS" # Find and install packages containing executables that we need
+ MISSING_EXECUTABLES="$(getMissingExecutables "$ALL_EXEC_DEPS")"
+ if [ "$MISSING_EXECUTABLES" != "" ]; then
+ echo "> ERROR: Failed to install packages providing the following executables automatically: $MISSING_EXECUTABLES"
+ fi
+else
+ echo "> [Skipped] Executable dependencies are already installed."
+fi
+
+if [ ! -d "${THIRDPARTY_DIR}/livecd-tools" ]; then
+ echo "> Downlaoding and installing livecd-tools..."
+ mkdir -p "${THIRDPARTY_DIR}"
+ cd "${THIRDPARTY_DIR}"
+ git clone --depth=1 https://github.com/livecd-tools/livecd-tools.git
+ cd livecd-tools
+ sudo make install
+ sudo pip3 install urlgrabber
+else
+ echo "> [Skipped] livecd-tools already installed."
+fi
+
+cd "${PROJECT_DIR}"
+
+function build_method_1() {
+ if [ ! -f "${ISO_FILE}" ]; then
+ echo "> Downloading Fedora ISO..."
+ wget "${ISO_DOWNLOAD_URL}" -c -O "${ISO_FILE}.part"
+ mv "${ISO_FILE}.part" "${ISO_FILE}"
+ else
+ echo "> [Skipped] Fedora ISO already downloaded."
+ fi
+
+ sudo rm -rf "${ISO_FILE_MODIFIED}"
+
+ echo "> Rebuilding the ISO adding kernel parameters and some files..."
+ TMP_SCRIPT="/tmp/tmp-rootfs-setup.sh"
+ sudo rm -f "${TMP_SCRIPT}"
+ echo "#!/usr/bin/env bash" > "${TMP_SCRIPT}"
+ echo "mkdir -p /etc/skel/.config/autostart/" >> "${TMP_SCRIPT}"
+ echo "IFS='' read -r -d '' GET_MBPT_SCRIPT <<\"EOF\"" >> "${TMP_SCRIPT}"
+ echo "$(cat ${LIVE_ISO_FILES_DIR}/get-mbpt.sh)" >> "${TMP_SCRIPT}"
+ echo "EOF" >> "${TMP_SCRIPT}"
+ echo 'echo "$GET_MBPT_SCRIPT" > /etc/skel/get-mbpt.sh' >> "${TMP_SCRIPT}"
+ echo "chmod +x /etc/skel/get-mbpt.sh" >> "${TMP_SCRIPT}"
+ echo "IFS='' read -r -d '' GET_MBPT_DESKTOP_FILE <<\"EOF\"" >> "${TMP_SCRIPT}"
+ echo "$(cat ${LIVE_ISO_FILES_DIR}/mbpt.desktop)" >> "${TMP_SCRIPT}"
+ echo "EOF" >> "${TMP_SCRIPT}"
+ echo 'echo "$GET_MBPT_DESKTOP_FILE" > /etc/skel/.config/autostart/mbpt.desktop' >> "${TMP_SCRIPT}"
+ echo 'echo "$GET_MBPT_DESKTOP_FILE" > /usr/share/applications/mbpt.desktop' >> "${TMP_SCRIPT}"
+ sudo chmod +x "${TMP_SCRIPT}"
+
+ USERNAME="T-vK" sudo editliveos \
+ --builder "T-vK" \
+ --noshell \
+ --script "${TMP_SCRIPT}" \
+ --extra-kernel-args "$ALL_KERNEL_PARAMS" \
+ --output "${LIVE_ISO_FILES_DIR}" \
+ --name "mbpt" \
+ "${ISO_FILE}"
+
+ mv "${LIVE_ISO_FILES_DIR}/mbpt-"*.iso "${ISO_FILE_MODIFIED}"
+
+ sudo rm -f "${TMP_SCRIPT}"
+}
+
+function build_method_2() {
+ if [ ! -f "${ISO_FILE}" ]; then
+ echo "> Downloading Fedora ISO..."
+ wget "${ISO_DOWNLOAD_URL}" -c -O "${ISO_FILE}.part"
+ mv "${ISO_FILE}.part" "${ISO_FILE}"
+ else
+ echo "> [Skipped] Fedora ISO already downloaded."
+ fi
+
+ sudo rm -rf "${ISO_FILE_MODIFIED}"
+
+ echo "> Extracting the squashfs image and unsquash it..."
+ sudo rm -f "/tmp/grub.conf"
+ sudo rm -f "/tmp/isolinux.cfg"
+ sudo rm -f "/tmp/BOOT.conf"
+ sudo rm -f "/tmp/grub.cfg"
+ sudo rm -f "${SQUASHFS_IMG}"
+ xorriso -dev "${ISO_FILE}" -osirrox "on" \
+ -extract "${SOURCE_SQUASHFS_IMG}" "${SQUASHFS_IMG}" \
+ -extract "/isolinux/grub.conf" "/tmp/grub.conf" \
+ -extract "/isolinux/isolinux.cfg" "/tmp/isolinux.cfg" \
+ -extract "/EFI/BOOT/BOOT.conf" "/tmp/BOOT.conf" \
+ -extract "/EFI/BOOT/grub.cfg" "/tmp/grub.cfg"
+ sudo rm -rf "${SQUASHFS_EXTRACTED}"
+ sudo unsquashfs -d "${SQUASHFS_EXTRACTED}" "${SQUASHFS_IMG}" # Unsquash the squashfs and mount the rootfs in read-write mode
+ sudo rm -f "${SQUASHFS_IMG}"
+
+ echo "> Mounting the rootfs image of the unsquashed squashfs image..."
+ sudo umount --force "${ROOTFS_MOUNTPOINT}"
+ sudo rm -rf "${ROOTFS_MOUNTPOINT}"
+ sudo mkdir -p "${ROOTFS_MOUNTPOINT}"
+ sudo mount -o loop,rw "${ROOTFS_IMG}" "${ROOTFS_MOUNTPOINT}"
+
+ echo "> Adding files to the rootfs..."
+ sudo mkdir -p "${ROOTFS_MOUNTPOINT}/etc/skel/.config/autostart/"
+ sudo cp "${LIVE_ISO_FILES_DIR}/get-mbpt.sh" "${ROOTFS_MOUNTPOINT}/etc/skel/"
+ sudo cp "${LIVE_ISO_FILES_DIR}/mbpt.desktop" "${ROOTFS_MOUNTPOINT}/etc/skel/.config/autostart/"
+ sudo cp "${LIVE_ISO_FILES_DIR}/mbpt.desktop" "${ROOTFS_MOUNTPOINT}/usr/share/applications/"
+
+ echo "> Unmounting the rootfs image again..."
+ sudo umount "${ROOTFS_MOUNTPOINT}"
+ sudo rm -rf "${ROOTFS_MOUNTPOINT}"
+
+ echo "> Making a new squashfs image from the unsquashed modified squashfs image..."
+ sudo mksquashfs "${SQUASHFS_EXTRACTED}" "${SQUASHFS_IMG_MODIFIED}" -b 1024k -comp xz -Xbcj x86 -e boot
+ sudo rm -rf "${SQUASHFS_EXTRACTED}"
+
+ sudo sed -i "s/rd.live.image/$1 &/" "/tmp/grub.conf"
+ sudo sed -i "s/rd.live.image/$1 &/" "/tmp/isolinux.cfg"
+ sudo sed -i "s/rd.live.image/$1 &/" "/tmp/BOOT.conf"
+ sudo sed -i "s/rd.live.image/$1 &/" "/tmp/grub.cfg"
+
+ echo "> Overwriting the squashfs image inside the ISO with the modified one..."
+ xorriso -indev "${ISO_FILE}" -outdev "${ISO_FILE_MODIFIED}" -md5 "all" -compliance no_emul_toc \
+ -update "${SQUASHFS_IMG_MODIFIED}" "/LiveOS/squashfs.img" \
+ -update "/tmp/grub.conf" "/isolinux/grub.conf" \
+ -update "/tmp/isolinux.cfg" "/isolinux/isolinux.cfg" \
+ -update "/tmp/BOOT.conf" "/EFI/BOOT/BOOT.conf" \
+ -update "/tmp/grub.cfg" "/EFI/BOOT/grub.cfg" \
+ -boot_image any replay
+
+ echo "> Removing modified squashfs image..."
+ sudo rm -f "${SQUASHFS_IMG_MODIFIED}"
+}
+
+function flash() {
+ echo "> Flashing ISO to USB drive"
+ mps="$(mount | grep "$DRIVE" | cut -d' ' -f3)" # get mountpoint for device
+ if [ "$mps" != "" ]; then
+ echo "> $DRIVE is still mounted."
+ while IFS= read -r mp; do
+ echo "> Unmounting partition mounted at ${mp}..."
+ sudo umount --force "$mp"
+ done <<< "$mps"
+ fi
+ yes "" | sudo livecd-iso-to-disk --format ext4 --overlay-size-mb 4095 --efi --force --extra-kernel-args "$ALL_KERNEL_PARAMS" "${ISO_FILE_MODIFIED}" "$DRIVE"
+}
+
+if [ "$MODE" = "flash" ]; then
+ if [ "$DRIVE" = "" ]; then
+ echo "> [Error] Missing parameter. You have to specify the device onto which to flash the Live ISO! E.g. /dev/sda"
+ exit 1
+ fi
+ if [ ! -f "${ISO_FILE_MODIFIED}" ]; then
+ build_method_1
+ fi
+ flash
+elif [ "$MODE" = "build" ]; then
+ build_method_1
+fi
diff --git a/scripts/generate-vm-config.sh b/scripts/main/generate-vm-config.sh
similarity index 51%
rename from scripts/generate-vm-config.sh
rename to scripts/main/generate-vm-config.sh
index a88877b..06883ab 100755
--- a/scripts/generate-vm-config.sh
+++ b/scripts/main/generate-vm-config.sh
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="$(readlink -f "${SCRIPT_DIR}/..")"
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
+#####################################################################################################
+# This interactive script creates a custom config file (user.conf) to your liking.
+#####################################################################################################
-#source "$UTILS_DIR/gpu-check"
+#source "$COMMON_UTILS_LIBS_DIR/gpu-check"
interactiveCfg() {
DEFAULT_VALUE=$(grep -Po "(?<=^$2=).*" "${PROJECT_DIR}/default.conf" | cut -d "#" -f1 | sed 's/^\s*"\(.*\)"\s*$/\1/' | xargs)
@@ -33,9 +33,9 @@ interactiveCfg() {
# TODO: change modified value on config file USER_CONFIG_FILE
}
-echo "!!!!!!"
-echo "IF IN DOUBT WITH ANY OF THE FOLLOWING, JUST PRESS ENTER TO USE THE RECOMMENDED/DEFAULT VALUE!"
-echo "!!!!!!"
+echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+echo "!!IF IN DOUBT WITH ANY OF THE FOLLOWING, JUST PRESS ENTER TO USE THE RECOMMENDED/DEFAULT VALUE!!"
+echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
interactiveCfg "Where should the VM files be saved?" VM_FILES_DIR
echo "> Directory set to '${VM_FILES_DIR}'"
@@ -51,51 +51,50 @@ mkdir -p "$(dirname "${USER_CONFIG_FILE}")"
cp "${PROJECT_DIR}/default.conf" "${USER_CONFIG_FILE}"
echo "> Config will be created at ${USER_CONFIG_FILE}'"
+# Variables that require a reinstall when changed (./mbpt.sh install)
interactiveCfg "What should the name of the VM be?" VM_NAME
interactiveCfg "Where to save the VM drive image?" DRIVE_IMG
-interactiveCfg "How big should the VM drive image be?" VM_DISK_SIZE
-interactiveCfg "How many CPU cores should the VM get?" CPU_CORE_COUNT
-interactiveCfg "How much RAM should the VM get?" RAM_SIZE
-interactiveCfg "Path to your Windows installation iso. (If it doesn't exist it will be downloaded automatically.)" INSTALL_IMG
-interactiveCfg "Path to a dGPU ROM. (Optional)" DGPU_ROM
-interactiveCfg "Path to a iGPU ROM. (Optional)" IGPU_ROM
+interactiveCfg "How big should the VM drive image be? (At least 40G is highly recommended; Can't be changed wihtout a reinstall)" VM_DISK_SIZE
+interactiveCfg "Path to your Windows installation iso. (If it doesn't exist it will be downloaded to that location automatically.)" INSTALL_IMG
+
+# Variables that can be changed between VM starts (./mbpt.sh start)
+interactiveCfg "How many CPU cores should the VM get? (e.g. 8 or auto; auto equals [AVAILABLE CORES]-1 but uses 16 cores max)" CPU_CORE_COUNT
+interactiveCfg "How much RAM should the VM get? (e.g. 16G or auto; auto equals [FREE RAM]-1G but uses 16G max)" RAM_SIZE
+
+interactiveCfg "The PCI address of your dGPU as obtained by 'lspci' or 'optimus lspci'. (E.g. 01:00.0 or auto to detect it automatically)" DGPU_PCI_ADDRESS
+interactiveCfg "The PCI address of your iGPU as obtained by 'lspci'. (E.g. 00:02.0 or auto to detect it automatically)" IGPU_PCI_ADDRESS
+interactiveCfg "Pass the dGPU through to the VM. (true, false or auto to enable if more than one GPU is in this system)" DGPU_PASSTHROUGH
+interactiveCfg "Share the iGPU (only supports Intel atm) with the VM to allow using Optimus within the VM to save battery life (true, false or auto to share it only if available)" SHARE_IGPU
+
+interactiveCfg "Path to a dGPU ROM. (Optional; Can help avoid error 43)" DGPU_ROM
+interactiveCfg "Path to a iGPU ROM. (Optional; Can help avoid error 43)" IGPU_ROM
+interactiveCfg "Patch OVMF with your dGPU ROM if you supply one. (Highly recommended to avoid Error 43)" PATCH_OVMF_WITH_VROM
+
+interactiveCfg "MAC address to use (e.g. 11:22:33:44:55:66 or auto to generate it automatically)" MAC_ADDRESS
+interactiveCfg "Network mode to use? Only supports bridge at the moment." NETWORK_MODE
interactiveCfg "Path to a folder to share with the VM via SMB. (Optional)" SMB_SHARE_FOLDER
-interactiveCfg "Location of OVMF_VARS.fd." OVMF_VARS
+
+interactiveCfg "Virtual input device mode for keyboard and mouse. (if usb-tablet doesn't work properly, you may want to switch to virtio)" VIRTUAL_INPUT_TYPE
+
+interactiveCfg "Location of the unmodified OVMF_VARS.fd." OVMF_VARS
+interactiveCfg "Location of the unmodified OVMF_CODE.fd." OVMF_CODE
interactiveCfg "Where to create Creating a copy of OVMF_VARS.fd (containing the executable firmware code and but the non-volatile variable store) for the VM?" OVMF_VARS_VM
-interactiveCfg "Location of OVMF_CODE.fd." OVMF_CODE
-interactiveCfg "Location of the virtio Windows driver disk." VIRTIO_WIN_IMG
+
interactiveCfg "Location of helper iso or where to create it." HELPER_ISO
-interactiveCfg "Pass the dGPU through to the VM." DGPU_PASSTHROUGH
-interactiveCfg "Share the iGPU with the VM to allow using Optimus within the VM to save battery life" SHARE_IGPU
-interactiveCfg "dGPU driver used by the Linux host (nvidia, nouveau, amdgpu, radeon). (nouveau & radeon are untested)" HOST_DGPU_DRIVER
-interactiveCfg "The PCI address of your dGPU as obtained by 'lspci' or 'optimus lspci'. (01:00.0 if you use Bumblebee)" DGPU_PCI_ADDRESS
-interactiveCfg "The PCI address of your iGPU as obtained by 'lspci'. (Usually 00:02.0)" IGPU_PCI_ADDRESS
-interactiveCfg "Virtual input device mode for keyboard and mouse. (if usb-tablet doesn't work properly, you may want to switch to virtio)" VIRTUAL_INPUT_TYPE
-interactiveCfg "MAC address to use or leave empty to generate a random one" MAC_ADDRESS
-if [ "$MAC_ADDRESS" == "" ]; then
- MAC_ADDRESS=$(printf '52:54:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256)))
- echo "> MAC_ADDRESS generated: ${MAC_ADDRESS}"
- echo "> Set MAC_ADDRESS to '${MAC_ADDRESS}'"
- crudini --set "${USER_CONFIG_FILE}" "" "MAC_ADDRESS" "\"${MAC_ADDRESS}\""
-fi
-interactiveCfg "Network mode to use? Only supports TAP at the moment." NETWORK_MODE
-interactiveCfg "Use Looking Glass to get super low latency video output." USE_LOOKING_GLASS
+
interactiveCfg "Max screen width with Looking Glass." LOOKING_GLASS_MAX_SCREEN_WIDTH
interactiveCfg "Max screen height with Looking Glass." LOOKING_GLASS_MAX_SCREEN_HEIGHT
-interactiveCfg "Version of Looking Glass to use (B3 is highly recommended)" LOOKING_GLASS_VERSION
-interactiveCfg "Enable spice. (Recommended for Looking Glass, required to install Windows)" USE_SPICE
+interactiveCfg "Version of Looking Glass to use (B4 is highly recommended)" LOOKING_GLASS_VERSION
+
+interactiveCfg "Display mode to use (e.g. 1 or 2 ... see scripts/utils/common/plugins)" DISPLAY_MODE
+
+interactiveCfg "Enable spice. (Leave this on unless you know what you're doing!)" USE_SPICE
interactiveCfg "Port to use for spice." SPICE_PORT
-interactiveCfg "Enable dma-buf. (Yet another way to get display access to your VM)" USE_DMA_BUF
-interactiveCfg "Enable QXL. (Required for Windows installation; has to be disabled after the Nvidia driver has been installed!)" USE_QXL
+interactiveCfg "Automatically start a Spice client when the VM starts." USE_SPICE_CLIENT
+
interactiveCfg "Provide the VM with a fake battery (Highly recommended to avoid Error 43)" USE_FAKE_BATTERY
-interactiveCfg "Patch OVMF with your dGPU ROM if you supply one. (Highly recommended to avoid Error 43)" PATCH_OVMF_WITH_VROM
+
+interactiveCfg "Tool to use to start/install the VM. (qemu or virt-install)" VM_START_MODE
+
interactiveCfg "List of USB devices to pass through. (Semicolon separated, e.g. vendorid=0x0b12,productid=0x9348;vendorid=0x0b95,productid=0x1790)" USB_DEVICES
-# TODO: Make selecting USB devices easier
-# TODO: Auto detect PCI addresses for GPUs
-# TODO: Don't ask for Bumblebee if there is no nvidia gpu
-
-source "$USER_CONFIG_FILE"
-if [ ! -f "$INSTALL_IMG" ]; then
- echo "'$INSTALL_IMG' does not exist and will be downloaded automatically now. If you don't want that, press Ctrl+C to cancel it."
- $UTILS_DIR/download-windows-iso "$INSTALL_IMG"
-fi
+# TODO: Make selecting USB devices easier
\ No newline at end of file
diff --git a/scripts/main/iommu-check.sh b/scripts/main/iommu-check.sh
new file mode 100755
index 0000000..059d681
--- /dev/null
+++ b/scripts/main/iommu-check.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+
+#####################################################################################################
+# This script checks if virtualization and IOMMU are enabled in the UEFI and kernel.
+# Exits with 0 in case of success; Exits with 1 if it's not fully enabled.
+# Will print helpful output telling you what is working and what is not.
+#####################################################################################################
+
+if sudo which optirun &> /dev/null && sudo optirun echo>/dev/null ; then
+ OPTIRUN_PREFIX="optirun "
+else
+ OPTIRUN_PREFIX=""
+fi
+
+IOMMU_GROUPS=$(sudo ${OPTIRUN_PREFIX}${COMMON_UTILS_TOOLS_DIR}/lsiommu)
+
+# Check if UEFI is configured correctly
+if systool -m kvm_intel -v &> /dev/null || systool -m kvm_amd -v &> /dev/null ; then
+ UEFI_VIRTUALIZATION_ENABLED=true
+ echo "[OK] VT-X / AMD-V virtualization is enabled in the UEFI."
+else
+ UEFI_VIRTUALIZATION_ENABLED=false
+ echo "[Error] VT-X / AMD-V virtualization is not enabled in the UEFI! This is required to run virtual machines!"
+fi
+
+if [ "$IOMMU_GROUPS" != "" ] ; then
+ UEFI_IOMMU_ENABLED=true
+ echo "[OK] VT-D / IOMMU is enabled in the UEFI."
+else
+ UEFI_IOMMU_ENABLED=false
+ echo "[Error] VT-D / IOMMU is not enabled in the UEFI! This is required to check which devices are in which IOMMU group and to use GPU passthrough!"
+fi
+
+if [ "$UEFI_VIRTUALIZATION_ENABLED" = true ] && [ "$UEFI_IOMMU_ENABLED" = true ] ; then
+ exit 0 # success
+else
+ exit 1 # error
+fi
\ No newline at end of file
diff --git a/scripts/main/setup.sh b/scripts/main/setup.sh
new file mode 100755
index 0000000..afe5fa7
--- /dev/null
+++ b/scripts/main/setup.sh
@@ -0,0 +1,200 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+loadConfig
+
+#####################################################################################################
+# This script installs all missing and required dependencies and also adds required kernel parameters. It's called like this: `./setup.sh`
+# If you want to automatically reboot the system if necessary (e.g. to load new kernel params) run with: `./setup.sh auto`.
+# This won't just reboot the system, but also create a temporary service that will execute `mbpt.sh auto` on the next boot.
+# TODO: the service creation shouldn'T be part of setup.sh. It should be in the auto section of mbpt.sh.
+#####################################################################################################
+
+source "${PROJECT_DIR}/requirements.sh"
+
+alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables"
+alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files"
+alias updatePkgInfo="'${PACKAGE_MANAGER}' update"
+alias getExecPkg="'${PACKAGE_MANAGER}' install --executables"
+alias getFilePkg="'${PACKAGE_MANAGER}' install --files"
+alias addKernelParams="sudo '${KERNEL_PARAM_MANAGER}' add"
+alias runtimeKernelHasParams="${COMMON_UTILS_TOOLS_DIR}/runtime-kernel-has-params"
+alias ovmfVbiosPatchSetup="sudo '$COMMON_UTILS_SETUP_DIR/ovmf-vbios-patch-setup'"
+alias buildFakeBatterySsdt="sudo '$COMMON_UTILS_SETUP_DIR/build-fake-battery-ssdt'"
+alias vbiosFinderSetup="sudo '$COMMON_UTILS_SETUP_DIR/vbios-finder-setup'"
+alias lookingGlassSetup="sudo '$COMMON_UTILS_SETUP_DIR/looking-glass-setup'"
+alias generateHelperIso="sudo '${MAIN_SCRIPTS_DIR}/generate-helper-iso.sh'"
+alias downloadWindowsIso="$COMMON_UTILS_TOOLS_DIR/download-windows-iso"
+alias createAutoStartService="'${SERVICE_MANAGER}' create-autostart-service"
+alias removeAutoStartService="'${SERVICE_MANAGER}' remove-autostart-service"
+
+mkdir -p "${THIRDPARTY_DIR}"
+mkdir -p "${VM_FILES_DIR}"
+
+if [ -f "${DISTRO_UTILS_DIR}/pre-package-info-update" ]; then
+ "${DISTRO_UTILS_DIR}/pre-package-info-update"
+fi
+
+MISSING_EXECUTABLES="$(getMissingExecutables "$ALL_EXEC_DEPS")"
+MISSING_FILES="$(getMissingFiles "$ALL_FILE_DEPS")"
+
+if [ "$MISSING_EXECUTABLES" != "" ] || [ "$MISSING_FILES" != "" ]; then
+ echo "> Update package info..."
+ updatePkgInfo
+fi
+
+if [ -f "${DISTRO_UTILS_DIR}/pre-package-install" ]; then
+ "${DISTRO_UTILS_DIR}/pre-package-install"
+fi
+
+if [ "$MISSING_EXECUTABLES" != "" ]; then
+ echo "> Finding and installing packages containing executables that we need..."
+ getExecPkg "$ALL_EXEC_DEPS" # Find and install packages containing executables that we need
+ MISSING_EXECUTABLES="$(getMissingExecutables "$ALL_EXEC_DEPS")"
+ if [ "$MISSING_EXECUTABLES" != "" ]; then
+ echo "> [Error] Failed to install packages providing the following executables automatically: $MISSING_EXECUTABLES"
+ fi
+else
+ echo "> [Skipped] Executable dependencies are already installed."
+fi
+
+if [ "$MISSING_FILES" != "" ]; then
+ echo "> Finding and installing packages containing files that we need..."
+ getFilePkg "$ALL_FILE_DEPS" # Find and install packages containing specific files that we need
+ MISSING_FILES="$(getMissingFiles "$ALL_FILE_DEPS")"
+ if [ "$MISSING_FILES" != "" ]; then
+ MISSING_FILES="$(echo "$MISSING_EXECUTABLES" | sed 's/\s\+/\n/g')" # replace spaces with new lines
+ echo "> [Error] Failed to install packages providing the following executables automatically:"
+ echo "$MISSING_FILES"
+ fi
+else
+ echo "> [Skipped] File dependencies are already installed."
+fi
+
+if [ "$MISSING_EXECUTABLES" != "" ] || [ "$MISSING_FILES" != "" ]; then
+ exit 1
+fi
+
+REBOOT_REQUIRED=false
+if ! runtimeKernelHasParams "${KERNEL_PARAMS_GENERAL[*]}"; then
+ echo "> Adding general kernel params..."
+ addKernelParams "${KERNEL_PARAMS_GENERAL[*]}"
+ REBOOT_REQUIRED=true
+else
+ echo "> [Skipped] General kernel params already set on running kernel."
+fi
+
+source "$COMMON_UTILS_LIBS_DIR/cpu-check"
+source "$COMMON_UTILS_LIBS_DIR/gpu-check"
+
+#if [ "$HAS_INTEL_CPU" = true ]; then
+ if ! runtimeKernelHasParams "${KERNEL_PARAMS_INTEL_CPU[*]}"; then
+ echo "> Adding Intel CPU-specific kernel params..."
+ addKernelParams "${KERNEL_PARAMS_INTEL_CPU[*]}"
+ REBOOT_REQUIRED=true
+ else
+ echo "> [Skipped] Intel CPU-specific kernel params already set on running kernel."
+ fi
+#fi
+
+#if [ "$HAS_AMD_CPU" = true ]; then
+ if ! runtimeKernelHasParams "${KERNEL_PARAMS_AMD_CPU[*]}"; then
+ echo "> Adding AMD CPU-specific kernel params..."
+ addKernelParams "${KERNEL_PARAMS_AMD_CPU[*]}"
+ REBOOT_REQUIRED=true
+ else
+ echo "> [Skipped] AMD CPU-specific kernel params already set on running kernel."
+ fi
+#fi
+
+#if [ "$HAS_INTEL_GPU" = true ]; then
+ if ! runtimeKernelHasParams "${KERNEL_PARAMS_INTEL_GPU[*]}"; then
+ echo "> Adding Intel GPU-specific kernel params..."
+ addKernelParams "${KERNEL_PARAMS_INTEL_GPU[*]}"
+ REBOOT_REQUIRED=true
+ else
+ echo "> [Skipped] Intel GPU-specific kernel params already set on running kernel."
+ fi
+#fi
+
+#if [ "$HAS_NVIDIA_GPU" = true ]; then # TODO: Don't force Bumblebee and the proprietary Nvidia driver upon the user
+# if ! runtimeKernelHasParams "${KERNEL_PARAMS_BUMBLEBEE_NVIDIA[*]}"; then
+# echo "> Adding Nvidia GPU-specific kernel params..."
+# addKernelParams "${KERNEL_PARAMS_BUMBLEBEE_NVIDIA[*]}"
+# REBOOT_REQUIRED=true
+# else
+# echo "> [Skipped] Nvidia GPU-specific kernel params already set on running kernel."
+# fi
+#fi
+
+#if [ "$HAS_NVIDIA_GPU" = true ]; then
+# nvidiaSetup
+#fi
+#if [ "$SUPPORTS_OPTIMUS" = true ]; then
+# bumblebeeSetup
+#fi
+
+if [ ! -f "${ACPI_TABLES_DIR}/fake-battery.aml" ]; then
+ echo "> Building fake ACPI SSDT battery..."
+ buildFakeBatterySsdt
+else
+ echo "> [Skipped] Fake ACPI SSDT battery has already been built."
+fi
+
+if [ ! -f ${THIRDPARTY_DIR}/VBiosFinder/vendor/bundle/ruby/*/bin/coderay ]; then
+ echo "> Installing VBiosFinder..."
+ vbiosFinderSetup
+else
+ echo "> [Skipped] VBiosFinder is already set up."
+fi
+
+if [ ! -f "${THIRDPARTY_DIR}/LookingGlass/looking-glass-host.exe" ] || [ ! -f "${THIRDPARTY_DIR}/LookingGlass/client/build/looking-glass-client" ]; then
+ echo "> Installing Looking Glass..."
+ lookingGlassSetup
+else
+ echo "> [Skipped] Looking Glass is already set up."
+fi
+
+CHECKSUM_FILE_PATH="$HELPER_ISO_FILES_DIR/.checksum"
+PREVIOUS_HELPER_ISO_DIR_CHECKSUM="$(cat "$CHECKSUM_FILE_PATH" 2> /dev/null)"
+NEW_HELPER_ISO_DIR_CHECKSUM="$(find "$HELPER_ISO_FILES_DIR" -type f ! -iname ".checksum" -exec md5sum {} + | LC_ALL=C sort | md5sum | cut -d' ' -f1)"
+if [ "$PREVIOUS_HELPER_ISO_DIR_CHECKSUM" != "$NEW_HELPER_ISO_DIR_CHECKSUM" ]; then
+ echo "> Generating helper ISO for auto unattended Windows install, config and driver installation..."
+ rm -f "$CHECKSUM_FILE_PATH"
+ generateHelperIso
+ echo "$NEW_HELPER_ISO_DIR_CHECKSUM" > "$CHECKSUM_FILE_PATH"
+else
+ echo "> [Skipped] Helper ISO for auto unattended Windows install, config and driver installation already generated for the current files."
+fi
+
+if [ ! -f "$INSTALL_IMG" ]; then
+ echo "Downloading Windows ISO from Microsoft now."
+ downloadWindowsIso "$INSTALL_IMG"
+else
+ echo "> [Skipped] Windows ISO has already been downloaded."
+fi
+
+if [[ "$(sudo docker images -q 'tavk/ovmf-vbios-patch:1.0.1-edk2-stable201905' 2> /dev/null)" == "" ]]; then
+ echo "> Installing 'ovmf-vbios-patch' Docker Image..."
+ ovmfVbiosPatchSetup
+else
+ echo "> [Skipped] Image 'ovmf-vbios-patch' has already been built."
+fi
+
+if [ "$1" = "auto" ]; then
+ if [ "$REBOOT_REQUIRED" = true ]; then
+ echo "> Creating a temporary service that will run on next reboot and continue the installation..."
+ createAutoStartService "${PROJECT_DIR}/mbpt.sh auto" "MobilePassthroughInitSetup"
+ echo "> Rebooting in 30 seconds... Press Ctrl+C to cancel."
+ sleep 30 && sudo shutdown -r 0
+ else
+ removeAutoStartService "MobilePassthroughInitSetup" &> /dev/null
+ echo "> No reboot required."
+ fi
+else
+ if [ REBOOT_REQUIRED = true ]; then
+ echo "> Please reboot to load the new kernel parameters!"
+ else
+ echo "> No reboot required."
+ fi
+fi
diff --git a/scripts/main/vm.sh b/scripts/main/vm.sh
new file mode 100755
index 0000000..b6e8be8
--- /dev/null
+++ b/scripts/main/vm.sh
@@ -0,0 +1,992 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+loadConfig
+
+#####################################################################################################
+# This script can create a VM and install Windows in i,t if called like this: `./vm.sh install`
+# or start the previously created Windows VM, if called like this: `./vm.sh`
+#####################################################################################################
+
+ORIGINAL_VM_ACTION="$1"
+VM_ACTION="$ORIGINAL_VM_ACTION"
+if [ "$VM_ACTION" != "auto" ]; then
+ echo "> Action: $VM_ACTION"
+fi
+
+if [ "$VM_ACTION" = "install" ]; then
+ VM_ACTION="install"
+elif [ "$VM_ACTION" = "start" ]; then
+ VM_ACTION="start"
+elif [ "$VM_ACTION" = "stop" ]; then
+ if [ "$VM_START_MODE" = "virt-install" ]; then
+ sudo virsh destroy --domain "${VM_NAME}"
+ elif [ "$VM_START_MODE" = "qemu" ]; then
+ sudo killall -9 qemu-system-x86_64 &> /dev/null
+ fi
+elif [ "$VM_ACTION" = "auto" ]; then
+ if sudo fdisk -lu "${DRIVE_IMG}" 2> /dev/null | grep --quiet 'Microsoft'; then
+ VM_ACTION="start"
+ else
+ VM_ACTION="install"
+ fi
+ echo "> Action: $VM_ACTION"
+elif [ "$VM_ACTION" = "remove" ]; then
+ if [ "$VM_START_MODE" = "virt-install" ]; then
+ sudo virsh destroy --domain "${VM_NAME}"
+ sudo virsh undefine --domain "${VM_NAME}" --nvram
+ elif [ "$VM_START_MODE" = "qemu" ]; then
+ sudo killall -9 qemu-system-x86_64 &> /dev/null
+ fi
+ if [[ ${DRIVE_IMG} == *.img ]]; then
+ sudo rm -f "${DRIVE_IMG}"
+ fi
+ rm -f "${OVMF_VARS_VM}"
+ exit
+else
+ echo "> Error: No valid vm.sh parameter was found!"
+ exit 1
+fi
+
+echo "> Start mode: $VM_START_MODE"
+
+GET_XML=false
+DRY_RUN=false
+if [ "$VM_ACTION" = "install" ] || [ "$VM_ACTION" = "start" ]; then
+ if [ "$2" = "dry-run" ]; then
+ DRY_RUN=true
+ elif [ "$2" = "get-xml" ]; then
+ GET_XML=true
+ echo "> Enforcing VM start mode 'virt-install' to generate the XML..."
+ VM_START_MODE="virt-install"
+ fi
+fi
+
+# Remove domain from PCI addressed if provided
+DGPU_PCI_ADDRESS="$(echo "$DGPU_PCI_ADDRESS" | sed 's/0000://g')"
+IGPU_PCI_ADDRESS="$(echo "$IGPU_PCI_ADDRESS" | sed 's/0000://g')"
+
+#source "$COMMON_UTILS_LIBS_DIR/gpu-check"
+alias driver="sudo '$COMMON_UTILS_TOOLS_DIR/driver-util'"
+alias vgpu="sudo '$COMMON_UTILS_TOOLS_DIR/vgpu-util'"
+alias lsiommu="sudo '$COMMON_UTILS_TOOLS_DIR/lsiommu'"
+
+VIRT_INSTALL_PARAMS=()
+QEMU_PARAMS=()
+
+#####################################################################################
+############################## Set basic VM parameters ##############################
+#####################################################################################
+function setMiscParams() {
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-name" "${VM_NAME}")
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--name" "${VM_NAME}")
+ fi
+
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-machine" "type=q35,accel=kvm") # for virt-install that's the default WHEN "--os-variant win10" is specified
+ fi
+
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-global" "ICH9-LPC.disable_s3=1") # for virt-install this enabled by default
+ QEMU_PARAMS+=("-global" "ICH9-LPC.disable_s4=1") # for virt-install this enabled by default
+ fi
+
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-enable-kvm") # for virt-install this enabled by default
+ fi
+
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ # Refer to https://github.com/saveriomiroddi/qemu-pinning for information on how to set your cpu affinity properly
+ QEMU_PARAMS+=("-cpu" "host,kvm=off,hv_vapic,hv_relaxed,hv_spinlocks=0x1fff,hv_time,hv_vendor_id=12alphanum")
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--cpu" "host")
+ VIRT_INSTALL_PARAMS+=("--feature" "kvm.hidden.state=yes")
+ VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./features/hyperv/vendor_id/@state=on" "--xml" "xpath.set=./features/hyperv/vendor_id/@value='12alphanum'")
+ fi
+
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-mem-prealloc") # for virt-install this enabled by default
+ fi
+
+ QEMU_PARAMS+=("-rtc" "clock=host,base=localtime")
+ QEMU_PARAMS+=("-nographic")
+ QEMU_PARAMS+=("-serial" "none")
+ QEMU_PARAMS+=("-parallel" "none")
+ QEMU_PARAMS+=("-boot" "menu=on")
+ QEMU_PARAMS+=("-boot" "once=d")
+ QEMU_PARAMS+=("-k" "en-us")
+
+ QEMU_PARAMS+=("-device" "ich9-intel-hda")
+ QEMU_PARAMS+=("-device" "hda-output")
+ QEMU_PARAMS+=("-device" "pci-bridge,addr=12.0,chassis_nr=2,id=head.2")
+ # More parameters are added throughout the whole script
+
+ VIRT_INSTALL_PARAMS+=("--virt-type" "kvm")
+ VIRT_INSTALL_PARAMS+=("--os-variant" "win10")
+ VIRT_INSTALL_PARAMS+=("--arch=x86_64")
+}
+
+#####################################################################################
+################################# Set up networking #################################
+#####################################################################################
+function setUpNetworking() {
+ if [ "$NETWORK_MODE" == "bridged" ]; then
+ echo "> Using network mode ${NETWORK_MODE}..."
+ if ! sudo virsh net-list | grep default | grep --quiet active; then
+ sudo virsh net-start default
+ fi
+
+ if [ "$MAC_ADDRESS" = "auto" ]; then
+ MAC_ADDRESS=$(printf '52:54:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256)))
+ fi
+ echo "> Using MAC address: ${MAC_ADDRESS}..."
+
+ INTERFACE_NAME="$(sudo cat /var/lib/libvirt/dnsmasq/default.conf | grep "^interface=" | cut -d'=' -f2-)"
+ NETWORK="$(sudo ip route | grep " ${INTERFACE_NAME} " | cut -d' ' -f1)"
+
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-net" "nic,model=e1000,macaddr=${MAC_ADDRESS}" "-net" "bridge,br=virbr0")
+ #QEMU_PARAMS+=("-netdev" "type=tap,id=net0,ifname=tap0,script=${VM_FILES_DIR}/network-scripts/tap_ifup,downscript=${VM_FILES_DIR}/network-scripts/tap_ifdown,vhost=on")
+ #QEMU_PARAMS+=("-device" "virtio-net-pci,netdev=net0,addr=19.0,mac=${MAC_ADDRESS}")
+ #-net user,hostfwd=tcp::13389-:3389 -net nic
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--network" "network=default,model=e1000,mac=${MAC_ADDRESS}")
+ #VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./devices/interface[type=network]/mac@address='${MAC_ADDRESS}'")
+ #VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./devices/interface[0]/source@network=default")
+ #if ! sudo virsh net-list | grep default | grep --quiet active; then
+ # sudo virsh net-start default
+ #fi
+ fi
+ else
+ echo "Networking will not be enabled for this VM..."
+ fi
+}
+
+#####################################################################################
+################################### Set CPU Cores ###################################
+#####################################################################################
+function setCpuCores() {
+ if [ "$CPU_CORE_COUNT" = "auto" ]; then
+ AVAILABLE_CPU_CORE_COUNT="$(nproc)"
+ CPU_CORE_COUNT="$((AVAILABLE_CPU_CORE_COUNT-1))"
+ if [[ $CPU_CORE_COUNT -gt 16 ]]; then
+ CPU_CORE_COUNT=16
+ fi
+ fi
+ echo "> Using ${CPU_CORE_COUNT} CPU cores..."
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-smp" "${CPU_CORE_COUNT}")
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--vcpu" "${CPU_CORE_COUNT}")
+ fi
+}
+
+#####################################################################################
+################################### Set RAM size ####################################
+#####################################################################################
+function setRamSize() {
+ if [ "$RAM_SIZE" = "auto" ]; then
+ FREE_RAM="$(free -g | grep 'Mem: ' | tr -s ' ' | cut -d ' ' -f7)"
+ RAM_SIZE_GB="$((FREE_RAM-1))"
+ if [[ $RAM_SIZE_GB -gt 16 ]]; then
+ RAM_SIZE_GB=16
+ fi
+ RAM_SIZE="${RAM_SIZE_GB}G"
+ fi
+ echo "> Using ${RAM_SIZE} of RAM..."
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-m" "${RAM_SIZE}")
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ RAM_SIZE_GB="$(numfmt --from=si "${RAM_SIZE}" --to-unit=1M)"
+ VIRT_INSTALL_PARAMS+=("--memory" "${RAM_SIZE_GB}")
+ fi
+}
+
+#####################################################################################
+############################## Set install media (ISO) ##############################
+#####################################################################################
+function setInstallMediaParam() {
+ if [ "$VM_ACTION" = "install" ]; then
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-drive" "file=${INSTALL_IMG},index=1,media=cdrom")
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--cdrom" "${INSTALL_IMG}")
+ fi
+ fi
+}
+
+#####################################################################################
+################################## Set helper ISO ###################################
+#####################################################################################
+function setHelperIsoParam() {
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-drive" "file=${HELPER_ISO},index=2,media=cdrom")
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--disk" "device=cdrom,path=${HELPER_ISO}")
+ fi
+}
+
+#####################################################################################
+########################### Set/create OS install drive #############################
+#####################################################################################
+function setUpOsDrive() {
+ if [[ ${DRIVE_IMG} == /dev/* ]]; then
+ echo "> Using a physical OS drive..."
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-drive" "file=${DRIVE_IMG},if=virtio" "-snapshot")
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--disk" "${DRIVE_IMG}")
+ fi
+ #QEMU_PARAMS+=("-drive" "file=/dev/sda,if=virtio" "-drive" "file=/dev/sdb,if=virtio" "-drive" "file=/dev/sdc,if=virtio" "-drive" "file=/dev/sdd,if=virtio" "-snapshot")
+ elif [[ ${DRIVE_IMG} == *.img ]]; then
+ echo "> Using a virtual OS drive..."
+ if [ "$VM_ACTION" = "install" ] && [ -f "${DRIVE_IMG}" ]; then
+ echo "> Removing old virtual disk..."
+ sudo rm -rf "${DRIVE_IMG}"
+ fi
+ if [ ! -f "${DRIVE_IMG}" ]; then
+ echo "> Creating a virtual disk for the VM..."
+ qemu-img create -f raw "${DRIVE_IMG}" "${VM_DISK_SIZE}" > /dev/null
+ sudo chown "$(whoami):$(id -gn "$(whoami)")" "${DRIVE_IMG}"
+ fi
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-drive" "id=disk0,if=virtio,cache.direct=on,if=virtio,aio=native,format=raw,file=${DRIVE_IMG}")
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--disk" "${DRIVE_IMG}")
+ fi
+ OS_DRIVE_SIZE="$(sudo ls -l --b=G "${DRIVE_IMG}" | cut -d " " -f5)"
+ echo "> Virtual OS drive has ${OS_DRIVE_SIZE} of storage."
+ else
+ echo "> Error: It appears that no proper OS drive (image) has been provided. Check your 'DRIVE_IMG' var: '${DRIVE_IMG}'"
+ exit
+ fi
+}
+
+#####################################################################################
+################ Figure out if optirun or DRI_PRIME should be used ##################
+#####################################################################################
+function bumblebeeCheck() {
+ if sudo which optirun &> /dev/null && sudo optirun echo > /dev/null ; then
+ OPTIRUN_PREFIX="optirun "
+ DRI_PRIME_PREFIX=""
+ echo "> Bumblebee works fine on this system. Using optirun when necessary..."
+ else
+ OPTIRUN_PREFIX=""
+ if [ "$SUPPORTS_DRI_PRIME" = true ]; then
+ DRI_PRIME_PREFIX="DRI_PRIME=1 "
+ else
+ echo "> Bumblebee is not available..."
+ fi
+ fi
+}
+
+#####################################################################################
+########################## Set up samba share directory #############################
+#####################################################################################
+function setUpSambaShare() {
+ if [ -z "$SMB_SHARE_FOLDER" ]; then
+ echo "> Not using SMB share..."
+ else
+ echo "> Using SMB share..."
+ QEMU_PARAMS+=("-net" "user,smb=${SMB_SHARE_FOLDER}")
+ fi
+}
+
+#####################################################################################
+####################### Set parameters for dGPU passthrough #########################
+#####################################################################################
+function setDGpuParams() {
+ if [ "$DGPU_PASSTHROUGH" != false ]; then
+ DGPU_PASSTHROUGH=false
+ availableGpusIds="$(sudo ${OPTIRUN_PREFIX}lshw -C display -businfo | grep 'pci@' | cut -d'@' -f2 | cut -d' ' -f1 | cut -d':' -f2-)"
+ if [ "$DGPU_PCI_ADDRESS" = "auto" ]; then
+ DGPU_PCI_ADDRESS=""
+ while IFS= read -r pciAddress; do
+ gpuInfo="$(sudo ${OPTIRUN_PREFIX}lspci -s "$pciAddress")"
+ if [[ "$gpuInfo" != *"Intel"* ]]; then
+ DGPU_PCI_ADDRESS="$pciAddress"
+ break
+ fi
+ done <<< "$availableGpusIds"
+ fi
+
+ if [ "$(echo -e "$availableGpusIds" | wc -l)" -le 1 ]; then
+ echo "> Not using dGPU passthrough because single GPU passthrough is not supported yet..."
+ elif [ "$DGPU_PCI_ADDRESS" != "" ]; then
+ DGPU_PASSTHROUGH=true
+ echo "> Using dGPU passthrough..."
+
+ DGPU_INFO="$(sudo ${OPTIRUN_PREFIX}lspci | grep "$DGPU_PCI_ADDRESS" | cut -d' ' -f2-)"
+ echo "> dGPU is: $DGPU_INFO"
+
+ echo "> Retrieving and parsing DGPU IDs..."
+ DGPU_IDS=$(export DRI_PRIME=1 && sudo ${OPTIRUN_PREFIX}lspci -n -s "${DGPU_PCI_ADDRESS}" | grep -oP "\w+:\w+" | tail -1)
+ DGPU_VENDOR_ID=$(echo "${DGPU_IDS}" | cut -d ":" -f1)
+ DGPU_DEVICE_ID=$(echo "${DGPU_IDS}" | cut -d ":" -f2)
+ DGPU_SS_IDS=$(export DRI_PRIME=1 && sudo ${OPTIRUN_PREFIX}lspci -vnn -d "${DGPU_IDS}" | grep "Subsystem:" | grep -oP "\w+:\w+")
+ DGPU_SS_VENDOR_ID=$(echo "${DGPU_SS_IDS}" | cut -d ":" -f1)
+ DGPU_SS_DEVICE_ID=$(echo "${DGPU_SS_IDS}" | cut -d ":" -f2)
+
+ if [ -z "$DGPU_IDS" ]; then
+ echo "> Error: Failed to retrieve DGPU IDs!"
+ echo "> DGPU_PCI_ADDRESS: ${DGPU_PCI_ADDRESS}"
+ echo "> DGPU_IDS: $DGPU_IDS"
+ echo "> DGPU_VENDOR_ID: $DGPU_VENDOR_ID"
+ echo "> DGPU_DEVICE_ID: $DGPU_DEVICE_ID"
+ echo "> DGPU_SS_IDS: $DGPU_SS_IDS"
+ echo "> DGPU_SS_VENDOR_ID: $DGPU_SS_VENDOR_ID"
+ echo "> DGPU_SS_DEVICE_ID: $DGPU_SS_DEVICE_ID"
+ exit 1
+ fi
+
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-device" "ioh3420,bus=pcie.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=pci.1") # DGPU root port
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--controller" "type=pci,model=pcie-root-port,address.type=pci,address.bus=0x0,address.slot=0x1c,address.function=0x0,address.multifunction=on,index=1,alias.name=pci.1") #
+ VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./devices/controller/model/@name=ioh3420")
+ VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./devices/controller/target/@chassis=1")
+ fi
+
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ if [ -z "$DGPU_ROM" ]; then
+ echo "> Not using DGPU vBIOS override..."
+ DGPU_ROM_PARAM=",rombar=0"
+ else
+ echo "> Using DGPU vBIOS override..."
+ DGPU_ROM_PARAM=",romfile=${DGPU_ROM}"
+ fi
+ QEMU_PARAMS+=("-device" "vfio-pci,host=${DGPU_PCI_ADDRESS},bus=pci.1,addr=00.0,x-pci-sub-device-id=0x${DGPU_SS_DEVICE_ID},x-pci-sub-vendor-id=0x${DGPU_SS_VENDOR_ID},multifunction=on${DGPU_ROM_PARAM}")
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ if [ -z "$DGPU_ROM" ]; then
+ echo "> Not using DGPU vBIOS override..."
+ DGPU_ROM_PARAM=",rom.bar=on"
+ fi
+ VIRT_INSTALL_PARAMS+=("--hostdev" "${DGPU_PCI_ADDRESS},address.bus=1,address.type=pci,address.multifunction=on${DGPU_ROM_PARAM}")
+ if [ ! -z "$DGPU_ROM" ]; then
+ echo "> Using DGPU vBIOS override..."
+ VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./devices/hostdev/rom/@file=${DGPU_ROM}")
+ QEMU_PARAMS+=("-set" "device.hostdev0.x-pci-sub-device-id=$((16#${DGPU_SS_DEVICE_ID}))")
+ QEMU_PARAMS+=("-set" "device.hostdev0.x-pci-sub-vendor-id=$((16#${DGPU_SS_VENDOR_ID}))")
+ fi
+ fi
+ else
+ echo "> Not using dGPU passthrough..."
+ fi
+ else
+ echo "> Not using dGPU passthrough..."
+ fi
+}
+
+##############################################################################################
+### If mediated iGPU passthrough is enabled, check if vGPU exists or if one can be created ###
+##############################################################################################
+function vGpuSetup() {
+ DMA_BUF_AVAILABLE=false
+ if [ "$SHARE_IGPU" = true ] || [ "$SHARE_IGPU" = "auto" ]; then
+
+ if [ "$IGPU_PCI_ADDRESS" = "auto" ]; then
+ IGPU_PCI_ADDRESS=""
+ availableGpusIds="$(sudo ${OPTIRUN_PREFIX}lshw -C display -businfo | grep 'pci@' | cut -d'@' -f2 | cut -d' ' -f1 | cut -d':' -f2-)"
+
+ while IFS= read -r pciAddress; do
+ gpuInfo="$(sudo ${OPTIRUN_PREFIX}lspci -s "$pciAddress")"
+ if [[ "$gpuInfo" == *"Intel"* ]]; then
+ IGPU_PCI_ADDRESS="$pciAddress"
+ break
+ fi
+ done <<< "$availableGpusIds"
+ fi
+
+ if [ "$IGPU_PCI_ADDRESS" != "" ]; then
+ vgpu init # load required kernel modules
+
+ # FIXME: There is a bug in Linux that prevents creating new vGPUs without rebooting after removing one.
+ # So for now we can't create a new vGPU every time the VM starts.
+ #vgpu remove "${IGPU_PCI_ADDRESS}" &> /dev/null # Ensure there are no vGPUs before creating a new one
+ VGPU_UUID="$(vgpu get "${IGPU_PCI_ADDRESS}" | head -1)"
+ if [ "$VGPU_UUID" == "" ]; then
+ echo "> Creating a vGPU for mediated iGPU passthrough..."
+ VGPU_UUID="$(vgpu create "${IGPU_PCI_ADDRESS}")"
+ if [ "$?" = "1" ]; then
+ echo "> [Error] Failed creating a vGPU. (You can try again. If you still get this error, you have to reboot. This seems to be a bug in Linux.)"
+ echo "> Continuing without mediated iGPU passthrough..."
+ VGPU_UUID=""
+ fi
+ fi
+
+ if [ "$VGPU_UUID" != "" ]; then
+ IGPU_INFO="$(sudo ${OPTIRUN_PREFIX}lspci | grep "$IGPU_PCI_ADDRESS" | cut -d' ' -f2-)"
+ echo "> iGPU is: $IGPU_INFO"
+ echo "> UUID of vGPU is: $VGPU_UUID"
+ DMA_BUF_AVAILABLE=true
+ fi
+ else
+ echo "> No iGPU found. - Not using mediated iGPU passthrough..."
+ fi
+ else
+ echo "> Not using mediated iGPU passthrough..."
+ fi
+}
+
+#####################################################################################
+############################ Load display output plugin #############################
+#####################################################################################
+function loadDisplayOutputPlugin() {
+ if [ "$DISPLAY_MODE" != "" ]; then
+ echo "> Loading display-mode-${DISPLAY_MODE} plugin..."
+ source "${COMMON_UTILS_PLUGINS_DIR}/display-mode-${DISPLAY_MODE}"
+ else
+ echo "> [Error] No display mode provided..."
+ fi
+}
+
+#########################################################################################################
+### If there is a vGPU for mediated iGPU passthrough, set parameters for iGPU passthrough and dma-buf ###
+#########################################################################################################
+function setIGpuParams() {
+ if [ "$VGPU_UUID" != "" ]; then
+ if [ "$VM_START_MODE" = "qemu" ]; then
+
+ if [ "$USE_DMA_BUF" = true ]; then
+ echo "> Using dma-buf..."
+ QEMU_PARAMS+=("-display" "egl-headless") #"-display" "gtk,gl=on" # DMA BUF Display
+ DMA_BUF_PARAM=",display=on,x-igd-opregion=on"
+ else
+ echo "> Not using dma-buf..."
+ DMA_BUF_PARAM=""
+ fi
+
+ if [ -z "$IGPU_ROM" ]; then
+ echo "> Not using iGPU vBIOS override..."
+ #IGPU_ROM_PARAM=",rom.bar=on"
+ else
+ echo "> Using iGPU vBIOS override..."
+ IGPU_ROM_PARAM=",romfile=${IGPU_ROM}"
+ fi
+
+ QEMU_PARAMS+=("-device" "vfio-pci,bus=pcie.0,addr=05.0,sysfsdev=/sys/bus/mdev/devices/${VGPU_UUID}${IGPU_ROM_PARAM}${DMA_BUF_PARAM}") # GVT-G
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ if [ "$USE_DMA_BUF" = true ]; then
+ echo "> Using dma-buf..."
+ #QEMU_PARAMS+=("-display" "egl-headless") #"-display" "gtk,gl=on" # DMA BUF Display
+ QEMU_PARAMS+=("-set" "device.hostdev1.x-igd-opregion=on")
+ GVTG_DISPLAY_STATE="on"
+ else
+ echo "> Not using dma-buf..."
+ GVTG_DISPLAY_STATE="off"
+ fi
+
+ if [ -z "$IGPU_ROM" ]; then
+ echo "> Not using iGPU vBIOS override..."
+ IGPU_ROM_PARAM=",rom.bar=on"
+ fi
+ VIRT_INSTALL_PARAMS+=("--hostdev" "type=mdev,alias.name=hostdev1,address.domain=0000,address.bus=0,address.slot=2,address.function=0,address.type=pci,address.multifunction=on${IGPU_ROM_PARAM}")
+ VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./devices/hostdev[2]/@model=vfio-pci")
+ VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./devices/hostdev[2]/source/address/@uuid=${VGPU_UUID}")
+
+ if [ ! -z "$IGPU_ROM" ]; then
+ echo "> Using iGPU vBIOS override..."
+ VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./devices/hostdev[2]/rom/@file=${IGPU_ROM}")
+ fi
+ fi
+ fi
+}
+
+#####################################################################################
+############################### Set Spice parameters ################################
+#####################################################################################
+function setSpiceParams() {
+ if [ "$USE_SPICE" = true ]; then
+ if sudo lsof -i ":${SPICE_PORT}" | grep --quiet LISTEN; then
+ echo "[Error] Something is blocking the SPICE_PORT (${SPICE_PORT})! Change it in your config or kill whatever is blocking it."
+ else
+ echo "> Using spice on port ${SPICE_PORT}..."
+ #QEMU_PARAMS+=("-spice" "port=${SPICE_PORT},addr=127.0.0.1,disable-ticketing") #Spice
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-spice" "port=${SPICE_PORT},addr=127.0.0.1,disable-ticketing") #Spice
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--channel" "spicevmc,target.address=127.0.0.1:${SPICE_PORT}")
+ #VIRT_INSTALL_PARAMS+=("--graphics" "spice,port=${SPICE_PORT}")
+ fi
+ fi
+ function waitForSpice() {
+ while true; do
+ if sudo lsof -i ":${SPICE_PORT}" | grep --quiet LISTEN &> /dev/null; then
+ break
+ fi
+ sleep 1
+ done
+ }
+ else
+ echo "> Not using Spice..."
+ fi
+}
+
+#####################################################################################
+###################### Check if spice client should be started ######################
+#####################################################################################
+function spiceClientCheck() {
+ if [ "$USE_SPICE_CLIENT" = "auto" ] && [ "$USE_SPICE" = true ]; then
+ if [ "$VM_ACTION" = "install" ]; then
+ USE_SPICE_CLIENT=true
+ elif [ "$USE_LOOKING_GLASS" = true ]; then
+ USE_SPICE_CLIENT=true
+ fi
+ fi
+}
+
+#####################################################################################
+############ Set QXL parameters if loaded display output plugin wants it ############
+#####################################################################################
+function setQxl() {
+ if [ "$USE_QXL" = true ]; then
+ echo "> Using QXL..."
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-device" "qxl,bus=pcie.0,addr=1c.4,id=video.2")
+ #QEMU_PARAMS+=("-vga" "qxl")
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--video" "qxl")
+ #-video qxl --channel spicevmc
+ fi
+ else
+ echo "> Not using QXL..."
+ fi
+}
+
+#####################################################################################
+####### Set Looking Glass parameters if loaded display output plugin wants it #######
+#####################################################################################
+function setUpLookingGlassParams() {
+ if [ "$USE_LOOKING_GLASS" = true ]; then
+ echo "> Using Looking Glass..."
+ echo "> Calculating required buffer size for ${LOOKING_GLASS_MAX_SCREEN_WIDTH}x${LOOKING_GLASS_MAX_SCREEN_HEIGHT} for Looking Glass..."
+ UNROUNDED_BUFFER_SIZE=$((($LOOKING_GLASS_MAX_SCREEN_WIDTH * $LOOKING_GLASS_MAX_SCREEN_HEIGHT * 4 * 2)/1024/1024+10))
+ BUFFER_SIZE=1
+ while [[ $BUFFER_SIZE -le $UNROUNDED_BUFFER_SIZE ]]; do
+ BUFFER_SIZE=$(($BUFFER_SIZE*2))
+ done
+ LOOKING_GLASS_BUFFER_SIZE="${BUFFER_SIZE}"
+ echo "> Looking Glass buffer size set to: ${LOOKING_GLASS_BUFFER_SIZE}MB"
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-device" "ivshmem-plain,memdev=ivshmem,bus=pcie.0")
+ QEMU_PARAMS+=("-object" "memory-backend-file,id=ivshmem,share=on,mem-path=/dev/shm/looking-glass,size=${LOOKING_GLASS_BUFFER_SIZE}M")
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./devices/shmem/@name=looking-glass")
+ VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./devices/shmem/model/@type=ivshmem-plain")
+ VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./devices/shmem/size=${LOOKING_GLASS_BUFFER_SIZE}")
+ VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./devices/shmem/size/@unit=M")
+ fi
+ #sudo bash -c "echo '#Type Path Mode UID GID Age Argument' > /etc/tmpfiles.d/10-looking-glass.conf"
+ #sudo bash -c "echo 'f /dev/shm/looking-glass 0660 qemu kvm - ' >> /etc/tmpfiles.d/10-looking-glass.conf"
+ #sudo systemd-tmpfiles --create --prefix=/dev/shm/looking-glass
+ else
+ echo "> Not using Looking Glass..."
+ fi
+}
+function autoConnectLookingGlass() {
+ while true; do
+ VM_IP="$(sudo nmap -sn -n ${NETWORK} -T5 | grep "MAC Address: ${MAC_ADDRESS}" -B 2 | head -1 | rev | cut -d' ' -f1 | rev)"
+ if [ "$VM_IP" != "" ]; then
+ while true; do
+ if nc -vz "$VM_IP" 3389 &> /dev/null; then
+ sleep 5
+ echo "> [Background task] Starting the Looking Glass client to connect with the VM..."
+ sudo -u "$(logname)" "${THIRDPARTY_DIR}/LookingGlass/client/build/looking-glass-client" -p "${SPICE_PORT}" 2>&1 | grep '^\[E\]' &
+ break
+ fi
+ sleep 1
+ done
+ break
+ fi
+ sleep 1
+ done
+}
+
+#####################################################################################
+########################## Set up fake battery if enabled ###########################
+#####################################################################################
+setUpFakeBattery() {
+ if [ "$USE_FAKE_BATTERY" = true ]; then
+ echo "> Using fake battery..."
+ if [ ! -f "${VM_FILES_DIR}/fake-battery.aml" ]; then
+ mv "${ACPI_TABLES_DIR}/fake-battery.aml" "${VM_FILES_DIR}/fake-battery.aml"
+ fi
+ FAKE_BATTERY_SSDT_TABLE="$(readlink -f "${VM_FILES_DIR}/fake-battery.aml")"
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-acpitable" "file=${FAKE_BATTERY_SSDT_TABLE}")
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--xml" "xpath.set=./os/acpi/table/@type=slic" "--xml" "xpath.set=./os/acpi/table=${VM_FILES_DIR}/fake-battery.aml")
+ fi
+ else
+ echo "> Not using fake battery..."
+ fi
+}
+
+#####################################################################################
+########### Create copy of OVMF_VARS_VM which is required for UEFI VMs #############
+#####################################################################################
+function createOvmfVarsCopy() {
+ if [ ! -f "${OVMF_VARS_VM}" ] || [ "$VM_ACTION" = "install" ]; then
+ echo "> Creating fresh OVMF_VARS copy for this VM..."
+ sudo rm -f "${OVMF_VARS_VM}"
+ sudo cp "${OVMF_VARS}" "${OVMF_VARS_VM}"
+ sudo chown "$(whoami):$(id -gn "$(whoami)")" "${OVMF_VARS_VM}"
+ fi
+}
+
+#####################################################################################
+####################### Patch OVMF with vBIOS ROM if enabled ########################
+#####################################################################################
+function patchOvmf() {
+ if [ "$PATCH_OVMF_WITH_VROM" = true ]; then
+ PATCHED_OVMF_FILES_DIR="${VM_FILES_DIR}/patched-ovmf-files"
+ if [ "$DGPU_ROM" != "" ]; then
+ echo "> Using patched OVMF..."
+ DGPU_ROM_NAME="$(basename "${DGPU_ROM}")"
+ if [ ! -f "${PATCHED_OVMF_FILES_DIR}/${DGPU_ROM_NAME}_OVMF_CODE.fd" ] || [ ! -f "${PATCHED_OVMF_FILES_DIR}/${DGPU_ROM_NAME}_OVMF_VARS.fd" ]; then
+ DGPU_ROM_DIR="$(dirname "${DGPU_ROM}")"
+ mkdir -p "${PATCHED_OVMF_FILES_DIR}/tmp-build"
+ sudo chown "$(whoami):$(id -gn "$(whoami)")" "${PATCHED_OVMF_FILES_DIR}"
+ echo "> Patching OVMF with your vBIOS ROM. This may take a few minutes!"
+ sleep 5 # Ensure the user can read this first
+ sudo service docker start
+ sudo docker run --rm -ti -v "${PATCHED_OVMF_FILES_DIR}/tmp-build:/build:z" -v "${DGPU_ROM_DIR}:/roms:z" -e "VROM=${DGPU_ROM_NAME}" ovmf-vbios-patch
+ sudo chown "$(whoami):$(id -gn "$(whoami)")" -R "${PATCHED_OVMF_FILES_DIR}/tmp-build"
+ sudo mv "${PATCHED_OVMF_FILES_DIR}/tmp-build/OVMF_CODE.fd" "${PATCHED_OVMF_FILES_DIR}/${DGPU_ROM_NAME}_OVMF_CODE.fd"
+ sudo mv "${PATCHED_OVMF_FILES_DIR}/tmp-build/OVMF_VARS.fd" "${PATCHED_OVMF_FILES_DIR}/${DGPU_ROM_NAME}_OVMF_VARS.fd"
+ sudo rm -rf "${PATCHED_OVMF_FILES_DIR}/tmp-build"
+ fi
+ OVMF_CODE="${PATCHED_OVMF_FILES_DIR}/${DGPU_ROM_NAME}_OVMF_CODE.fd"
+ if [ "$VM_ACTION" = "install" ]; then
+ echo "> Creating fresh copy of patched OVMF VARS..."
+ rm -f "${OVMF_VARS_VM}"
+ sudo cp "${PATCHED_OVMF_FILES_DIR}/${DGPU_ROM_NAME}_OVMF_VARS.fd" "${OVMF_VARS_VM}"
+ fi
+ #OVMF_VARS_VM="${PATCHED_OVMF_FILES_DIR}/${DGPU_ROM_NAME}_OVMF_VARS.fd"
+ else
+ echo "> Not using patched OVMF..."
+ fi
+ else
+ echo "> Not using patched OVMF..."
+ fi
+}
+
+#####################################################################################
+############################### Set OVMF parameters #################################
+#####################################################################################
+function setOvmfParams() {
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ QEMU_PARAMS+=("-drive" "if=pflash,format=raw,readonly=on,file=${OVMF_CODE}")
+ QEMU_PARAMS+=("-drive" "if=pflash,format=raw,file=${OVMF_VARS_VM}")
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ VIRT_INSTALL_PARAMS+=("--boot" "loader=${OVMF_CODE},loader.readonly=yes,loader.type=pflash,nvram.template=${OVMF_VARS_VM},loader_secure=no")
+ fi
+}
+
+#####################################################################################
+########################## Set up USB device passthrough ############################
+#####################################################################################
+function setUpUsbPassthrough() {
+ QEMU_PARAMS+=("-usb")
+ if [ -z "$USB_DEVICES" ]; then
+ echo "> Not using USB passthrough..."
+ USB_DEVICE_PARAMS=""
+ else
+ echo "> Using USB passthrough..."
+ IFS=';' read -a USB_DEVICES_ARRAY <<< "${USB_DEVICES}"
+ for USB_DEVICE in "${USB_DEVICES_ARRAY[@]}"; do
+ QEMU_PARAMS+=("-device" "usb-host,${USB_DEVICE}")
+ echo "> Passing USB device '${USB_DEVICE}' through..."
+ done
+ fi
+}
+
+#####################################################################################
+############################### Set up input method #################################
+#####################################################################################
+function setUpInputMethod() {
+ if [ "$VIRTUAL_INPUT_TYPE" = "virtio" ]; then
+ echo "> Using virtual input method 'virtio' for keyboard/mouse input..."
+ QEMU_PARAMS+=("-device" "virtio-keyboard-pci,bus=head.2,addr=03.0,display=video.2")
+ QEMU_PARAMS+=("-device" "virtio-mouse-pci,bus=head.2,addr=04.0,display=video.2")
+ elif [ "$VIRTUAL_INPUT_TYPE" = "usb-tablet" ]; then
+ echo "> Using virtual input method 'usb-tablet' for keyboard/mouse input..."
+ QEMU_PARAMS+=("-device" "usb-tablet")
+ else
+ echo "> Not using virtual input method for keyboard/mouse input..."
+ fi
+}
+
+#####################################################################################
+################################### Set up RDP ######################################
+#####################################################################################
+function setUpRdp() {
+ if [ "$USE_RDP" = true ] && [ "$NETWORK_MODE" != "none" ]; then
+ echo "> Using RDP..."
+ RDP_USER=Administrator
+ RDP_PASSWORD=admin
+ # Run it once because the first time it prints a useless message instead of actually encrypting
+ echo "$RDP_PASSWORD" | remmina --encrypt-password &> /dev/null
+ # Run it again, hoping it always works the second time
+ RDP_PASSWORD_ENCRYPTED="$(echo "$RDP_PASSWORD" | remmina --encrypt-password 2>&1 | grep 'Encrypted password: ' | cut -d':' -f2- | tr -d ' ')"
+
+ function autoConnectRdp() {
+ while true; do
+ VM_IP="$(sudo nmap -sn -n ${NETWORK} -T5 | grep "MAC Address: ${MAC_ADDRESS}" -B 2 | head -1 | rev | cut -d' ' -f1 | rev)"
+ if [ "$VM_IP" != "" ]; then
+ echo ""
+ echo "> [Background task] The IP address of the VM is: ${VM_IP}"
+ echo "> [Background task] Waiting for RDP to be available in the VM..."
+ while true; do
+ if nc -vz "$VM_IP" 3389 &> /dev/null; then
+ echo "> [Background task] Opening Remmina to start an RDP connection with the VM..."
+ remmina -c "rdp://${RDP_USER}:${RDP_PASSWORD_ENCRYPTED}@${VM_IP}" &> /dev/null &
+ break
+ fi
+ sleep 1
+ done
+ break
+ fi
+ sleep 1
+ done
+ }
+ else
+ echo "> Not using RDP..."
+ fi
+}
+
+#####################################################################################
+################# Load vfio-pci and bind dGPU to vfio-pci driver ####################
+#####################################################################################
+function vfioPci() {
+ if [ "$DRY_RUN" = false ]; then
+ if [ "$DGPU_PASSTHROUGH" = true ] || [ "$SHARE_IGPU" = true ]; then
+ echo "> Loading vfio-pci kernel module..."
+ sudo modprobe vfio
+ sudo modprobe vfio_pci
+ sudo modprobe vfio_iommu_type1
+ fi
+
+ if [ "$DGPU_PASSTHROUGH" = true ]; then
+ #echo "> Unbinding dGPU from ${HOST_DGPU_DRIVER} driver..."
+ #driver unbind
+ #echo "> Binding dGPU to VFIO driver..."
+ #driver bind "${DGPU_PCI_ADDRESS}" "vfio-pci"
+
+ IOMMU_GROUP="$(echo "$LSIOMMU_OUTPUT" | grep "${DGPU_PCI_ADDRESS}" | cut -d' ' -f3)"
+ echo "> IOMMU group for passthrough is ${IOMMU_GROUP}"
+
+ LSPCI_OUTPUT="$(sudo ${OPTIRUN_PREFIX}lspci)"
+ LSIOMMU_OUTPUT="$(lsiommu)"
+ IOMMU_GROUP="$(echo "$LSIOMMU_OUTPUT" | grep "${DGPU_PCI_ADDRESS}" | cut -d' ' -f3)"
+ DGPU_IOMMU_GROUP_DEVICES=$(echo "$LSIOMMU_OUTPUT" | grep "IOMMU Group ${IOMMU_GROUP} " | grep -v "PCI bridge" | grep -v "ISA bridge")
+ DGPU_FUNCTION_DEVICES=$(echo "$LSIOMMU_OUTPUT" | grep " ${DGPU_PCI_ADDRESS::-1}" | grep -v "PCI bridge" | grep -v "ISA bridge" | grep -v "${DGPU_PCI_ADDRESS}" | grep -v ^$)
+ DEVICES_TO_REBIND="$(echo -e "${DGPU_IOMMU_GROUP_DEVICES}\n${DGPU_FUNCTION_DEVICES}" | sort | uniq | grep -v ^$)"
+ while IFS= read -r deviceInfo; do
+ deviceName="$(echo "$deviceInfo" | cut -d ' ' -f4-)"
+ deviceAddress="$(echo "$deviceInfo" | cut -d ' ' -f4)"
+ echo "> Unbinding device '${deviceName}' from its driver, then bind it to the vfio-pci driver..."
+ sudo driverctl --nosave set-override "0000:${deviceAddress}" vfio-pci
+ done <<< "$DEVICES_TO_REBIND"
+
+ while IFS= read -r deviceInfo; do
+ if [ "${deviceInfo}" != "" ]; then
+ echo "> Passing through $deviceInfo"
+ deviceAddress="$(echo "$deviceInfo" | cut -d ' ' -f4)"
+ QEMU_PARAMS+=("-device" "vfio-pci,host=${deviceAddress}")
+ fi
+ done <<< "$DGPU_FUNCTION_DEVICES"
+
+ #sudo bash -c "echo 'options vfio-pci ids=${DGPU_VENDOR_ID}:${DGPU_DEVICE_ID}' > '/etc/modprobe.d/vfio.conf'"
+ # TODO: Make sure to also do the rebind for the other devices that are in the same iommu group (exclude stuff like PCI Bridge root ports that don't have vfio drivers)
+ fi
+ fi
+}
+
+#####################################################################################
+############ Clean up before creating a new VM when action is install ###############
+#####################################################################################
+function preCleanUp() {
+ if [ "$VM_ACTION" = "install" ]; then
+ echo "> Deleting VM if it already exists..."
+ sudo virsh destroy --domain "${VM_NAME}" &> /dev/null
+ sudo virsh undefine --domain "${VM_NAME}" --nvram &> /dev/null
+ fi
+}
+
+#####################################################################################
+########################## Start a few background tasks #############################
+#####################################################################################
+function startBackgroundTasks() {
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ if [ "$DRY_RUN" = false ]; then
+ if [ "$VM_ACTION" = "install" ]; then
+ echo "> Repeatedly sending keystrokes to the new VM for 30 seconds to ensure the Windows ISO boots..."
+ QEMU_PARAMS+=("-monitor" "unix:/tmp/${VM_NAME}-monitor,server,nowait")
+ bash -c "for i in {1..30}; do echo 'sendkey home' | sudo socat - 'UNIX-CONNECT:/tmp/${VM_NAME}-monitor'; sleep 1; done" &> /dev/null &
+ fi
+
+ if [ "$USE_SPICE_CLIENT" = true ]; then
+ echo "> [Background task] Starting the spice client at localhost:${SPICE_PORT}..."
+ bash -c "sleep 2; spicy -h localhost -p ${SPICE_PORT}" &> /dev/null &
+ fi
+ fi
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ if [ "$DRY_RUN" = false ]; then
+ if [ "$VM_ACTION" = "install" ]; then
+ echo "> Repeatedly sending keystrokes to the new VM for 30 seconds to ensure the Windows ISO boots..."
+ bash -c "for i in {1..30}; do sudo virsh send-key ${VM_NAME} KEY_HOME; sleep 1; done" &> /dev/null &
+ fi
+ fi
+ fi
+ if [ "$USE_RDP" = true ] && [ "$NETWORK_MODE" != "none" ]; then
+ echo "> [Background task] Starting RDP autoconnect..."
+ autoConnectRdp &
+ fi
+ if [ "$USE_LOOKING_GLASS" = true ]; then
+ echo "> [Background task] Starting the Looking Glass client..."
+ #while true; do sleep 1 && echo "lg" && sudo lsof -i ":${SPICE_PORT}" | grep --quiet LISTEN &> /dev/null && sleep 5 && sudo -u "$(logname)" "${THIRDPARTY_DIR}/LookingGlass/client/build/looking-glass-client" -p "${SPICE_PORT}" 2>&1 | grep '^\[E\]'; done &
+ autoConnectLookingGlass &
+ fi
+}
+
+#####################################################################################
+################################## Start the VM #####################################
+#####################################################################################
+function startVm() {
+ if [ "$VM_START_MODE" = "qemu" ]; then
+ if [ "$DRY_RUN" = true ]; then
+ echo "> Generating qemu-system-x86_64 command (dry-run)..."
+ echo ""
+ printf "sudo qemu-system-x86_64"
+ for param in "${QEMU_PARAMS[@]}"; do
+ if [[ "${param}" == -* ]]; then
+ printf " \\\\\n ${param}"
+ elif [[ $param = *" "* ]]; then
+ printf " \"${param}\""
+ else
+ printf " ${param}"
+ fi
+ done
+ echo ""
+ echo ""
+ else
+ echo "> Starting the Virtual Machine using qemu..."
+ sudo qemu-system-x86_64 "${QEMU_PARAMS[@]}"
+ fi
+ elif [ "$VM_START_MODE" = "virt-install" ]; then
+ #VIRT_INSTALL_PARAMS+=("--debug")
+ for param in "${QEMU_PARAMS[@]}"; do
+ VIRT_INSTALL_PARAMS+=("--qemu-commandline='${param}'")
+ done
+
+ if [ "$DRY_RUN" = true ]; then
+ echo "> Generating virt-install command (dry-run)..."
+ echo ""
+ printf "sudo virt-install"
+ for param in "${VIRT_INSTALL_PARAMS[@]}"; do
+ if [[ "${param}" == -* ]]; then
+ printf " \\\\\n ${param}"
+ elif [[ $param = *" "* ]]; then
+ printf " \"${param}\""
+ else
+ printf " ${param}"
+ fi
+ done
+ echo ""
+ echo ""
+ elif [ "$GET_XML" = true ]; then
+ VIRT_INSTALL_PARAMS+=("--print-xml")
+ sudo virt-install "${VIRT_INSTALL_PARAMS[@]}"
+ elif [ "$VM_ACTION" = "install" ]; then
+ echo "> Starting the Virtual Machine using virt-install..."
+ sudo virt-install "${VIRT_INSTALL_PARAMS[@]}"
+ elif [ "$VM_ACTION" = "start" ]; then
+ echo "> Starting the Virtual Machine using virsh..."
+ sudo virsh start "${VM_NAME}"
+ fi
+ fi
+}
+
+#####################################################################################
+############### The function below gets executed when the vm exits ##################
+#####################################################################################
+function onExit() {
+ echo "Cleaning up..."
+ if [ "$DGPU_PASSTHROUGH" = true ]; then
+ #echo "> Unbinding dGPU from vfio driver..."
+ #driver unbind "${DGPU_PCI_ADDRESS}"
+ #if [ "$HOST_DGPU_DRIVER" = "nvidia" ] || [ "$HOST_DGPU_DRIVER" = "nouveau" ]; then
+ # echo "> Turn the dGPU off using bumblebee..."
+ # sudo bash -c "echo 'OFF' >> /proc/acpi/bbswitch"
+ #fi
+ #echo "> Binding dGPU back to ${HOST_DGPU_DRIVER} driver..."
+ #driver bind "${DGPU_PCI_ADDRESS}" "${HOST_DGPU_DRIVER}"
+ while IFS= read -r deviceInfo; do
+ deviceName="$(echo "$deviceInfo" | cut -d ' ' -f4-)"
+ deviceAddress="$(echo "$deviceInfo" | cut -d ' ' -f4)"
+ echo "> Unbinding device '${deviceName} from the vfio-pci driver, then bind it back to its original driver..."
+ sudo driverctl --nosave unset-override "0000:${deviceAddress}"
+ done <<< "$DEVICES_TO_REBIND"
+
+ fi
+
+ if [ "$VGPU_UUID" != "" ]; then
+ echo "> Keeping Intel vGPU for next VM start..."
+
+ # FIXME: There is a bug in Linux that prevents creating new vGPUs without rebooting after removing one.
+ # So for now we can't create a new vGPU every time the VM starts.
+ #echo "> Remove Intel vGPU..."
+ #vgpu remove "${IGPU_PCI_ADDRESS}" "${VGPU_UUID}"
+
+ fi
+
+ if [ "$VM_ACTION" = "install" ]; then
+ if sudo fdisk -lu "${DRIVE_IMG}" 2> /dev/null | grep --quiet 'Microsoft'; then
+ if [ "$ORIGINAL_VM_ACTION" = "auto" ]; then
+ sudo "${MAIN_SCRIPTS_DIR}/vm.sh" start
+ fi
+ exit 0
+ else
+ echo "> [Error] Seems like the installation failed..."
+ exit 1
+ fi
+ fi
+
+ stty sane
+ kill $(jobs -p) &> /dev/null
+ stty sane
+}
+
+
+setMiscParams
+setUpNetworking
+setCpuCores
+setRamSize
+setInstallMediaParam
+setHelperIsoParam
+setUpOsDrive
+bumblebeeCheck
+setUpSambaShare
+setDGpuParams
+vGpuSetup
+loadDisplayOutputPlugin
+setIGpuParams
+setSpiceParams
+spiceClientCheck
+setQxl
+setUpLookingGlassParams
+setUpFakeBattery
+createOvmfVarsCopy
+patchOvmf
+setOvmfParams
+setUpUsbPassthrough
+setUpInputMethod
+setUpRdp
+trap onExit EXIT
+vfioPci
+preCleanUp
+startBackgroundTasks
+startVm
diff --git a/scripts/setup.sh b/scripts/setup.sh
deleted file mode 100755
index f5cd48b..0000000
--- a/scripts/setup.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="$(readlink -f "${SCRIPT_DIR}/..")"
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-
-mkdir -p "${PROJECT_DIR}/thirdparty"
-
-source "$DISTRO_UTILS_DIR/kernel-param-utils"
-
-sudo $DISTRO_UTILS_DIR/install-dependencies
-sudo $UTILS_DIR/set-kernel-params
-
-
-source "$UTILS_DIR/gpu-check"
-
-sudo $UTILS_DIR/ovmf-vbios-patch-setup
-
-if [ $HAS_INTEL_GPU = true ]; then
- sudo $DISTRO_UTILS_DIR/intel-setup
-fi
-if [ $HAS_AMD_GPU = true ]; then
- sudo $DISTRO_UTILS_DIR/amd-setup
-fi
-if [ $HAS_NVIDIA_GPU = true ]; then
- sudo $DISTRO_UTILS_DIR/nvidia-setup
-fi
-if [ $SUPPORTS_OPTIMUS = true ]; then
- sudo $DISTRO_UTILS_DIR/bumblebee-setup
-fi
-
-sudo $UTILS_DIR/build-fake-battery-ssdt
-
-sudo $DISTRO_UTILS_DIR/vbios-finder-installer
-
-sudo $DISTRO_UTILS_DIR/looking-glass-setup
-
-echo "Make sure you didn't get any critical errors above."
-echo "Then reboot!"
-echo "After the reboot you can check if your device is compatible by running: ./mbpt.sh check"
diff --git a/scripts/start-vm.sh b/scripts/start-vm.sh
deleted file mode 100755
index 22d749d..0000000
--- a/scripts/start-vm.sh
+++ /dev/null
@@ -1,318 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="$(readlink -f "${SCRIPT_DIR}/..")"
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-
-# If user.conf doesn't exist use the default.conf
-if [ -f "${PROJECT_DIR}/user.conf" ]; then
- echo "> Loading config from ${PROJECT_DIR}/user.conf"
- source "${PROJECT_DIR}/user.conf"
-elif [ -f "${PROJECT_DIR}/default.conf" ]; then
- echo "> Warning: No user.conf found, falling back to default.conf"
- echo "> Loading config from ${PROJECT_DIR}/default.conf"
- source "${PROJECT_DIR}/default.conf"
-else
- echo "> Error: No user.conf or user.conf found!"
- exit
-fi
-
-#source "$UTILS_DIR/gpu-check"
-shopt -s expand_aliases
-alias driver="sudo $UTILS_DIR/driver-util"
-alias vgpu="sudo $UTILS_DIR/vgpu-util"
-
-
-if [[ ${DRIVE_IMG} == /dev/* ]] ; then
- echo "> Using a physical OS drive..."
- OS_DRIVE_PARAM="-drive file=${DRIVE_IMG},if=virtio -snapshot"
- #OS_DRIVE_PARAM="-drive file=/dev/sda,if=virtio -drive file=/dev/sdb,if=virtio -drive file=/dev/sdc,if=virtio -drive file=/dev/sdd,if=virtio -snapshot"
-elif [[ ${DRIVE_IMG} == *.img ]] ; then
- echo "> Using a virtual OS drive..."
- if [ ! -f "${DRIVE_IMG}" ]; then
- #sudo $DISTRO_UTILS_DIR/prepare-vm
- echo "> Creating a virtual disk for the VM..."
- qemu-img create -f raw "${DRIVE_IMG}" "${VM_DISK_SIZE}"
- fi
- OS_DRIVE_PARAM="-drive id=disk0,if=virtio,cache.direct=on,if=virtio,aio=native,format=raw,file=${DRIVE_IMG}"
-else
- echo "> Error: It appears that no proper OS drive (image) has been provided. Check your 'DRIVE_IMG' var: '${DRIVE_IMG}'"
- exit
-fi
-
-if [ ! -f "${OVMF_VARS_VM}" ]; then
- echo "> Creating OVMF_VARS copy for this VM..."
- sudo cp "${OVMF_VARS}" "${OVMF_VARS_VM}"
-fi
-
-if sudo which optirun &> /dev/null && sudo optirun echo > /dev/null ; then
- OPTIRUN_PREFIX="optirun "
- DRI_PRIME_PREFIX=""
- echo "> Bumblebee works fine on this system. Using optirun when necessary..."
-else
- OPTIRUN_PREFIX=""
- if [ "$SUPPORTS_DRI_PRIME" = true ]; then
- DRI_PRIME_PREFIX="DRI_PRIME=1 "
- else
- echo "> Warning: Bumblebee is not available or doesn't work properly. Continuing anyway..."
- fi
-fi
-
-echo "> Retrieving and parsing DGPU IDs..."
-DGPU_IDS=$(export DRI_PRIME=1 && sudo ${OPTIRUN_PREFIX}lspci -n -s "${DGPU_PCI_ADDRESS}" | grep -oP "\w+:\w+" | tail -1)
-DGPU_VENDOR_ID=$(echo "${DGPU_IDS}" | cut -d ":" -f1)
-DGPU_DEVICE_ID=$(echo "${DGPU_IDS}" | cut -d ":" -f2)
-DGPU_SS_IDS=$(export DRI_PRIME=1 && sudo ${OPTIRUN_PREFIX}lspci -vnn -d "${DGPU_IDS}" | grep "Subsystem:" | grep -oP "\w+:\w+")
-DGPU_SS_VENDOR_ID=$(echo "${DGPU_SS_IDS}" | cut -d ":" -f1)
-DGPU_SS_DEVICE_ID=$(echo "${DGPU_SS_IDS}" | cut -d ":" -f2)
-
-if [ -z "$DGPU_IDS" ]; then
- echo "> Error: Failed to retrieve DGPU IDs!"
- echo "> DGPU_PCI_ADDRESS: ${DGPU_PCI_ADDRESS}"
- echo "> DGPU_IDS: $DGPU_IDS"
- echo "> DGPU_VENDOR_ID: $DGPU_VENDOR_ID"
- echo "> DGPU_DEVICE_ID: $DGPU_DEVICE_ID"
- echo "> DGPU_SS_IDS: $DGPU_SS_IDS"
- echo "> DGPU_SS_VENDOR_ID: $DGPU_SS_VENDOR_ID"
- echo "> DGPU_SS_DEVICE_ID: $DGPU_SS_DEVICE_ID"
- exit
-fi
-
-echo "> Loading vfio-pci kernel module..."
-sudo modprobe vfio-pci
-
-if [ "$USE_LOOKING_GLASS" = true ] ; then
- echo "> Using Looking Glass..."
- echo "> Calculating required buffer size for ${LOOKING_GLASS_MAX_SCREEN_WIDTH}x${LOOKING_GLASS_MAX_SCREEN_HEIGHT} for Looking Glass..."
- UNROUNDED_BUFFER_SIZE=$((($LOOKING_GLASS_MAX_SCREEN_WIDTH * $LOOKING_GLASS_MAX_SCREEN_HEIGHT * 4 * 2)/1024/1024+10))
- BUFFER_SIZE=1
- while [[ $BUFFER_SIZE -le $UNROUNDED_BUFFER_SIZE ]]; do
- BUFFER_SIZE=$(($BUFFER_SIZE*2))
- done
- LOOKING_GLASS_BUFFER_SIZE="${BUFFER_SIZE}M"
- echo "> Looking Glass buffer size set to: ${LOOKING_GLASS_BUFFER_SIZE}"
- LOOKING_GLASS_DEVICE_PARAM="-device ivshmem-plain,memdev=ivshmem,bus=pcie.0"
- LOOKING_GLASS_OBJECT_PARAM="-object memory-backend-file,id=ivshmem,share=on,mem-path=/dev/shm/looking-glass,size=${LOOKING_GLASS_BUFFER_SIZE}"
-else
- echo "> Not using Looking Glass..."
- LOOKING_GLASS_DEVICE_PARAM=""
- LOOKING_GLASS_OBJECT_PARAM=""
-fi
-
-if [ -z "$DGPU_ROM" ]; then
- echo "> Not using DGPU vBIOS override..."
- DGPU_ROM_PARAM=",rombar=0"
-else
- echo "> Using DGPU vBIOS override..."
- DGPU_ROM_PARAM=",romfile=${DGPU_ROM}"
-fi
-
-if [ -z "$IGPU_ROM" ]; then
- echo "> Not using DGPU vBIOS override..."
- IGPU_ROM_PARAM=",rombar=0"
-else
- echo "> Using DGPU vBIOS override..."
- IGPU_ROM_PARAM=",romfile=${IGPU_ROM}"
-fi
-
-if [ -z "$SMB_SHARE_FOLDER" ]; then
- echo "> Not using SMB share..."
- SMB_SHARE_PARAM=""
-else
- echo "> Using SMB share..."
- SMB_SHARE_PARAM="-net user,smb=${SMB_SHARE_FOLDER}"
-fi
-
-if [ "$DGPU_PASSTHROUGH" = true ] ; then
- echo "> Using dGPU passthrough..."
- echo "> Unbinding dGPU from ${HOST_DGPU_DRIVER} driver..."
- driver unbind "${DGPU_PCI_ADDRESS}"
- echo "> Binding dGPU to VFIO driver..."
- driver bind "${DGPU_PCI_ADDRESS}" "vfio-pci"
- #sudo bash -c "echo 'options vfio-pci ids=${DGPU_VENDOR_ID}:${DGPU_DEVICE_ID}' > '/etc/modprobe.d/vfio.conf'"
- # TODO: Make sure to also do the rebind for the other devices that are in the same iommu group (exclude stuff like PCI Bridge root ports that don't have vfio drivers)
- DGPU_ROOT_PORT_PARAM="-device ioh3420,bus=pcie.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1"
- DGPU_PARAM="-device vfio-pci,host=${DGPU_PCI_ADDRESS},bus=root.1,addr=00.0,x-pci-sub-device-id=0x${DGPU_SS_DEVICE_ID},x-pci-sub-vendor-id=0x${DGPU_SS_VENDOR_ID},multifunction=on${DGPU_ROM_PARAM}"
-else
- echo "> Not using dGPU passthrough..."
- DGPU_ROOT_PORT_PARAM=""
- DGPU_PARAM=""
-fi
-
-if [ "$SHARE_IGPU" = true ] ; then
- echo "> Using mediated iGPU passthrough..."
- vgpu init # load required kernel modules
-
- # FIXME: There is a bug in Linux that prevents creating new vGPUs without rebooting after removing one.
- # So for now we can't create a new vGPU every time the VM starts.
- #vgpu remove "${IGPU_PCI_ADDRESS}" &> /dev/null # Ensure there are no vGPUs before creating a new one
- VGPU_UUID="$(vgpu get "${IGPU_PCI_ADDRESS}" | head -1)"
- if [ "$VGPU_UUID" == "" ]; then
- echo "> Creating a vGPU for mediated iGPU passthrough..."
- VGPU_UUID="$(vgpu create "${IGPU_PCI_ADDRESS}")"
- if [ "$?" = "1" ]; then
- echo "> Failed creating a vGPU. Try again. If you still get this error, you have to reboot. This seems to be a bug in Linux."
- exit 1
- fi
- fi
-
- if [ "$USE_DMA_BUF" = true ] ; then
- echo "> Using dma-buf..."
- DMA_BUF_DISPLAY_PARAM="-display egl-headless" #"-display gtk,gl=on"
- GVTG_DISPLAY_STATE="on"
- else
- echo "> Not using dma-buf..."
- DMA_BUF_DISPLAY_PARAM=""
- GVTG_DISPLAY_STATE="off"
- fi
-
- GVTG_PARAM="-device vfio-pci,bus=pcie.0,addr=02.0,sysfsdev=/sys/bus/pci/devices/0000:${IGPU_PCI_ADDRESS}/${VGPU_UUID},x-igd-opregion=on${IGPU_ROM_PARAM},display=${GVTG_DISPLAY_STATE}"
-else
- echo "> Not using mediated iGPU passthrough..."
- GVTG_PARAM=""
- DMA_BUF_DISPLAY_PARAM=""
-fi
-
-if [ "$USE_SPICE" = true ] ; then
- echo "> Using spice on port ${SPICE_PORT}..."
- SPICE_PARAM="-spice port=${SPICE_PORT},addr=127.0.0.1,disable-ticketing"
-else
- echo "> Not using Spice..."
- SPICE_PARAM=""
-fi
-
-if [ "$USE_QXL" = true ] ; then
- echo "> Using QXL..."
- QXL_DEVICE_PARAM="-device qxl,bus=pcie.0,addr=1c.4,id=video.2"
- QXL_VGA_PARAM="-vga qxl"
-else
- echo "> Not using QXL..."
- QXL_DEVICE_PARAM=""
- QXL_VGA_PARAM=""
-fi
-
-if [ "$USE_FAKE_BATTERY" = true ] ; then
- echo "> Using fake battery..."
- if [ ! -f "${VM_FILES_DIR}/fake-battery.aml" ] ; then
- mv "${PROJECT_DIR}/acpi-tables/fake-battery.aml" "${VM_FILES_DIR}/fake-battery.aml"
- fi
- FAKE_BATTERY_SSDT_TABLE="$(readlink -f "${VM_FILES_DIR}/fake-battery.aml")"
- ACPI_TABLE_PARAM="-acpitable file=${FAKE_BATTERY_SSDT_TABLE}"
-else
- echo "> Not using fake battery..."
- ACPI_TABLE_PARAM=""
-fi
-
-if [ "$PATCH_OVMF_WITH_VROM" = true ] ; then
- PATCHED_OVMF_FILES_DIR="${VM_FILES_DIR}/patched-ovmf-files"
- if [ "$DGPU_ROM" != "" ] ; then
- echo "> Using patched OVMF..."
- DGPU_ROM_NAME="$(basename "${DGPU_ROM}")"
- if [ ! -f "${PATCHED_OVMF_FILES_DIR}/${DGPU_ROM_NAME}_OVMF_CODE.fd" ] || [ ! -f "${PATCHED_OVMF_FILES_DIR}/${DGPU_ROM_NAME}_OVMF_VARS.fd" ] ; then
- DGPU_ROM_DIR="$(dirname "${DGPU_ROM}")"
- mkdir -p "${PATCHED_OVMF_FILES_DIR}/tmp-build"
- echo "> Patching OVMF with your vBIOS ROM. This may take a few minutes!"
- sleep 5 # Ensure the user can read this first
- sudo docker run --rm -ti -v "${PATCHED_OVMF_FILES_DIR}/tmp-build:/build:z" -v "${DGPU_ROM_DIR}:/roms:z" -e "VROM=${DGPU_ROM_NAME}" ovmf-vbios-patch
- sudo mv "${PATCHED_OVMF_FILES_DIR}/tmp-build/OVMF_CODE.fd" "${PATCHED_OVMF_FILES_DIR}/${DGPU_ROM_NAME}_OVMF_CODE.fd"
- sudo mv "${PATCHED_OVMF_FILES_DIR}/tmp-build/OVMF_VARS.fd" "${PATCHED_OVMF_FILES_DIR}/${DGPU_ROM_NAME}_OVMF_VARS.fd"
- sudo rm -rf "${PATCHED_OVMF_FILES_DIR}/tmp-build"
- fi
- OVMF_CODE="${PATCHED_OVMF_FILES_DIR}/${DGPU_ROM_NAME}_OVMF_CODE.fd"
- OVMF_VARS_VM="${PATCHED_OVMF_FILES_DIR}/${DGPU_ROM_NAME}_OVMF_VARS.fd"
- else
- echo "> Not using patched OVMF..."
- fi
-else
- echo "> Not using patched OVMF..."
-fi
-
-if [ -z "$USB_DEVICES" ] ; then
- echo "> Not using USB passthrough..."
- USB_DEVICE_PARAMS=""
-else
- echo "> Using USB passthrough..."
- IFS=';' read -a USB_DEVICES_ARRAY <<< "${USB_DEVICES}"
- USB_DEVICE_PARAMS=""
- for USB_DEVICE in "${USB_DEVICES_ARRAY[@]}"; do
- USB_DEVICE_PARAMS="${USB_DEVICE_PARAMS} -device usb-host,${USB_DEVICE}"
- done
- echo "USB_DEVICE_PARAMS: $USB_DEVICE_PARAMS"
-fi
-
-if [ "$VIRTUAL_INPUT_TYPE" = "virtio" ] ; then
- echo "> Using virtual input method 'virtio' for keyboard/mouse input..."
- VIRTUAL_INPUT_PARAMS="-device virtio-keyboard-pci,bus=head.2,addr=03.0,display=video.2 -device virtio-mouse-pci,bus=head.2,addr=04.0,display=video.2"
-elif [ "$VIRTUAL_INPUT_TYPE" = "usb-tablet" ] ; then
- echo "> Using virtual input method 'usb-tablet' for keyboard/mouse input..."
- VIRTUAL_KEYBOARD_PARAM="-device usb-tablet"
-else
- echo "> Not using virtual input method for keyboard/mouse input..."
- VIRTUAL_KEYBOARD_PARAM=""
-fi
-
-echo "> Starting the Virtual Machine..."
-# Refer to https://github.com/saveriomiroddi/qemu-pinning for information on how to set your cpu affinity properly
-sudo qemu-system-x86_64 \
- -name "${VM_NAME}" \
- -machine type=q35,accel=kvm \
- -global ICH9-LPC.disable_s3=1 \
- -global ICH9-LPC.disable_s4=1 \
- -enable-kvm \
- -cpu host,kvm=off,hv_vapic,hv_relaxed,hv_spinlocks=0x1fff,hv_time,hv_vendor_id=12alphanum \
- -smp ${CPU_CORE_COUNT} \
- -m ${RAM_SIZE} \
- -mem-prealloc \
- -rtc clock=host,base=localtime \
- -nographic \
- -serial none \
- -parallel none \
- -boot menu=on \
- -boot order=c \
- -k en-us \
- ${SMB_SHARE_PARAM} \
- ${SPICE_PARAM} \
- -drive "if=pflash,format=raw,readonly=on,file=${OVMF_CODE}" \
- -drive "if=pflash,format=raw,file=${OVMF_VARS_VM}" \
- -drive "file=${INSTALL_IMG},index=1,media=cdrom" \
- -drive "file=${VIRTIO_WIN_IMG},index=2,media=cdrom" \
- -drive "file=${HELPER_ISO},index=3,media=cdrom" \
- ${OS_DRIVE_PARAM} \
- -netdev "type=tap,id=net0,ifname=tap0,script=${VM_FILES_DIR}/network-scripts/tap_ifup,downscript=${VM_FILES_DIR}/network-scripts/tap_ifdown,vhost=on" \
- ${GVTG_PARAM} \
- -device ich9-intel-hda \
- -device hda-output \
- ${DGPU_ROOT_PORT_PARAM} \
- ${DGPU_PARAM} \
- -device virtio-net-pci,netdev=net0,addr=19.0,mac=${MAC_ADDRESS} \
- -device pci-bridge,addr=12.0,chassis_nr=2,id=head.2 \
- ${ACPI_TABLE_PARAM} \
- -usb \
- ${VIRTUAL_KEYBOARD_PARAM} \
- ${USB_DEVICE_PARAMS} \
- ${LOOKING_GLASS_DEVICE_PARAM} \
- ${LOOKING_GLASS_OBJECT_PARAM} \
- ${QXL_DEVICE_PARAM} \
- ${QXL_VGA_PARAM} \
- ${DMA_BUF_DISPLAY_PARAM}
-
-# This gets executed when the vm exits
-if [ "$DGPU_PASSTHROUGH" = true ] ; then
- echo "> Unbinding dGPU from vfio driver..."
- driver unbind "${DGPU_PCI_ADDRESS}"
- if [ "$HOST_DGPU_DRIVER" = "nvidea" ] || [ "$HOST_DGPU_DRIVER" = "nuveau" ]; then
- echo "> Turn the dGPU off using bumblebee..."
- sudo bash -c "echo 'OFF' >> /proc/acpi/bbswitch"
- fi
- echo "> Binding dGPU back to ${HOST_DGPU_DRIVER} driver..."
- driver bind "${DGPU_PCI_ADDRESS}" "${HOST_DGPU_DRIVER}"
-fi
-if [ "$SHARE_IGPU" = true ] ; then
- # FIXME: There is a bug in Linux that prevents creating new vGPUs without rebooting after removing one.
- # So for now we can't create a new vGPU every time the VM starts.
- echo "> Keeping Intel vGPU for next VM start..."
- #echo "> Remove Intel vGPU..."
- #vgpu remove "${IGPU_PCI_ADDRESS}" "${VGPU_UUID}"
-fi
diff --git a/scripts/utils/common/libs/cpu-check b/scripts/utils/common/libs/cpu-check
new file mode 100644
index 0000000..a055c76
--- /dev/null
+++ b/scripts/utils/common/libs/cpu-check
@@ -0,0 +1,14 @@
+#####################################################################################################
+# This script is not meant to be executed. It should be `source`d.
+# It creates a bunch of variables telling you what kinds of CPUs the system has.
+# Use it like this: `source "./cpu-check.sh"`
+#####################################################################################################
+
+LSCPU_OUTPUT="$(sudo lscpu)"
+if echo -e "$LSCPU_OUTPUT" | grep "Model name: " | grep -qi "intel"; then
+ export HAS_INTEL_CPU=true
+fi
+
+if echo -e "$LSCPU_OUTPUT" | grep "Model name: " | grep -qi "AMD"; then
+ export HAS_AMD_CPU=true
+fi
\ No newline at end of file
diff --git a/utils/gpu-check b/scripts/utils/common/libs/gpu-check
old mode 100755
new mode 100644
similarity index 59%
rename from utils/gpu-check
rename to scripts/utils/common/libs/gpu-check
index 20499b6..2691b12
--- a/utils/gpu-check
+++ b/scripts/utils/common/libs/gpu-check
@@ -1,4 +1,8 @@
-#!/usr/bin/env bash
+#####################################################################################################
+# This script is not meant to be executed. It should be `source`d.
+# It creates a bunch of variables telling you what kinds of GPUs the system has.
+# Use it like this: `source "./gpu-check.sh"`
+#####################################################################################################
LSHW_DISPLAY_OUTPUT="$(sudo lshw -C display)"
if echo -e "$LSHW_DISPLAY_OUTPUT" | grep " vendor: " | grep -qi "intel"; then
diff --git a/scripts/utils/common/libs/helpers b/scripts/utils/common/libs/helpers
new file mode 100644
index 0000000..d02c5fb
--- /dev/null
+++ b/scripts/utils/common/libs/helpers
@@ -0,0 +1,64 @@
+#####################################################################################################
+# This script has to be sourced and is not meant to be executed directly!
+# How to use: Insert the following two lines without the `#` symbols below the shebang of all scripts in this project that need it:
+# while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+# source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+#####################################################################################################
+
+
+SCRIPTS_DIR="${PROJECT_DIR}/scripts"
+ MAIN_SCRIPTS_DIR="${SCRIPTS_DIR}/main"
+ UTILS_DIR="${SCRIPTS_DIR}/utils"
+ COMMON_UTILS_DIR="${UTILS_DIR}/common"
+ COMMON_UTILS_LIBS_DIR="${COMMON_UTILS_DIR}/libs"
+ COMMON_UTILS_PLUGINS_DIR="${COMMON_UTILS_DIR}/plugins"
+ COMMON_UTILS_SETUP_DIR="${COMMON_UTILS_DIR}/setup"
+ COMMON_UTILS_TOOLS_DIR="${COMMON_UTILS_DIR}/tools"
+ DISTRO_UTILS_DIR="${UTILS_DIR}/distro-specific/$("${COMMON_UTILS_TOOLS_DIR}/distro-info" --exclude-version)"
+ DISTRO_VERSION_UTILS_DIR="${UTILS_DIR}/distro-specific/$("${COMMON_UTILS_TOOLS_DIR}/distro-info")"
+ MANAGER_UTILS_DIR="${UTILS_DIR}/manager-specific"
+ INITRAMFS_MANAGER="${MANAGER_UTILS_DIR}/initramfs/$(sudo "${COMMON_UTILS_TOOLS_DIR}/get-manager" initramfs)"
+ SERVICE_MANAGER="${MANAGER_UTILS_DIR}/service/$("${COMMON_UTILS_TOOLS_DIR}/get-manager" service)"
+ KERNEL_PARAM_MANAGER="${MANAGER_UTILS_DIR}/kernelparams/$(sudo "${COMMON_UTILS_TOOLS_DIR}/get-manager" kernelparams)"
+ PACKAGE_MANAGER="${MANAGER_UTILS_DIR}/package/$("${COMMON_UTILS_TOOLS_DIR}/get-manager" package)"
+ GUI_TERMINAL="${MANAGER_UTILS_DIR}/gui-terminal/$("${COMMON_UTILS_TOOLS_DIR}/get-manager" gui-terminal)"
+THIRDPARTY_DIR="${PROJECT_DIR}/thirdparty"
+ACPI_TABLES_DIR="${PROJECT_DIR}/acpi-tables"
+HELPER_ISO_FILES_DIR="${PROJECT_DIR}/helper-iso-files"
+LIVE_ISO_FILES_DIR="${PROJECT_DIR}/live-iso-files"
+LOG_BASE_DIR="${PROJECT_DIR}/logs"
+
+C_NC='\033[0m' # No Color
+C_RED='\033[0;31m'
+C_GREEN='\033[0;32m'
+C_ORANGE='\033[1;33m'
+
+function echo_red() {
+ echo -e "${C_RED}$@${C_NC}"
+}
+function echo_green() {
+ echo -e "${C_GREEN}$@${C_NC}"
+}
+function echo_orange() {
+ echo -e "${C_ORANGE}$@${C_NC}"
+}
+function echo_white() {
+ echo -e "$@"
+}
+
+function loadConfig() {
+ # If user.conf doesn't exist use the default.conf
+ if [ -f "${PROJECT_DIR}/user.conf" ]; then
+ #echo "> Loading config from ${PROJECT_DIR}/user.conf"
+ source "${PROJECT_DIR}/user.conf"
+ elif [ -f "${PROJECT_DIR}/default.conf" ]; then
+ #echo "> Warning: No user.conf found, falling back to default.conf"
+ #echo "> Loading config from ${PROJECT_DIR}/default.conf"
+ source "${PROJECT_DIR}/default.conf"
+ else
+ #echo "> Error: No user.conf or user.conf found!"
+ exit
+ fi
+}
+
+shopt -s expand_aliases
diff --git a/scripts/utils/common/plugins/display-mode-1 b/scripts/utils/common/plugins/display-mode-1
new file mode 100644
index 0000000..71a555d
--- /dev/null
+++ b/scripts/utils/common/plugins/display-mode-1
@@ -0,0 +1,27 @@
+#####################################################################################################
+# This script has to be sourced and is not meant to be executed directly!
+# It sets the display output configuration.
+# How to use:
+# source "$PLUGIN_DIR/display-mode-x"
+#####################################################################################################
+
+if [ "$DMA_BUF_AVAILABLE" = true ]; then
+ USE_QXL=false
+ USE_DMA_BUF=true
+ USE_RDP=false
+ if [ "$VM_ACTION" = "start" ]; then
+ USE_LOOKING_GLASS=true
+ elif [ "$VM_ACTION" = "install" ]; then
+ USE_LOOKING_GLASS=false
+ fi
+else
+ USE_DMA_BUF=false
+ USE_RDP=true
+ if [ "$VM_ACTION" = "install" ]; then
+ USE_QXL=true
+ USE_LOOKING_GLASS=false
+ elif [ "$VM_ACTION" = "start" ]; then
+ USE_QXL=false
+ USE_LOOKING_GLASS=true
+ fi
+fi
\ No newline at end of file
diff --git a/scripts/utils/common/plugins/display-mode-2 b/scripts/utils/common/plugins/display-mode-2
new file mode 100644
index 0000000..bcfdfce
--- /dev/null
+++ b/scripts/utils/common/plugins/display-mode-2
@@ -0,0 +1,22 @@
+#####################################################################################################
+# This script has to be sourced and is not meant to be executed directly!
+# It sets the display output configuration.
+# How to use:
+# source "$PLUGIN_DIR/display-mode-x"
+#####################################################################################################
+
+RDP=true
+if [ "$DMA_BUF_AVAILABLE" = true ]; then
+ USE_LOOKING_GLASS=true
+ USE_DMA_BUF=true
+ USE_QXL=false
+else
+ USE_DMA_BUF=false
+ if [ "$VM_ACTION" = "install" ]; then
+ USE_QXL=true
+ USE_LOOKING_GLASS=false
+ elif [ "$VM_ACTION" = "start" ]; then
+ USE_QXL=false
+ USE_LOOKING_GLASS=true
+ fi
+fi
\ No newline at end of file
diff --git a/scripts/utils/common/plugins/display-mode-3 b/scripts/utils/common/plugins/display-mode-3
new file mode 100644
index 0000000..b318a73
--- /dev/null
+++ b/scripts/utils/common/plugins/display-mode-3
@@ -0,0 +1,24 @@
+#####################################################################################################
+# This script has to be sourced and is not meant to be executed directly!
+# It sets the display output configuration.
+# How to use:
+# source "$PLUGIN_DIR/display-mode-x"
+#####################################################################################################
+
+if [ "$VM_ACTION" = "install" ]; then
+ USE_LOOKING_GLASS=false
+ USE_RDP=false
+ if [ "$DMA_BUF_AVAILABLE" = true ]; then
+ USE_DMA_BUF=true
+ USE_QXL=false
+ elif [ "$VM_ACTION" = "start" ]; then
+ USE_DMA_BUF=false
+ USE_QXL=true
+ fi
+else
+ USE_SPICE_CLIENT=true
+ USE_LOOKING_GLASS=true
+ USE_RDP=true
+ USE_QXL=true
+ USE_DMA_BUF=false
+fi
\ No newline at end of file
diff --git a/scripts/utils/common/plugins/display-mode-4 b/scripts/utils/common/plugins/display-mode-4
new file mode 100644
index 0000000..6c4e2fe
--- /dev/null
+++ b/scripts/utils/common/plugins/display-mode-4
@@ -0,0 +1,22 @@
+#####################################################################################################
+# This script has to be sourced and is not meant to be executed directly!
+# It sets the display output configuration.
+# How to use:
+# source "$PLUGIN_DIR/display-mode-x"
+#####################################################################################################
+
+USE_LOOKING_GLASS=false
+
+if [ "$VM_ACTION" = "start" ]; then
+ USE_RDP=true
+elif [ "$VM_ACTION" = "install" ]; then
+ USE_RDP=false
+fi
+
+if [ "$DMA_BUF_AVAILABLE" = true ]; then
+ USE_QXL=false
+ USE_DMA_BUF=true
+else
+ USE_DMA_BUF=false
+ USE_RDP=true
+fi
\ No newline at end of file
diff --git a/scripts/utils/common/plugins/display-mode-5 b/scripts/utils/common/plugins/display-mode-5
new file mode 100644
index 0000000..2a02cf0
--- /dev/null
+++ b/scripts/utils/common/plugins/display-mode-5
@@ -0,0 +1,24 @@
+#####################################################################################################
+# This script has to be sourced and is not meant to be executed directly!
+# It sets the display output configuration.
+# How to use:
+# source "$PLUGIN_DIR/display-mode-x"
+#####################################################################################################
+
+if [ "$VM_ACTION" = "install" ]; then
+ USE_LOOKING_GLASS=false
+ USE_RDP=false
+ if [ "$DMA_BUF_AVAILABLE" = true ]; then
+ USE_DMA_BUF=true
+ USE_QXL=false
+ elif [ "$VM_ACTION" = "start" ]; then
+ USE_DMA_BUF=false
+ USE_QXL=true
+ fi
+else
+ USE_SPICE_CLIENT=true
+ USE_LOOKING_GLASS=true
+ USE_RDP=true
+ USE_QXL=false
+ USE_DMA_BUF=false
+fi
\ No newline at end of file
diff --git a/scripts/utils/common/setup/build-fake-battery-ssdt b/scripts/utils/common/setup/build-fake-battery-ssdt
new file mode 100755
index 0000000..0f40132
--- /dev/null
+++ b/scripts/utils/common/setup/build-fake-battery-ssdt
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+
+#####################################################################################################
+# This script compiles the asm source code for the SSDT table that contains a fake battery for the VM.
+# Usage: `./build-fake-battery-ssdt`
+#####################################################################################################
+
+iasl "${ACPI_TABLES_DIR}/fake-battery.asl" # creates fake-battery.aml
\ No newline at end of file
diff --git a/utils/extract-vbios b/scripts/utils/common/setup/extract-vbios
similarity index 50%
rename from utils/extract-vbios
rename to scripts/utils/common/setup/extract-vbios
index 614a889..2d6bd7f 100755
--- a/utils/extract-vbios
+++ b/scripts/utils/common/setup/extract-vbios
@@ -1,13 +1,15 @@
#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
+#####################################################################################################
+# WARNING: THIS SCRIPT WORKS ON ALMOST NO SYSTEM
+# This script tries to extract the vBIOS ROM form your dGPU.
+# usage: `./extract-vbios`
+#####################################################################################################
-function extractNvideaVbios() {
+function extractNvidiaVbios() {
if which optirun ; then
USE_BUMBLEBEE=true
OPTIRUN_PREFIX="optirun "
@@ -17,13 +19,13 @@ function extractNvideaVbios() {
fi
if [ ! -f "${UTILS_DIR}/nvflash_linux" ]; then
NVFLASH_DOWNLOAD_ID=$(curl https://www.techpowerup.com/download/nvidia-nvflash/ | grep '_linux.zip' -A 5 | grep 'name="id" value="' | cut -d '"' -f6)
- wget --post-data "id=${NVFLASH_DOWNLOAD_ID}&server_id=2" https://www.techpowerup.com/download/nvidia-nvflash/ -O ${UTILS_DIR}/nvidia-nvflash.zip
- unzip ${UTILS_DIR}/nvidia-nvflash.zip -d ${UTILS_DIR}/
- rm -f ${UTILS_DIR}/nvidia-nvflash.zip
- chmod +x ${UTILS_DIR}/nvflash_linux
+ wget --post-data "id=${NVFLASH_DOWNLOAD_ID}&server_id=2" https://www.techpowerup.com/download/nvidia-nvflash/ -O ${THIRDPARTY_DIR}/nvidia-nvflash.zip
+ unzip ${THIRDPARTY_DIR}/nvidia-nvflash.zip -d ${THIRDPARTY_DIR}/
+ rm -f ${THIRDPARTY_DIR}/nvidia-nvflash.zip
+ chmod +x ${THIRDPARTY_DIR}/nvflash_linux
fi
mkdir -p "${VM_FILES_DIR}/vbios-roms"
- sudo ${OPTIRUN_PREFIX}${UTILS_DIR}/nvflash_linux --save ${VM_FILES_DIR}/vbios-roms/nvidea_vbios.rom
+ sudo ${OPTIRUN_PREFIX}${THIRDPARTY_DIR}/nvflash_linux --save ${VM_FILES_DIR}/vbios-roms/nvidia_vbios.rom
}
function extractVbios() {
@@ -36,5 +38,5 @@ function extractVbios() {
#echo "Attempting to extract the VBIOS ROM of the Nvidia GPU"
#echo "This will probably fail. If you know how to fix it please open an issue and tell me."
-#extractNvideaVbios
+#extractNvidiaVbios
extractVbios $1 $2
\ No newline at end of file
diff --git a/scripts/utils/common/setup/looking-glass-setup b/scripts/utils/common/setup/looking-glass-setup
new file mode 100755
index 0000000..2fcd025
--- /dev/null
+++ b/scripts/utils/common/setup/looking-glass-setup
@@ -0,0 +1,83 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+loadConfig
+
+LOOKING_GLASS_VERSION="B4"
+cd "${THIRDPARTY_DIR}"
+
+if [ ! -f "./LookingGlass" ]; then
+ # Get the source code
+ git clone --single-branch --branch "${LOOKING_GLASS_VERSION}" --depth 1 --recursive https://github.com/gnif/LookingGlass.git
+fi
+CURRENT_LG_VERSION="$(cd LookingGlass && git branch --show-current)"
+if [ "$CURRENT_LG_VERSION" != "$LOOKING_GLASS_VERSION" ]; then
+ # If an old version of Looking Glass is detected, delete the old source code and get a clean copy of the required one
+ rm -rf LookingGlass
+ git clone --single-branch --branch "${LOOKING_GLASS_VERSION}" --depth 1 --recursive https://github.com/gnif/LookingGlass.git
+fi
+
+# Clean up (remove old builds etc.)
+git clean -fdx
+
+# Build the (Linux) client application
+mkdir LookingGlass/client/build
+cd LookingGlass/client/build
+cmake ../
+make
+
+# Utilize systemd-tmpfiles to automatically set required permissions on /dev/shm/looking-glass
+sudo bash -c "echo '#Type Path Mode UID GID Age Argument' > /etc/tmpfiles.d/10-looking-glass.conf"
+sudo bash -c "echo 'f /dev/shm/looking-glass 0660 $(logname) kvm - ' >> /etc/tmpfiles.d/10-looking-glass.conf"
+sudo systemd-tmpfiles --create /etc/tmpfiles.d/10-looking-glass.conf
+
+# Adjust permissions for systems with AppArmor
+if [ -d "/etc/apparmor.d" ]; then
+ if ! sudo cat /etc/apparmor.d/local/abstractions/libvirt-qemu | grep --quiet '/dev/shm/looking-glass rw,'; then
+ sudo bash -c "echo '/dev/shm/looking-glass rw,' >> /etc/apparmor.d/local/abstractions/libvirt-qemu"
+ sudo systemctl restart apparmor
+ fi
+fi
+
+# Adjust permissions for systems with SELinux
+if [ -d "/etc/selinux" ]; then
+ TE_FILE="./lookingglass-fix-qemu.te"
+ MOD_FILE="./lookingglass-fix-qemu.mod"
+ PP_FILE="./lookingglass-fix-qemu.pp"
+ echo "module lookingglass-fix-qemu 1.0;" > "${TE_FILE}"
+ echo "" >> "${TE_FILE}"
+ echo "require {" >> "${TE_FILE}"
+ echo " type tmpfs_t;" >> "${TE_FILE}"
+ echo " type svirt_t;" >> "${TE_FILE}"
+ echo " class file { getattr map open };" >> "${TE_FILE}"
+ echo "}" >> "${TE_FILE}"
+ echo "" >> "${TE_FILE}"
+ echo "#============= svirt_t ==============" >> "${TE_FILE}"
+ echo "allow svirt_t tmpfs_t:file { getattr open };" >> "${TE_FILE}"
+ echo "" >> "${TE_FILE}"
+ echo "#!!!! This avc can be allowed using the boolean 'domain_can_mmap_files'" >> "${TE_FILE}"
+ echo "allow svirt_t tmpfs_t:file map;" >> "${TE_FILE}"
+
+ checkmodule -M -m -o "${MOD_FILE}" "${TE_FILE}"
+ semodule_package -o "${PP_FILE}" -m "${MOD_FILE}"
+ sudo semodule -i "${PP_FILE}"
+fi
+
+# Download the Nvidia Capture SDK if it hasn'T been downlaoded already
+cd "${THIRDPARTY_DIR}"
+if [ ! -f "./Capture_Linux_v8.0.4" ]; then
+ wget https://developer.nvidia.com/capture_sdk/downloads/v8.0.4/linux -O ./nvidia_capture_api.tgz
+ #rm -rf ./Capture_Linux_v8.0.4
+ tar -xvzf ./nvidia_capture_api.tgz
+ rm ./nvidia_capture_api.tgz
+fi
+
+# Build the (Windows) host application
+cp ./Capture_Linux_v8.0.4 ./LookingGlass/
+cd LookingGlass
+cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=./host/toolchain-mingw64.cmake -DNVFBC_SDK='./Capture_Linux_v8.0.4' -DUSE_NVFBC=1 ./host
+make
+
+#wget "https://ci.appveyor.com/api/projects/rainers/visuald/artifacts/cv2pdb.exe?job=Environment%3A%20os%3DVisual%20Studio%202015%2C%20VS%3D14%2C%20APPVEYOR_BUILD_WORKER_IMAGE%3DVisual%20Studio%202015" -O "cv2pdb.exe"
+#wine './cv2pdb.exe' './looking-glass-host.exe'
+makensis './platform/Windows/installer.nsi'
\ No newline at end of file
diff --git a/scripts/utils/common/setup/ovmf-vbios-patch-setup b/scripts/utils/common/setup/ovmf-vbios-patch-setup
new file mode 100755
index 0000000..9888f92
--- /dev/null
+++ b/scripts/utils/common/setup/ovmf-vbios-patch-setup
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+
+#####################################################################################################
+# This script builds a Docker image that allows us to patch OVMF_CODE.fd and OVMF_VARS.fd with your vBIOS ROM.
+# This helps circumvent Nvidia's Error 43 in some cases.
+# Usage: `./ovmf-vbios-patch-setup`
+#####################################################################################################
+
+cd "${THIRDPARTY_DIR}"
+
+sudo service docker start
+#rm -rf ovmf-with-vbios-patch
+#git clone https://github.com/T-vK/ovmf-with-vbios-patch.git
+#cd ovmf-with-vbios-patch
+#sudo docker build -t ovmf-vbios-patch .
+sudo docker pull 'tavk/ovmf-vbios-patch:1.0.1-edk2-stable201905' # Pull instead of build because the root partition of the Live version is too small.
+# TODO: Get rid of Docker and build this thing natively
\ No newline at end of file
diff --git a/utils/Fedora/34/vbios-finder-installer b/scripts/utils/common/setup/vbios-finder-setup
similarity index 58%
rename from utils/Fedora/34/vbios-finder-installer
rename to scripts/utils/common/setup/vbios-finder-setup
index 4438341..2e04cca 100755
--- a/utils/Fedora/34/vbios-finder-installer
+++ b/scripts/utils/common/setup/vbios-finder-setup
@@ -1,21 +1,14 @@
#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+loadConfig
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/../../.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-VM_FILES_DIR="${PROJECT_DIR}/vm-files"
-
-mkdir -p "${PROJECT_DIR}/thirdparty"
-cd "${PROJECT_DIR}/thirdparty"
+cd "${THIRDPARTY_DIR}"
rm -rf VBiosFinder
git clone https://github.com/coderobe/VBiosFinder.git
cd VBiosFinder
-sudo dnf install ruby rubygem-bundler ruby-devel p7zip innoextract upx -y
-
wget https://github.com/LongSoft/UEFITool/releases/download/A58/UEFIExtract_NE_A58_linux_x86_64.zip -O ./UEFIExtract.zip
unzip ./UEFIExtract.zip -d ./3rdparty/
rm -f ./UEFIExtract.zip
diff --git a/scripts/utils/common/tools/commands-available b/scripts/utils/common/tools/commands-available
new file mode 100755
index 0000000..3c83905
--- /dev/null
+++ b/scripts/utils/common/tools/commands-available
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+#####################################################################################################
+# Checks if all given commands are installed and if not print out the list of missing ones
+# Usage: `./commands-available`
+#####################################################################################################
+
+function commandsAvailable() {
+ commandsMissing=()
+ for currentCommand in $1; do
+ if ! command -v $currentCommand &> /dev/null; then
+ commandsMissing+=("$currentCommand")
+ fi
+ done
+ if ((${#commandsMissing[@]})); then
+ echo "Missing commands: ${commandsMissing[@]}"
+ return 1 # Some commands are missing
+ else
+ return 0
+ fi
+}
+
+commandsAvailable "$1"
\ No newline at end of file
diff --git a/utils/distro-info b/scripts/utils/common/tools/distro-info
similarity index 67%
rename from utils/distro-info
rename to scripts/utils/common/tools/distro-info
index e2e4cd5..f29322f 100755
--- a/utils/distro-info
+++ b/scripts/utils/common/tools/distro-info
@@ -1,5 +1,10 @@
#!/usr/bin/env bash
+#####################################################################################################
+# Determines which Linux distribution and version this is and echoes it out
+# Usage: `./distro-info`
+#####################################################################################################
+
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
@@ -32,4 +37,8 @@ else
VER=$(uname -r)
fi
-echo "${OS}/${VER}"
+if [ "$1" = "--exclude-version" ]; then
+ echo "${OS}"
+else
+ echo "${OS}/${VER}"
+fi
diff --git a/utils/download-windows-iso b/scripts/utils/common/tools/download-windows-iso
similarity index 56%
rename from utils/download-windows-iso
rename to scripts/utils/common/tools/download-windows-iso
index 2a059fb..d909d29 100755
--- a/utils/download-windows-iso
+++ b/scripts/utils/common/tools/download-windows-iso
@@ -1,5 +1,10 @@
#!/usr/bin/env bash
+#####################################################################################################
+# Downloads a Windows 10 ISO from Microsoft
+# Usage: `./download-windows-iso "/path/to/where/you/want/to/save/the/windows.iso" "x64"`
+#####################################################################################################
+
WIN10_IMG_DESTINATION="$1"
WIN10_IMG_ARCH="$2"
echo "$WIN10_IMG_DESTINATION"
@@ -16,7 +21,12 @@ echo "$WINDOWS_10_ISO_URL"
echo "Making sure the URL comes from a trusted Microsoft domain..."
if [[ $WINDOWS_10_ISO_URL == https://software-download.microsoft.com/* ]] ; then
echo "Downloading the Windows 10 installation iso..."
- wget "$WINDOWS_10_ISO_URL" -O "$WIN10_IMG_DESTINATION"
+ if [ ! -f "${WIN10_IMG_DESTINATION}" ]; then
+ wget "${WINDOWS_10_ISO_URL}" -c -O "${WIN10_IMG_DESTINATION}.part"
+ mv "${WIN10_IMG_DESTINATION}.part" "${WIN10_IMG_DESTINATION}"
+ else
+ echo "Skipping download because the Windows ISO already exists: ${WIN10_IMG_DESTINATION}"
+ fi
else
echo "URL validation failed. Please download the Windows 10 iso manually."
exit 1
diff --git a/utils/driver-util b/scripts/utils/common/tools/driver-util
similarity index 93%
rename from utils/driver-util
rename to scripts/utils/common/tools/driver-util
index 5d41c32..e9df171 100755
--- a/utils/driver-util
+++ b/scripts/utils/common/tools/driver-util
@@ -1,5 +1,10 @@
#!/usr/bin/env bash
+#####################################################################################################
+# A simple tool to make driverbinding easy.
+# Usage: `./driver-util --help`
+#####################################################################################################
+
COMMAND="$1"
# Get driver currently used by the given PCI device
@@ -95,8 +100,8 @@ if [ "$COMMAND" = "help" ] || [ "$COMMAND" = "--help" ] || [ "$COMMAND" = "-h" ]
echo " #Bind the vfio-pci driver to the device with address 01:00.0"
echo " driver-util bind 01:00.0 vfio-pci"
echo ""
- echo " #Bind the nvidea driver to the device with address 05:00.0"
- echo " driver-util bind 05:00.0 nvidea"
+ echo " #Bind the nvidia driver to the device with address 05:00.0"
+ echo " driver-util bind 05:00.0 nvidia"
echo ""
echo " #Bind the amdgpu driver to the device with address 02:00.0"
echo " driver-util bind 02:00.0 amdgpu"
diff --git a/scripts/utils/common/tools/get-manager b/scripts/utils/common/tools/get-manager
new file mode 100755
index 0000000..2dc3d08
--- /dev/null
+++ b/scripts/utils/common/tools/get-manager
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+
+#####################################################################################################
+# Determines how the system manages initramfs, packages, kernel parameters and services
+# Usage: `./get-manager service` # supports service, initramfs, kernelparams, package
+#####################################################################################################
+
+COMMAND="$1"
+
+if [ "$COMMAND" = "service" ]; then
+ if command -v "systemctl" &> /dev/null; then
+ echo "systemd"
+ elif command -v "service" &> /dev/null; then
+ echo "service"
+ elif command -v "initctl" &> /dev/null; then
+ echo "initctl"
+ #elif [ -d "/etc/init.d/" ] && command -v "service" &> /dev/null; then
+ # echo "sysvinit"
+ else
+ exit 1
+ fi
+elif [ "$COMMAND" = "initramfs" ]; then
+ if [ -d "/etc/dracut.conf.d/" ]; then
+ echo "dracut"
+ else
+ exit 1
+ fi
+elif [ "$COMMAND" = "kernelparams" ]; then
+ if [ -f "/etc/default/grub" ]; then
+ echo "grub"
+ else
+ exit 1
+ fi
+elif [ "$COMMAND" = "package" ]; then
+ if command -v dnf &> /dev/null; then
+ echo "dnf"
+ elif command -v yum &> /dev/null; then
+ echo "yum"
+ elif command -v apt-get &> /dev/null; then
+ echo "apt"
+ elif command -v pacman &> /dev/null; then
+ echo "pacman"
+ elif command -v zypper &> /dev/null; then
+ echo "zypper"
+ elif command -v emerge &> /dev/null; then
+ echo "emerge"
+ else
+ exit 1
+ fi
+elif [ "$COMMAND" = "gui-terminal" ]; then
+ if command -v gnome-terminal &> /dev/null; then
+ echo "gnome-terminal"
+ elif command -v konsole &> /dev/null; then
+ echo "konsole"
+ elif command -v x-terminal-emulator &> /dev/null; then
+ echo "x-terminal-emulator"
+ elif command -v st &> /dev/null; then
+ echo "st"
+ else
+ exit 1
+ fi
+fi
diff --git a/scripts/utils/common/tools/get-missing-executables b/scripts/utils/common/tools/get-missing-executables
new file mode 100755
index 0000000..f2f952d
--- /dev/null
+++ b/scripts/utils/common/tools/get-missing-executables
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+#####################################################################################################
+# Simple script to check which executables in a given list are not installed
+# Usage: `./get-missing-executables "curl git wget docker"`
+#####################################################################################################
+
+function getMissingExecutables() {
+ EXECUTABLES_MISSING=""
+ for CURRENT_EXECUTABLE in $1; do
+ if ! command -v $CURRENT_EXECUTABLE &> /dev/null; then
+ EXECUTABLES_MISSING+=" $CURRENT_EXECUTABLE"
+ fi
+ done
+ echo "$EXECUTABLES_MISSING"
+}
+
+getMissingExecutables "$1"
\ No newline at end of file
diff --git a/scripts/utils/common/tools/get-missing-files b/scripts/utils/common/tools/get-missing-files
new file mode 100755
index 0000000..f6eed8c
--- /dev/null
+++ b/scripts/utils/common/tools/get-missing-files
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+#####################################################################################################
+# Simple script to check which files in a given list do not exist
+# Usage: `./get-missing-files "curl git wget docker"`
+#####################################################################################################
+
+function getMissingFiles() {
+ FILES_MISSING=""
+ for CURRENT_FILE in $1; do
+ if [ ! -f "$CURRENT_FILE" ]; then
+ FILES_MISSING+=" $CURRENT_FILE"
+ fi
+ done
+ echo "$FILES_MISSING"
+}
+
+getMissingFiles "$1"
\ No newline at end of file
diff --git a/scripts/utils/common/tools/lsiommu b/scripts/utils/common/tools/lsiommu
new file mode 100755
index 0000000..7894ccd
--- /dev/null
+++ b/scripts/utils/common/tools/lsiommu
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+#####################################################################################################
+# Simple script to list all PCI devices and vGPUs by their IOMMU Group
+# Usage: `./lsiommu`
+#####################################################################################################
+
+shopt -s nullglob
+for d in /sys/kernel/iommu_groups/*/devices/*; do
+ n=${d#*/iommu_groups/*}; n=${n%%/*}
+ printf 'IOMMU Group %s ' "$n"
+ if [[ $d =~ "." ]]; then
+ lspci -nns "${d##*/}"
+ else
+ printf "$(readlink -f "${d}" | cut -d'/' -f5- | cut -d':' -f2-) Virtual GPU of: "
+ lspci -nns "$(basename "$(dirname "$(readlink -f "${d}")")")" | cut -d' ' -f2-
+ fi
+done;
diff --git a/scripts/utils/common/tools/runtime-kernel-has-params b/scripts/utils/common/tools/runtime-kernel-has-params
new file mode 100755
index 0000000..28bf749
--- /dev/null
+++ b/scripts/utils/common/tools/runtime-kernel-has-params
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+function runtimeKernelHasParam() {
+ cmdline="$(cat /proc/cmdline)"
+ [[ $cmdline =~ ^$1.* ]] || [[ $cmdline =~ .*$1$ ]] || [[ $cmdline = *" $1 "* ]]
+}
+
+function runtimeKernelHasParams() {
+ for param in $1; do
+ runtimeKernelHasParam "$param"
+ done
+}
+
+runtimeKernelHasParams "$1"
\ No newline at end of file
diff --git a/utils/vgpu-util b/scripts/utils/common/tools/vgpu-util
similarity index 96%
rename from utils/vgpu-util
rename to scripts/utils/common/tools/vgpu-util
index fcb14e8..2f0337d 100755
--- a/utils/vgpu-util
+++ b/scripts/utils/common/tools/vgpu-util
@@ -1,5 +1,10 @@
#!/usr/bin/env bash
+#####################################################################################################
+# Simple tool to manage vGPUs more easily
+# Usage: `./vgpu-tool`
+#####################################################################################################
+
COMMAND="$1"
# Load required kernel modules
diff --git a/scripts/utils/distro-specific/Ubuntu/pre-package-info-update b/scripts/utils/distro-specific/Ubuntu/pre-package-info-update
new file mode 100755
index 0000000..cb648db
--- /dev/null
+++ b/scripts/utils/distro-specific/Ubuntu/pre-package-info-update
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+
+sudo add-apt-repository -y universe
\ No newline at end of file
diff --git a/scripts/utils/distro-specific/Ubuntu/pre-package-install b/scripts/utils/distro-specific/Ubuntu/pre-package-install
new file mode 100755
index 0000000..07600a5
--- /dev/null
+++ b/scripts/utils/distro-specific/Ubuntu/pre-package-install
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+
+alias commandAvailable="${COMMON_UTILS_TOOLS_DIR}/commands-available"
+
+if ! commandAvailable "x86_64-w64-mingw32-g++"; then
+ sudo apt-get install -y g++-mingw-w64-x86-64-win32
+fi
+
+if ! commandAvailable "upx"; then
+ sudo apt-get install -y upx-ucl
+fi
\ No newline at end of file
diff --git a/scripts/utils/manager-specific/gui-terminal/gnome-terminal b/scripts/utils/manager-specific/gui-terminal/gnome-terminal
new file mode 100755
index 0000000..e554fb8
--- /dev/null
+++ b/scripts/utils/manager-specific/gui-terminal/gnome-terminal
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+
+COMMAND="$1"
+COMMAND_TO_EXECUTE="$2"
+
+if [ "$COMMAND" = "run-with-command" ]; then
+ gnome-terminal -- bash -c "$COMMAND_TO_EXECUTE"
+fi
diff --git a/scripts/utils/manager-specific/gui-terminal/konsole b/scripts/utils/manager-specific/gui-terminal/konsole
new file mode 100755
index 0000000..bf69d38
--- /dev/null
+++ b/scripts/utils/manager-specific/gui-terminal/konsole
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+
+COMMAND="$1"
+COMMAND_TO_EXECUTE="$2"
+
+if [ "$COMMAND" = "run-with-command" ]; then
+ konsole -e "$COMMAND_TO_EXECUTE"
+fi
diff --git a/scripts/utils/manager-specific/gui-terminal/st b/scripts/utils/manager-specific/gui-terminal/st
new file mode 100755
index 0000000..148248f
--- /dev/null
+++ b/scripts/utils/manager-specific/gui-terminal/st
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+
+COMMAND="$1"
+COMMAND_TO_EXECUTE="$2"
+
+if [ "$COMMAND" = "run-with-command" ]; then
+ st -e "$COMMAND_TO_EXECUTE"
+fi
diff --git a/scripts/utils/manager-specific/gui-terminal/x-terminal-emulator b/scripts/utils/manager-specific/gui-terminal/x-terminal-emulator
new file mode 100755
index 0000000..83ae614
--- /dev/null
+++ b/scripts/utils/manager-specific/gui-terminal/x-terminal-emulator
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+
+COMMAND="$1"
+COMMAND_TO_EXECUTE="$2"
+
+if [ "$COMMAND" = "run-with-command" ]; then
+ x-terminal-emulator -e "$COMMAND_TO_EXECUTE"
+fi
diff --git a/scripts/utils/manager-specific/initramfs/dracut b/scripts/utils/manager-specific/initramfs/dracut
new file mode 100755
index 0000000..0974369
--- /dev/null
+++ b/scripts/utils/manager-specific/initramfs/dracut
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+VFIO_CFG_PATH=/etc/dracut.conf.d/vfio.conf
+
+COMMAND="$1" # Supported commands: add-driver, apply
+PARAM="$2"
+
+function addInitramfsDriver() {
+ driver="$1"
+ sudo touch "$VFIO_CFG_PATH"
+ if ! sudo cat "$VFIO_CFG_PATH" | grep --quiet "add_driver+="; then
+ echo 'add_driver+=" "' >> "$VFIO_CFG_PATH"
+ fi
+ if ! sudo cat "$VFIO_CFG_PATH" | grep "add_driver+=" | grep --quiet -P "( |\")$driver( |\")"; then
+ sudo sed -i "s/^add_driver+=\" \{0,1\}/&$driver /" "$VFIO_CFG_PATH"
+ echo "addDriverToInitramfs: Added \"$driver\" to add_driver in $VFIO_CFG_PATH"
+ else
+ echo "addDriverToInitramfs: No action required. \"$driver\" already exists in add_driver in $VFIO_CFG_PATH"
+ fi
+}
+
+function applyInitramfsChanges() {
+ sudo dracut -f --kver `uname -r`
+ #TODO: Find out if this needs to be executed again after every kernel update.
+}
+
+if [ "$COMMAND" = "add-driver" ]; then
+ addInitramfsDriver "$PARAM"
+elif [ "$COMMAND" = "apply" ]; then
+ applyInitramfsChanges
+fi
\ No newline at end of file
diff --git a/scripts/utils/manager-specific/kernelparams/grub b/scripts/utils/manager-specific/kernelparams/grub
new file mode 100755
index 0000000..47053ab
--- /dev/null
+++ b/scripts/utils/manager-specific/kernelparams/grub
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+
+GRUB_CFG_PATH=/etc/default/grub
+
+COMMAND="$1" # Supported commands: add, remove, apply
+PARAM="$2"
+
+if sudo cat "$GRUB_CFG_PATH" | grep --quiet "GRUB_CMDLINE_LINUX_DEFAULT="; then
+ GRUB_CMDLINE_VAR="GRUB_CMDLINE_LINUX_DEFAULT"
+else
+ GRUB_CMDLINE_VAR="GRUB_CMDLINE_LINUX"
+fi
+
+function addKernelParam() {
+ if ! sudo cat "$GRUB_CFG_PATH" | grep "$GRUB_CMDLINE_VAR=" | grep --quiet "$1"; then
+ sudo sed -i "s/^$GRUB_CMDLINE_VAR=\"/&$1 /" "$GRUB_CFG_PATH"
+ echo "addKernelParam: Added \"$1\" to $GRUB_CMDLINE_VAR in $GRUB_CFG_PATH"
+ else
+ echo "addKernelParam: No action required. \"$1\" already exists in $GRUB_CMDLINE_VAR of $GRUB_CFG_PATH"
+ fi
+}
+function addKernelParams() {
+ for param in $1; do
+ addKernelParam "$param"
+ done
+}
+function removeKernelParam() {
+ if sudo cat "$GRUB_CFG_PATH" | grep "$GRUB_CMDLINE_VAR=" | grep --quiet "$1"; then
+ sudo sed -i "s/$1 //" "$GRUB_CFG_PATH"
+ echo "removeKernelParam: Removed \"$1\" from $GRUB_CMDLINE_VAR in $GRUB_CFG_PATH"
+ else
+ echo "removeKernelParam: No action required. \"$1\" is not set in $GRUB_CMDLINE_VAR of $GRUB_CFG_PATH"
+ fi
+}
+function removeKernelParams() {
+ for param in $1; do
+ removeKernelParam "$param"
+ done
+}
+
+function applyKernelParamChanges() {
+ if command -v update-grub &> /dev/null; then
+ sudo update-grub
+ elif [ -f "/etc/grub2-efi.cfg" ]; then
+ sudo sh -c 'grub2-mkconfig > /etc/grub2-efi.cfg'
+ fi
+}
+
+if [ "$COMMAND" = "add" ]; then
+ addKernelParams "$PARAM"
+elif [ "$COMMAND" = "remove" ]; then
+ removeKernelParams "$PARAM"
+elif [ "$COMMAND" = "apply" ]; then
+ applyKernelParamChanges
+fi
diff --git a/scripts/utils/manager-specific/package/apt b/scripts/utils/manager-specific/package/apt
new file mode 100755
index 0000000..bce9810
--- /dev/null
+++ b/scripts/utils/manager-specific/package/apt
@@ -0,0 +1,79 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+loadConfig
+
+#####################################################################################################
+# Simple script to install the packages containing the given executable names or file names
+# Usage: `./apt --executables "curl git wget docker"`
+# Usage: `./apt --files "/usr/include/{ree,ruby}/ruby.h /usr/share/virtio-win/virtio-win.iso"`
+#####################################################################################################
+
+alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables"
+alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files"
+
+COMMAND="$1"
+SEARCH_MODE="$2"
+WANTED_ITEMS="$3"
+
+function updatePackageInfo() {
+ sudo apt-get update
+ if ! command -v apt-file &> /dev/null; then
+ sudo apt-get install -y apt-file
+ fi
+ sudo apt-file update
+}
+
+function installPackages() {
+ SEARCH_MODE="$1"
+ WANTED_ITEMS="$2"
+ if ! command -v apt-file &> /dev/null; then
+ sudo apt-get install -y apt-file
+ sudo apt-file update
+ fi
+ PACKAGES_TO_INSTALL=""
+ for CURRENT_ITEM in $WANTED_ITEMS; do
+ if [ "$SEARCH_MODE" = "--executables" ]; then
+ PACKAGE_TO_INSTALL="$(sudo apt-file search -l -x "^/(bin|sbin|usr/bin|usr/sbin)/${CURRENT_ITEM}$" | head -1)"
+ elif [ "$SEARCH_MODE" = "--files" ]; then
+ PACKAGE_TO_INSTALL="$(sudo apt-file search $CURRENT_ITEM | grep "${CURRENT_ITEM}$" | head -1 | cut -d':' -f1)"
+ fi
+ if [ "$?" = "0" ] && [ "$PACKAGE_TO_INSTALL" != "" ]; then
+ PACKAGES_TO_INSTALL+=" $PACKAGE_TO_INSTALL"
+ else
+ STILL_MISSING_ITEMS+=" $CURRENT_ITEM"
+ fi
+ done
+ if [ "$PACKAGES_TO_INSTALL" != "" ]; then
+ sudo bash -c "DEBIAN_FRONTEND=noninteractive apt-get install -yq $PACKAGES_TO_INSTALL"
+ fi
+}
+
+if [ "$COMMAND" = "install" ]; then
+ if [ "$SEARCH_MODE" = "--executables" ]; then
+ MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")"
+ installPackages "$SEARCH_MODE" "$MISSING_EXECUTABLES"
+ MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")"
+ elif [ "$SEARCH_MODE" = "--files" ]; then
+ MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")"
+ installPackages "$SEARCH_MODE" "$MISSING_FILES"
+ MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")"
+ else
+ echo "ERROR: Invalid mode or no mode at all was speficied!"
+ exit 1
+ fi
+ if [ "$MISSING_EXECUTABLES" != "" ]; then
+ echo "ERROR: Still missing package providing the following executables: $MISSING_EXECUTABLES"
+ fi
+ if [ "$MISSING_FILES" != "" ]; then
+ echo "ERROR: Still missing package providing the following files: $MISSING_FILES"
+ fi
+ if [ "$MISSING_EXECUTABLES" != "" ] && [ "$MISSING_FILES" != "" ]; then
+ exit 1
+ fi
+elif [ "$COMMAND" = "update" ]; then
+ updatePackageInfo
+else
+ echo "ERROR: Invalid command"
+ exit 1
+fi
diff --git a/scripts/utils/manager-specific/package/dnf b/scripts/utils/manager-specific/package/dnf
new file mode 100755
index 0000000..af98e80
--- /dev/null
+++ b/scripts/utils/manager-specific/package/dnf
@@ -0,0 +1,73 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+loadConfig
+
+#####################################################################################################
+# Simple script to install the packages containing the given executable names or files
+# Usage: `./dnf --executables "curl git wget docker"`
+# Usage: `./dnf --files "/usr/include/{ree,ruby}/ruby.h /usr/share/virtio-win/virtio-win.iso"`
+#####################################################################################################
+
+alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables"
+alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files"
+
+COMMAND="$1"
+SEARCH_MODE="$2"
+WANTED_ITEMS="$3"
+
+function updatePackageInfo() {
+ sudo dnf check-update
+}
+
+function installPackages() {
+ SEARCH_MODE="$1"
+ WANTED_ITEMS="$2"
+
+ PACKAGES_TO_INSTALL=""
+ for CURRENT_ITEM in $WANTED_ITEMS; do
+ if [ "$SEARCH_MODE" = "--executables" ]; then
+ PACKAGE_TO_INSTALL="$(sudo dnf provides {/bin,/sbin,/usr/bin/,/usr/sbin}/$CURRENT_ITEM 2> /dev/null | grep ' : ' | head -1 | cut -d'.' -f1 | rev | cut -d'-' -f 2- | rev)"
+ elif [ "$SEARCH_MODE" = "--files" ]; then
+ PACKAGE_TO_INSTALL="$(sudo dnf provides $CURRENT_ITEM 2> /dev/null | grep ' : ' | head -1 | cut -d'.' -f1 | rev | cut -d'-' -f 2- | rev)"
+ fi
+ if [ "$?" = "0" ] && [ "$PACKAGE_TO_INSTALL" != "" ]; then
+ PACKAGES_TO_INSTALL+=" $PACKAGE_TO_INSTALL"
+ else
+ STILL_MISSING_ITEMS+=" $CURRENT_ITEM"
+ fi
+ done
+ if [ "$PACKAGES_TO_INSTALL" != "" ]; then
+ sudo dnf install -y $PACKAGES_TO_INSTALL
+ fi
+}
+
+if [ "$COMMAND" = "install" ]; then
+ if [ "$SEARCH_MODE" = "--executables" ]; then
+ MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")"
+ installPackages "$SEARCH_MODE" "$MISSING_EXECUTABLES"
+ MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")"
+ elif [ "$SEARCH_MODE" = "--files" ]; then
+ MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")"
+ installPackages "$SEARCH_MODE" "$MISSING_FILES"
+ MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")"
+ else
+ echo "ERROR: Invalid mode or no mode at all was speficied!"
+ exit 1
+ fi
+ if [ "$MISSING_EXECUTABLES" != "" ]; then
+ echo "ERROR: Still missing package providing the following executables: $MISSING_EXECUTABLES"
+ fi
+ if [ "$MISSING_FILES" != "" ]; then
+ echo "ERROR: Still missing package providing the following files: $MISSING_FILES"
+ fi
+ if [ "$MISSING_EXECUTABLES" != "" ] && [ "$MISSING_FILES" != "" ]; then
+ exit 1
+ fi
+elif [ "$COMMAND" = "update" ]; then
+ updatePackageInfo
+else
+ echo "ERROR: Invalid command"
+ exit 1
+fi
+
diff --git a/scripts/utils/manager-specific/package/emerge b/scripts/utils/manager-specific/package/emerge
new file mode 100755
index 0000000..e254ecc
--- /dev/null
+++ b/scripts/utils/manager-specific/package/emerge
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+loadConfig
+
+#####################################################################################################
+#
+# WARNING!!!!!!!!!!!!!!!! The `e-file` calls in this file have not been properly implemented yet!!!
+# WARNING!!!!!!!!!!!!!!!! The `e-file` calls in this file have not been properly implemented yet!!!
+# WARNING!!!!!!!!!!!!!!!! The `e-file` calls in this file have not been properly implemented yet!!!
+#
+# Simple script to install the packages containing the given executable names or file names
+# Usage: `./emerge --executables "curl git wget docker"`
+# Usage: `./emerge --files "/usr/include/{ree,ruby}/ruby.h /usr/share/virtio-win/virtio-win.iso"`
+#####################################################################################################
+
+alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables"
+alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files"
+
+COMMAND="$1"
+SEARCH_MODE="$2"
+WANTED_ITEMS="$3"
+
+function updatePackageInfo() {
+ sudo emerge-webrsync -v
+}
+
+function installPackages() {
+ SEARCH_MODE="$1"
+ WANTED_ITEMS="$2"
+ if ! command -v e-file &> /dev/null; then
+ sudo emerge app-portage/pfl
+ fi
+ PACKAGES_TO_INSTALL=""
+ for CURRENT_ITEM in $WANTED_ITEMS; do
+ if [ "$SEARCH_MODE" = "--executables" ]; then
+ PACKAGE_TO_INSTALL="$(sudo e-file $CURRENT_ITEM ????)" # TODO: FIXME
+ elif [ "$SEARCH_MODE" = "--files" ]; then
+ PACKAGE_TO_INSTALL="$(sudo e-file $CURRENT_ITEM ????)" # TODO: FIXME
+ fi
+ if [ "$?" = "0" ] && [ "$PACKAGE_TO_INSTALL" != "" ]; then
+ PACKAGES_TO_INSTALL+=" $PACKAGE_TO_INSTALL"
+ else
+ STILL_MISSING_ITEMS+=" $CURRENT_ITEM"
+ fi
+ done
+ if [ "$PACKAGES_TO_INSTALL" != "" ]; then
+ sudo emerge $PACKAGES_TO_INSTALL
+ fi
+}
+
+if [ "$SEARCH_MODE" = "--executables" ]; then
+ MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")"
+ installPackages "$SEARCH_MODE" "$MISSING_EXECUTABLES"
+ MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")"
+elif [ "$SEARCH_MODE" = "--files" ]; then
+ MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")"
+ installPackages "$SEARCH_MODE" "$MISSING_FILES"
+ MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")"
+else
+ echo "ERROR: Invalid mode or no mode at all was speficied!"
+ exit 1
+fi
+if [ "$MISSING_EXECUTABLES" != "" ]; then
+ echo "ERROR: Still missing package providing the following executables: $MISSING_EXECUTABLES"
+fi
+if [ "$MISSING_FILES" != "" ]; then
+ echo "ERROR: Still missing package providing the following files: $MISSING_FILES"
+fi
+if [ "$MISSING_EXECUTABLES" != "" ] && [ "$MISSING_FILES" != "" ]; then
+ exit 1
+fi
diff --git a/scripts/utils/manager-specific/package/pacman b/scripts/utils/manager-specific/package/pacman
new file mode 100755
index 0000000..3635fef
--- /dev/null
+++ b/scripts/utils/manager-specific/package/pacman
@@ -0,0 +1,65 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+loadConfig
+
+#####################################################################################################
+# Simple script to install the packages containing the given executable names or file names
+# Usage: `./pacman --executables "curl git wget docker"`
+# Usage: `./pacman --files "/usr/include/{ree,ruby}/ruby.h /usr/share/virtio-win/virtio-win.iso"`
+#####################################################################################################
+
+alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables"
+alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files"
+
+COMMAND="$1"
+SEARCH_MODE="$2"
+WANTED_ITEMS="$3"
+
+function updatePackageInfo() {
+ sudo pacman -Syy
+ sudo pacman -Fy
+}
+
+function installPackages() {
+ SEARCH_MODE="$1"
+ WANTED_ITEMS="$2"
+ PACKAGES_TO_INSTALL=""
+ for CURRENT_ITEM in $WANTED_ITEMS; do
+ if [ "$SEARCH_MODE" = "--executables" ]; then
+ PACKAGE_TO_INSTALL="$(sudo pacman -F $CURRENT_ITEM | grep -B 1 /bin/$CURRENT_ITEM | head -1 | cut -d' ' -f1)"
+ elif [ "$SEARCH_MODE" = "--files" ]; then
+ PACKAGE_TO_INSTALL="$(sudo pacman -F $CURRENT_ITEM | head -1 | rev | cut -d' ' -f2 | rev)"
+ fi
+ if [ "$?" = "0" ] && [ "$PACKAGE_TO_INSTALL" != "" ]; then
+ PACKAGES_TO_INSTALL+=" $PACKAGE_TO_INSTALL"
+ else
+ STILL_MISSING_ITEMS+=" $CURRENT_ITEM"
+ fi
+ done
+ if [ "$PACKAGES_TO_INSTALL" != "" ]; then
+ sudo pacman -S --noconfirm $PACKAGES_TO_INSTALL
+ fi
+}
+
+if [ "$SEARCH_MODE" = "--executables" ]; then
+ MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")"
+ installPackages "$SEARCH_MODE" "$MISSING_EXECUTABLES"
+ MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")"
+elif [ "$SEARCH_MODE" = "--files" ]; then
+ MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")"
+ installPackages "$SEARCH_MODE" "$MISSING_FILES"
+ MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")"
+else
+ echo "ERROR: Invalid mode or no mode at all was speficied!"
+ exit 1
+fi
+if [ "$MISSING_EXECUTABLES" != "" ]; then
+ echo "ERROR: Still missing package providing the following executables: $MISSING_EXECUTABLES"
+fi
+if [ "$MISSING_FILES" != "" ]; then
+ echo "ERROR: Still missing package providing the following files: $MISSING_FILES"
+fi
+if [ "$MISSING_EXECUTABLES" != "" ] && [ "$MISSING_FILES" != "" ]; then
+ exit 1
+fi
diff --git a/scripts/utils/manager-specific/package/yum b/scripts/utils/manager-specific/package/yum
new file mode 100755
index 0000000..e18456b
--- /dev/null
+++ b/scripts/utils/manager-specific/package/yum
@@ -0,0 +1,73 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+loadConfig
+
+#####################################################################################################
+# Simple script to install the packages containing the given executable names or files
+# Usage: `./yum --executables "curl git wget docker"`
+# Usage: `./yum --files "/usr/include/{ree,ruby}/ruby.h /usr/share/virtio-win/virtio-win.iso"`
+#####################################################################################################
+
+alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables"
+alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files"
+
+COMMAND="$1"
+SEARCH_MODE="$2"
+WANTED_ITEMS="$3"
+
+function updatePackageInfo() {
+ sudo yum check-update
+}
+
+function installPackages() {
+ SEARCH_MODE="$1"
+ WANTED_ITEMS="$2"
+
+ PACKAGES_TO_INSTALL=""
+ for CURRENT_ITEM in $WANTED_ITEMS; do
+ if [ "$SEARCH_MODE" = "--executables" ]; then
+ PACKAGE_TO_INSTALL="$(sudo yum provides {/bin,/sbin,/usr/bin/,/usr/sbin}/$CURRENT_ITEM 2> /dev/null | grep ' : ' | head -1 | cut -d'.' -f1 | rev | cut -d'-' -f 2- | rev)"
+ elif [ "$SEARCH_MODE" = "--files" ]; then
+ PACKAGE_TO_INSTALL="$(sudo yum provides $CURRENT_ITEM 2> /dev/null | grep ' : ' | head -1 | cut -d'.' -f1 | rev | cut -d'-' -f 2- | rev)"
+ fi
+ if [ "$?" = "0" ] && [ "$PACKAGE_TO_INSTALL" != "" ]; then
+ PACKAGES_TO_INSTALL+=" $PACKAGE_TO_INSTALL"
+ else
+ STILL_MISSING_ITEMS+=" $CURRENT_ITEM"
+ fi
+ done
+ if [ "$PACKAGES_TO_INSTALL" != "" ]; then
+ sudo yum install -y $PACKAGES_TO_INSTALL
+ fi
+}
+
+if [ "$COMMAND" = "install" ]; then
+ if [ "$SEARCH_MODE" = "--executables" ]; then
+ MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")"
+ installPackages "$SEARCH_MODE" "$MISSING_EXECUTABLES"
+ MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")"
+ elif [ "$SEARCH_MODE" = "--files" ]; then
+ MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")"
+ installPackages "$SEARCH_MODE" "$MISSING_FILES"
+ MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")"
+ else
+ echo "ERROR: Invalid mode or no mode at all was speficied!"
+ exit 1
+ fi
+ if [ "$MISSING_EXECUTABLES" != "" ]; then
+ echo "ERROR: Still missing package providing the following executables: $MISSING_EXECUTABLES"
+ fi
+ if [ "$MISSING_FILES" != "" ]; then
+ echo "ERROR: Still missing package providing the following files: $MISSING_FILES"
+ fi
+ if [ "$MISSING_EXECUTABLES" != "" ] && [ "$MISSING_FILES" != "" ]; then
+ exit 1
+ fi
+elif [ "$COMMAND" = "update" ]; then
+ updatePackageInfo
+else
+ echo "ERROR: Invalid command"
+ exit 1
+fi
+
diff --git a/scripts/utils/manager-specific/package/zypper b/scripts/utils/manager-specific/package/zypper
new file mode 100755
index 0000000..8bb6dfa
--- /dev/null
+++ b/scripts/utils/manager-specific/package/zypper
@@ -0,0 +1,64 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+loadConfig
+
+#####################################################################################################
+# Simple script to install the packages containing the given executable names or file names
+# Usage: `./zypper --executables "curl git wget docker"`
+# Usage: `./zypper --files "/usr/include/{ree,ruby}/ruby.h /usr/share/virtio-win/virtio-win.iso"`
+#####################################################################################################
+
+alias getMissingExecutables="${COMMON_UTILS_TOOLS_DIR}/get-missing-executables"
+alias getMissingFiles="${COMMON_UTILS_TOOLS_DIR}/get-missing-files"
+
+COMMAND="$1"
+SEARCH_MODE="$2"
+WANTED_ITEMS="$3"
+
+function updatePackageInfo() {
+ sudo zypper refresh
+}
+
+function installPackages() {
+ SEARCH_MODE="$1"
+ WANTED_ITEMS="$2"
+ PACKAGES_TO_INSTALL=""
+ for CURRENT_ITEM in $WANTED_ITEMS; do
+ if [ "$SEARCH_MODE" = "--executables" ]; then
+ PACKAGE_TO_INSTALL="$(sudo zypper search -f {/bin,/sbin,/usr/bin/,/usr/sbin}/$CURRENT_ITEM | grep " | package" | head -1 | tr -d ' ' | cut -d'|' -f2)"
+ elif [ "$SEARCH_MODE" = "--files" ]; then
+ PACKAGE_TO_INSTALL="$(sudo zypper search -f $CURRENT_ITEM | grep " | package" | head -1 | tr -d ' ' | cut -d'|' -f2)"
+ fi
+ if [ "$?" = "0" ] && [ "$PACKAGE_TO_INSTALL" != "" ]; then
+ PACKAGES_TO_INSTALL+=" $PACKAGE_TO_INSTALL"
+ else
+ STILL_MISSING_ITEMS+=" $CURRENT_ITEM"
+ fi
+ done
+ if [ "$PACKAGES_TO_INSTALL" != "" ]; then
+ sudo zypper --non-interactive install $PACKAGES_TO_INSTALL
+ fi
+}
+
+if [ "$SEARCH_MODE" = "--executables" ]; then
+ MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")"
+ installPackages "$SEARCH_MODE" "$MISSING_EXECUTABLES"
+ MISSING_EXECUTABLES="$(getMissingExecutables "$WANTED_ITEMS")"
+elif [ "$SEARCH_MODE" = "--files" ]; then
+ MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")"
+ installPackages "$SEARCH_MODE" "$MISSING_FILES"
+ MISSING_FILES="$(getMissingFiles "$WANTED_ITEMS")"
+else
+ echo "ERROR: Invalid mode or no mode at all was speficied!"
+ exit 1
+fi
+if [ "$MISSING_EXECUTABLES" != "" ]; then
+ echo "ERROR: Still missing package providing the following executables: $MISSING_EXECUTABLES"
+fi
+if [ "$MISSING_FILES" != "" ]; then
+ echo "ERROR: Still missing package providing the following files: $MISSING_FILES"
+fi
+if [ "$MISSING_EXECUTABLES" != "" ] && [ "$MISSING_FILES" != "" ]; then
+ exit 1
+fi
diff --git a/scripts/utils/manager-specific/service/initctl b/scripts/utils/manager-specific/service/initctl
new file mode 100755
index 0000000..54b5ad0
--- /dev/null
+++ b/scripts/utils/manager-specific/service/initctl
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+
+COMMAND="$1"
+SERVICE_NAME="$2"
+
+if [ "$COMMAND" = "create-autostart-service" ]; then
+ echo "Not implemented"
+ exit 1
+elif [ "$COMMAND" = "remove-autostart-service" ]; then
+ echo "Not implemented"
+ exit 1
+elif [ "$COMMAND" = "start" ]; then
+ sudo service start ${SERVICE_NAME} &> /dev/null
+elif [ "$COMMAND" = "stop" ]; then
+ sudo service stop ${SERVICE_NAME} &> /dev/null
+elif [ "$COMMAND" = "restart" ]; then
+ sudo initctl restart ${SERVICE_NAME} &> /dev/null
+fi
diff --git a/scripts/utils/manager-specific/service/service b/scripts/utils/manager-specific/service/service
new file mode 100755
index 0000000..dbe4a93
--- /dev/null
+++ b/scripts/utils/manager-specific/service/service
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+
+COMMAND="$1"
+SERVICE_NAME="$2"
+
+if [ "$COMMAND" = "create-autostart-service" ]; then
+ echo "Not implemented"
+ exit 1
+elif [ "$COMMAND" = "remove-autostart-service" ]; then
+ echo "Not implemented"
+ exit 1
+elif [ "$COMMAND" = "start" ]; then
+ sudo service ${SERVICE_NAME} start &> /dev/null
+elif [ "$COMMAND" = "stop" ]; then
+ sudo service ${SERVICE_NAME} stop &> /dev/null
+elif [ "$COMMAND" = "restart" ]; then
+ sudo service ${SERVICE_NAME} stop &> /dev/null
+ sudo service ${SERVICE_NAME} start &> /dev/null
+fi
diff --git a/scripts/utils/manager-specific/service/systemd b/scripts/utils/manager-specific/service/systemd
new file mode 100755
index 0000000..91c6e40
--- /dev/null
+++ b/scripts/utils/manager-specific/service/systemd
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+while [[ "$PROJECT_DIR" != */MobilePassThrough ]]; do PROJECT_DIR="$(readlink -f "$(dirname "${PROJECT_DIR:-0}")")"; done
+source "$PROJECT_DIR/scripts/utils/common/libs/helpers"
+
+COMMAND="$1"
+
+SERVICE_NAME="$2"
+if [ "$COMMAND" = "create-autostart-service" ]; then
+ COMMAND_TO_RUN="$2"
+ EXEC_START="'$GUI_TERMINAL' run-with-command '$COMMAND_TO_RUN'"
+
+ sudo echo "[Unit]
+Description=${SERVICE_NAME}
+After=multi-user.target network.target
+
+[Service]
+User=$(logname)
+Group=$(id -gn $(logname))
+Type=simple
+Environment=DISPLAY=:0
+WorkingDirectory=${PROJECT_DIR}
+ExecStart=${EXEC_START}
+Restart=never
+
+[Install]
+WantedBy=multi-user.target" > /etc/systemd/system/${SERVICE_NAME}.service
+
+ sudo systemctl daemon-reload
+ sudo systemctl enable ${SERVICE_NAME}.service
+elif [ "$COMMAND" = "remove-autostart-service" ]; then
+ sudo systemctl disable ${SERVICE_NAME}.service &> /dev/null
+elif [ "$COMMAND" = "start" ]; then
+ sudo systemctl start ${SERVICE_NAME}.service &> /dev/null
+elif [ "$COMMAND" = "stop" ]; then
+ sudo systemctl stop ${SERVICE_NAME}.service &> /dev/null
+elif [ "$COMMAND" = "restart" ]; then
+ sudo systemctl restart ${SERVICE_NAME}.service &> /dev/null
+fi
diff --git a/utils/Fedora/34/amd-setup b/utils/Fedora/34/amd-setup
deleted file mode 100644
index 5abb1d8..0000000
--- a/utils/Fedora/34/amd-setup
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/../../.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-VM_FILES_DIR="${PROJECT_DIR}/vm-files"
-
-source "$DISTRO_UTILS_DIR/kernel-param-utils"
-
-# This script doesn't do anything yet.
\ No newline at end of file
diff --git a/utils/Fedora/34/bumblebee-setup b/utils/Fedora/34/bumblebee-setup
deleted file mode 100755
index cc1bca1..0000000
--- a/utils/Fedora/34/bumblebee-setup
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/../../.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-VM_FILES_DIR="${PROJECT_DIR}/vm-files"
-
-source "$DISTRO_UTILS_DIR/kernel-param-utils"
-
-echo "Disable Nouveau drivers"
-addKernelParam "nouveau.modeset=0"
-#sudo grep -qxsF 'blacklist nouveau' "/etc/modprobe.d/blacklist.conf" || echo "blacklist nouveau" | sudo tee -a "/etc/modprobe.d/blacklist.conf" > /dev/null
-#sudo grep -qxsF 'exclude=xorg-x11*' "/etc/dnf/dnf.conf" || echo "exclude=xorg-x11*" | sudo tee -a "/etc/dnf/dnf.conf" > /dev/null
-#sudo dnf remove xorg-x11-drv-nouveau -y
-
-echo "Install third party repositories"
-sudo dnf install fedora-workstation-repositories -y
-
-echo "Enable the Bumblebee repository"
-sudo dnf copr enable chenxiaolong/bumblebee -y
-
-echo "Install Bumblebee"
-sudo dnf install akmod-bbswitch bumblebee primus -y
-
-echo "Make Bumblebee avialable to the current user"
-sudo gpasswd -a $(who -m | awk '{print $1;}') bumblebee
-
-echo "Enable Bumblebee autostart"
-sudo systemctl enable bumblebeed
-
-echo "Block nvidia-fallback service"
-sudo systemctl mask nvidia-fallback
-
-echo "Start Bumblebee"
-sudo systemctl start bumblebeed
\ No newline at end of file
diff --git a/utils/Fedora/34/install-dependencies b/utils/Fedora/34/install-dependencies
deleted file mode 100755
index 09b2d83..0000000
--- a/utils/Fedora/34/install-dependencies
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/env bash
-
-echo "Updating software..."
-sudo dnf update -y
-echo "Installing some useful tools..."
-sudo dnf install -y wget curl vim screen git crudini lshw msr-tools sysfsutils tunctl remmina samba spice-gtk-tools genisoimage uuid acpica-tools docker
-echo "Installing virtualization software..."
-sudo dnf install -y qemu #@virtualization
-
-echo "Installing the Windows VirtIO Repository..."
-sudo wget https://fedorapeople.org/groups/virt/virtio-win/virtio-win.repo -O /etc/yum.repos.d/virtio-win.repo
-echo "Installing virtio-win..."
-sudo dnf install virtio-win -y
-echo "Upgrading to latest virtio-win..."
-sudo dnf --enablerepo=virtio-win-latest upgrade virtio-win -y
-echo "Installing virt-viewer so you can connect to the VM for the windows installation"
-sudo dnf install -y virt-viewer
-# /usr/share/virtio-win/virtio-win.iso
diff --git a/utils/Fedora/34/intel-setup b/utils/Fedora/34/intel-setup
deleted file mode 100755
index 090cf8c..0000000
--- a/utils/Fedora/34/intel-setup
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/../../.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-VM_FILES_DIR="${PROJECT_DIR}/vm-files"
-
-source "$DISTRO_UTILS_DIR/kernel-param-utils"
-
-#TODO: verify if that actually works:
-echo "Allow using external monitor for notebooks that have the port wired to the dGPU directly"
-sudo dnf install -y intel-gpu-tools
-sudo intel-virtual-output
-#example usage: xrandr –output eDP1 –mode 1920×1080 –output HDMI1 –mode 1920×1080 –right-of eDP1
diff --git a/utils/Fedora/34/kernel-param-utils b/utils/Fedora/34/kernel-param-utils
deleted file mode 100755
index 3ac278c..0000000
--- a/utils/Fedora/34/kernel-param-utils
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env bash
-
-GRUB_CFG_PATH=/etc/default/grub
-VFIO_CFG_PATH=/etc/dracut.conf.d/vfio.conf
-
-function addKernelParam() {
- if ! sudo cat "$GRUB_CFG_PATH" | grep "GRUB_CMDLINE_LINUX=" | grep --quiet "$1"; then
- sudo sed -i "s/^GRUB_CMDLINE_LINUX=\"/&$1 /" "$GRUB_CFG_PATH"
- echo "addKernelParam: Added \"$1\" to GRUB_CMDLINE_LINUX in $GRUB_CFG_PATH"
- else
- echo "addKernelParam: No action required. \"$1\" already exists in GRUB_CMDLINE_LINUX of $GRUB_CFG_PATH"
- fi
-}
-function removeKernelParam() {
- if sudo cat "$GRUB_CFG_PATH" | grep "GRUB_CMDLINE_LINUX=" | grep --quiet "$1"; then
- sudo sed -i "s/$1 //" "$GRUB_CFG_PATH"
- echo "removeKernelParam: Removed \"$1\" from GRUB_CMDLINE_LINUX in $GRUB_CFG_PATH"
- else
- echo "removeKernelParam: No action required. \"$1\" is not set in GRUB_CMDLINE_LINUX of $GRUB_CFG_PATH"
- fi
-}
-function applyKernelParamChanges() {
- sudo sh -c 'grub2-mkconfig > /etc/grub2-efi.cfg'
-}
-
-function setGrubTimeout() {
- sudo sed -i -r "s/^GRUB_TIMEOUT=[0-9]+/GRUB_TIMEOUT=$1 /" "$GRUB_CFG_PATH"
-}
-
-function addInitramfsDriver() {
- driver="$1"
- sudo touch "$VFIO_CFG_PATH"
- if ! sudo cat "$VFIO_CFG_PATH" | grep --quiet "add_driver+="; then
- echo 'add_driver+=" "' >> "$VFIO_CFG_PATH"
- fi
- if ! sudo cat "$VFIO_CFG_PATH" | grep "add_driver+=" | grep --quiet -P "( |\")$driver( |\")"; then
- sudo sed -i "s/^add_driver+=\" \{0,1\}/&$driver /" "$VFIO_CFG_PATH"
- echo "addDriverToInitramfs: Added \"$driver\" to add_driver in $VFIO_CFG_PATH"
- else
- echo "addDriverToInitramfs: No action required. \"$driver\" already exists in add_driver in $VFIO_CFG_PATH"
- fi
-}
-
-function applyInitramfsChanges() {
- sudo dracut -f --kver `uname -r`
- #TODO: Find out if this needs to be executed again after every kernel update.
-}
\ No newline at end of file
diff --git a/utils/Fedora/34/looking-glass-setup b/utils/Fedora/34/looking-glass-setup
deleted file mode 100755
index 0e63fcd..0000000
--- a/utils/Fedora/34/looking-glass-setup
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/../../.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-VM_FILES_DIR="${PROJECT_DIR}/vm-files"
-
-mkdir -p "${PROJECT_DIR}/thirdparty"
-cd "${PROJECT_DIR}/thirdparty"
-
-sudo dnf install -y binutils-devel cmake texlive-gnu-freefont fontconfig-devel SDL2-devel SDL2_ttf-devel spice-protocol libX11-devel nettle-devel wayland-protocols-devel gcc libXScrnSaver-devel libXfixes-devel libXi-devel wayland-devel mingw64-gcc-c++ mingw32-nsis
-
-LOOKING_GLASS_VERSION="B3"
-
-# Build the (Linux) client application
-git clone --single-branch --branch "${LOOKING_GLASS_VERSION}" --depth 1 --recursive https://github.com/gnif/LookingGlass.git
-mkdir LookingGlass/client/build
-cd LookingGlass/client/build
-cmake ../
-make
-
-TMP_USER_NAME="$(logname)"
-TMP_USER_ID="$(id -u "$TMP_USER_NAME")"
-sudo bash -c "echo '#Type Path Mode UID GID Age Argument' > /etc/tmpfiles.d/10-looking-glass.conf"
-sudo bash -c "echo 'f /dev/shm/looking-glass ${TMP_USER_ID} ${TMP_USER_NAME} kvm - ' >> /etc/tmpfiles.d/10-looking-glass.conf"
-
-# Build the (Windows) host application
-cd "${PROJECT_DIR}/thirdparty"
-wget https://developer.nvidia.com/capture_sdk/downloads/v8.0.4/linux -O ./nvidea_capture_api.tgz
-rm -rf ./Capture_Linux_v8.0.4
-tar -xvzf ./nvidea_capture_api.tgz
-rm ./nvidea_capture_api.tgz
-rm -rf ./LookingGlass/Capture_Linux_v8.0.4
-mv ./Capture_Linux_v8.0.4 ./LookingGlass/
-cd LookingGlass
-cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=./host/toolchain-mingw64.cmake -DNVFBC_SDK='./Capture_Linux_v8.0.4' -DUSE_NVFBC=1 ./host
-make
-
-#wget "https://ci.appveyor.com/api/projects/rainers/visuald/artifacts/cv2pdb.exe?job=Environment%3A%20os%3DVisual%20Studio%202015%2C%20VS%3D14%2C%20APPVEYOR_BUILD_WORKER_IMAGE%3DVisual%20Studio%202015" -O "cv2pdb.exe"
-#wine './cv2pdb.exe' './looking-glass-host.exe'
-makensis './platform/Windows/installer.nsi'
diff --git a/utils/Fedora/34/nvidia-setup b/utils/Fedora/34/nvidia-setup
deleted file mode 100755
index e7186e2..0000000
--- a/utils/Fedora/34/nvidia-setup
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/../../.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-VM_FILES_DIR="${PROJECT_DIR}/vm-files"
-
-source "$DISTRO_UTILS_DIR/kernel-param-utils"
-
-echo "Disable Nouveau drivers"
-addKernelParam "nouveau.modeset=0"
-#sudo grep -qxsF 'blacklist nouveau' "/etc/modprobe.d/blacklist.conf" || echo "blacklist nouveau" | sudo tee -a "/etc/modprobe.d/blacklist.conf" > /dev/null
-#sudo grep -qxsF 'exclude=xorg-x11*' "/etc/dnf/dnf.conf" || echo "exclude=xorg-x11*" | sudo tee -a "/etc/dnf/dnf.conf" > /dev/null
-#sudo dnf remove xorg-x11-drv-nouveau -y
-
-echo "Install third party repositories"
-sudo dnf install fedora-workstation-repositories -y
-
-echo "Install third party repositories"
-sudo dnf config-manager rpmfusion-nonfree-nvidia-driver --set-enabled -y
-
-echo "Enable the NVIDIA driver repository"
-sudo dnf install akmod-nvidia acpi -y
-
-echo "Enable the Bumblebee repository"
-sudo dnf copr enable chenxiaolong/bumblebee -y
-
-echo "Install Bumblebee"
-sudo dnf install akmod-bbswitch bumblebee primus -y
-
-echo "Make Bumblebee avialable to the current user"
-sudo gpasswd -a $(who -m | awk '{print $1;}') bumblebee
-
-echo "Enable Bumblebee autostart"
-sudo systemctl enable bumblebeed
-
-echo "Block nvidia-fallback service"
-sudo systemctl mask nvidia-fallback
-
-echo "Start Bumblebee"
-sudo systemctl start bumblebeed
-
-sudo ${UTILS_DIR}/extract-vbios
diff --git a/utils/Ubuntu/21.04/amd-setup b/utils/Ubuntu/21.04/amd-setup
deleted file mode 100644
index 5abb1d8..0000000
--- a/utils/Ubuntu/21.04/amd-setup
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/../../.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-VM_FILES_DIR="${PROJECT_DIR}/vm-files"
-
-source "$DISTRO_UTILS_DIR/kernel-param-utils"
-
-# This script doesn't do anything yet.
\ No newline at end of file
diff --git a/utils/Ubuntu/21.04/bumblebee-setup b/utils/Ubuntu/21.04/bumblebee-setup
deleted file mode 100755
index d4d5e5e..0000000
--- a/utils/Ubuntu/21.04/bumblebee-setup
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/../../.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-VM_FILES_DIR="${PROJECT_DIR}/vm-files"
-
-source "$DISTRO_UTILS_DIR/kernel-param-utils"
-
-echo "Disable Nouveau drivers"
-addKernelParam "nouveau.modeset=0"
-#sudo grep -qxsF 'blacklist nouveau' "/etc/modprobe.d/blacklist.conf" || echo "blacklist nouveau" | sudo tee -a "/etc/modprobe.d/blacklist.conf" > /dev/null
-#sudo grep -qxsF 'exclude=xorg-x11*' "/etc/dnf/dnf.conf" || echo "exclude=xorg-x11*" | sudo tee -a "/etc/dnf/dnf.conf" > /dev/null
-#sudo dnf remove xorg-x11-drv-nouveau -y
-
-echo "Install third party repositories"
-sudo add-apt-repository ppa:bumblebee/testing -y
-
-
-echo "Install Bumblebee"
-sudo apt install bumblebee bumblebee-nvidia -y
-
-echo "Make Bumblebee available to the current user"
-sudo gpasswd -a $(whoami) bumblebee
-
-echo "Enable Bumblebee autostart"
-sudo systemctl enable bumblebeed
-
-echo "Block nvidia-fallback service"
-sudo systemctl mask nvidia-fallback
-
-echo "Start Bumblebee"
-sudo systemctl start bumblebeed
diff --git a/utils/Ubuntu/21.04/install-dependencies b/utils/Ubuntu/21.04/install-dependencies
deleted file mode 100755
index f325f59..0000000
--- a/utils/Ubuntu/21.04/install-dependencies
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/env bash
-
-echo "Updating software..."
-sudo apt upgrade -y
-echo "Installing some useful tools..."
-sudo apt install -y wget curl vim screen git crudini lshw msr-tools sysfsutils uml-utilities remmina samba spice-client-gtk genisoimage uuid acpica-tools docker
-echo "Installing virtualization software..."
-sudo apt install qemu-kvm qemu-utils qemu-efi ovmf qemu -y
-
-#echo "Installing the Windows VirtIO Repository..."
-#sudo wget https://fedorapeople.org/groups/virt/virtio-win/virtio-win.repo -O /etc/yum.repos.d/virtio-win.repo
-echo "Installing virtio-modules"
-sudo apt install virtio-modules -y
-#echo "Upgrading to latest virtio-win..."
-#sudo dnf --enablerepo=virtio-win-latest upgrade virtio-win -y
-echo "Installing virt-viewer so you can connect to the VM for the windows installation"
-sudo apt install -y virt-viewer
-# /usr/share/virtio-win/virtio-win.iso
diff --git a/utils/Ubuntu/21.04/intel-setup b/utils/Ubuntu/21.04/intel-setup
deleted file mode 100755
index 5c9ca09..0000000
--- a/utils/Ubuntu/21.04/intel-setup
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/../../.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-VM_FILES_DIR="${PROJECT_DIR}/vm-files"
-
-source "$DISTRO_UTILS_DIR/kernel-param-utils"
-
-#TODO: verify if that actually works:
-echo "Allow using external monitor for notebooks that have the port wired to the dGPU directly"
-sudo apt install -y intel-gpu-tools
-sudo intel-virtual-output
-#example usage: xrandr –output eDP1 –mode 1920×1080 –output HDMI1 –mode 1920×1080 –right-of eDP1
diff --git a/utils/Ubuntu/21.04/kernel-param-utils b/utils/Ubuntu/21.04/kernel-param-utils
deleted file mode 100755
index 3ac278c..0000000
--- a/utils/Ubuntu/21.04/kernel-param-utils
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env bash
-
-GRUB_CFG_PATH=/etc/default/grub
-VFIO_CFG_PATH=/etc/dracut.conf.d/vfio.conf
-
-function addKernelParam() {
- if ! sudo cat "$GRUB_CFG_PATH" | grep "GRUB_CMDLINE_LINUX=" | grep --quiet "$1"; then
- sudo sed -i "s/^GRUB_CMDLINE_LINUX=\"/&$1 /" "$GRUB_CFG_PATH"
- echo "addKernelParam: Added \"$1\" to GRUB_CMDLINE_LINUX in $GRUB_CFG_PATH"
- else
- echo "addKernelParam: No action required. \"$1\" already exists in GRUB_CMDLINE_LINUX of $GRUB_CFG_PATH"
- fi
-}
-function removeKernelParam() {
- if sudo cat "$GRUB_CFG_PATH" | grep "GRUB_CMDLINE_LINUX=" | grep --quiet "$1"; then
- sudo sed -i "s/$1 //" "$GRUB_CFG_PATH"
- echo "removeKernelParam: Removed \"$1\" from GRUB_CMDLINE_LINUX in $GRUB_CFG_PATH"
- else
- echo "removeKernelParam: No action required. \"$1\" is not set in GRUB_CMDLINE_LINUX of $GRUB_CFG_PATH"
- fi
-}
-function applyKernelParamChanges() {
- sudo sh -c 'grub2-mkconfig > /etc/grub2-efi.cfg'
-}
-
-function setGrubTimeout() {
- sudo sed -i -r "s/^GRUB_TIMEOUT=[0-9]+/GRUB_TIMEOUT=$1 /" "$GRUB_CFG_PATH"
-}
-
-function addInitramfsDriver() {
- driver="$1"
- sudo touch "$VFIO_CFG_PATH"
- if ! sudo cat "$VFIO_CFG_PATH" | grep --quiet "add_driver+="; then
- echo 'add_driver+=" "' >> "$VFIO_CFG_PATH"
- fi
- if ! sudo cat "$VFIO_CFG_PATH" | grep "add_driver+=" | grep --quiet -P "( |\")$driver( |\")"; then
- sudo sed -i "s/^add_driver+=\" \{0,1\}/&$driver /" "$VFIO_CFG_PATH"
- echo "addDriverToInitramfs: Added \"$driver\" to add_driver in $VFIO_CFG_PATH"
- else
- echo "addDriverToInitramfs: No action required. \"$driver\" already exists in add_driver in $VFIO_CFG_PATH"
- fi
-}
-
-function applyInitramfsChanges() {
- sudo dracut -f --kver `uname -r`
- #TODO: Find out if this needs to be executed again after every kernel update.
-}
\ No newline at end of file
diff --git a/utils/Ubuntu/21.04/looking-glass-setup b/utils/Ubuntu/21.04/looking-glass-setup
deleted file mode 100755
index 7fe81e3..0000000
--- a/utils/Ubuntu/21.04/looking-glass-setup
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/../../.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-VM_FILES_DIR="${PROJECT_DIR}/vm-files"
-
-mkdir -p "${PROJECT_DIR}/thirdparty"
-cd "${PROJECT_DIR}/thirdparty"
-
-sudo apt install binutils binutils-multiarch-dev cmake texlive-fonts-recommended fonts-freefont-ttf libfontconfig-dev libegl-dev libspice-protocol-dev libsdl2-dev nettle-dev libx11-dev libxi-dev libxinerama-dev libxss-dev libwayland-dev wayland-protocols
-
-LOOKING_GLASS_VERSION="B3"
-
-# Build the (Linux) client application
-git clone --single-branch --branch "${LOOKING_GLASS_VERSION}" --depth 1 --recursive https://github.com/gnif/LookingGlass.git
-mkdir LookingGlass/client/build
-cd LookingGlass/client/build
-cmake ../
-make
-
-TMP_USER_NAME="$(logname)"
-TMP_USER_ID="$(id -u "$TMP_USER_NAME")"
-sudo bash -c "echo '#Type Path Mode UID GID Age Argument' > /etc/tmpfiles.d/10-looking-glass.conf"
-sudo bash -c "echo 'f /dev/shm/looking-glass ${TMP_USER_ID} ${TMP_USER_NAME} kvm - ' >> /etc/tmpfiles.d/10-looking-glass.conf"
-
-# Build the (Windows) host application
-cd "${PROJECT_DIR}/thirdparty"
-wget https://developer.nvidia.com/capture_sdk/downloads/v8.0.4/linux -O ./nvidea_capture_api.tgz
-rm -rf ./Capture_Linux_v8.0.4
-tar -xvzf ./nvidea_capture_api.tgz
-rm ./nvidea_capture_api.tgz
-rm -rf ./LookingGlass/Capture_Linux_v8.0.4
-mv ./Capture_Linux_v8.0.4 ./LookingGlass/
-cd LookingGlass
-cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=./host/toolchain-mingw64.cmake -DNVFBC_SDK='./Capture_Linux_v8.0.4' -DUSE_NVFBC=1 ./host
-make
-
-#wget "https://ci.appveyor.com/api/projects/rainers/visuald/artifacts/cv2pdb.exe?job=Environment%3A%20os%3DVisual%20Studio%202015%2C%20VS%3D14%2C%20APPVEYOR_BUILD_WORKER_IMAGE%3DVisual%20Studio%202015" -O "cv2pdb.exe"
-#wine './cv2pdb.exe' './looking-glass-host.exe'
-makensis './platform/Windows/installer.nsi'
diff --git a/utils/Ubuntu/21.04/nvidia-setup b/utils/Ubuntu/21.04/nvidia-setup
deleted file mode 100755
index 996724a..0000000
--- a/utils/Ubuntu/21.04/nvidia-setup
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/../../.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-VM_FILES_DIR="${PROJECT_DIR}/vm-files"
-
-source "$DISTRO_UTILS_DIR/kernel-param-utils"
-
-echo "Disable Nouveau drivers"
-addKernelParam "nouveau.modeset=0"
-#sudo grep -qxsF 'blacklist nouveau' "/etc/modprobe.d/blacklist.conf" || echo "blacklist nouveau" | sudo tee -a "/etc/modprobe.d/blacklist.conf" > /dev/null
-#sudo grep -qxsF 'exclude=xorg-x11*' "/etc/dnf/dnf.conf" || echo "exclude=xorg-x11*" | sudo tee -a "/etc/dnf/dnf.conf" > /dev/null
-#sudo dnf remove xorg-x11-drv-nouveau -y
-
-echo "Install third party repositories"
-sudo add-apt-repository ppa:graphics-drivers/ppa -y
-
-echo "Auto-install NVIDIA Drivers with ubuntu-drivers"
-sudo ubuntu-drivers install -y
-
-echo "Add Bumblebee repository"
-sudo add-apt-repository ppa:bumblebee/testing -y
-
-
-echo "Install Bumblebee"
-sudo apt install bumblebee bumblebee-nvidia primus -y
-
-echo "Make Bumblebee available to the current user"
-sudo usermod -aG bumblebee $(whoami)
-
-echo "Enable Bumblebee autostart"
-sudo systemctl enable bumblebeed
-
-echo "Block nvidia-fallback service"
-sudo systemctl mask nvidia-fallback
-
-echo "Start Bumblebee"
-sudo systemctl start bumblebeed
diff --git a/utils/Ubuntu/21.04/vbios-finder-installer b/utils/Ubuntu/21.04/vbios-finder-installer
deleted file mode 100755
index 7c25227..0000000
--- a/utils/Ubuntu/21.04/vbios-finder-installer
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/../../.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-VM_FILES_DIR="${PROJECT_DIR}/vm-files"
-="${PROJECT_DIR}/vm-files"
-_DIR="${PROJECT_DIR}/vm-files"
-
-mkdir -p "${PROJECT_DIR}/thirdparty"
-cd "${PROJECT_DIR}/thirdparty"
-
-rm -rf VBiosFinder
-git clone https://github.com/coderobe/VBiosFinder.git
-cd VBiosFinder
-
-sudo apt install ruby ruby-rubygems ruby-bundler ruby-dev p7zip innoextract upx -y
-
-
-wget https://github.com/LongSoft/UEFITool/releases/download/A58/UEFIExtract_NE_A58_linux_x86_64.zip -O ./UEFIExtract.zip
-unzip ./UEFIExtract.zip -d ./3rdparty/
-rm -f ./UEFIExtract.zip
-
-git clone https://github.com/awilliam/rom-parser.git
-cd rom-parser
-
-bundle install --path=vendor/bundle
-gem install bundler:1.17.3
-
-make
-mv ./rom-fixer ../3rdparty/
-mv ./rom-parser ../3rdparty/
-cd ..
-
-bundle install --path=vendor/bundle
-
diff --git a/utils/build-fake-battery-ssdt b/utils/build-fake-battery-ssdt
deleted file mode 100755
index ac780d9..0000000
--- a/utils/build-fake-battery-ssdt
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-
-ACPI_TABLES_DIR="$(readlink -f "${PROJECT_DIR}/acpi-tables")"
-
-# This script compiles the asm source code for the SSDT table that contains a fake battery for the VM.
-
-iasl "${ACPI_TABLES_DIR}/fake-battery.asl" # creates fake-battery.aml
\ No newline at end of file
diff --git a/utils/lsiommu b/utils/lsiommu
deleted file mode 100755
index 3da599e..0000000
--- a/utils/lsiommu
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env bash
-
-shopt -s nullglob
-for d in /sys/kernel/iommu_groups/*/devices/*; do
- n=${d#*/iommu_groups/*}; n=${n%%/*}
- printf 'IOMMU Group %s ' "$n"
- lspci -nns "${d##*/}"
-done;
diff --git a/utils/ovmf-vbios-patch-setup b/utils/ovmf-vbios-patch-setup
deleted file mode 100755
index 94dc9da..0000000
--- a/utils/ovmf-vbios-patch-setup
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-
-# This script builds a Docker image that allows us to patch OVMF_CODE.fd and OVMF_VARS.fd with your vBIOS ROM.
-# This helps circumvent Nvidia's Error 43 in some cases.
-
-mkdir -p "${PROJECT_DIR}/thirdparty"
-cd "${PROJECT_DIR}/thirdparty"
-
-sudo service docker start
-git clone https://github.com/T-vK/ovmf-with-vbios-patch.git
-cd ovmf-with-vbios-patch
-sudo docker build -t ovmf-vbios-patch .
\ No newline at end of file
diff --git a/utils/set-kernel-params b/utils/set-kernel-params
deleted file mode 100755
index fd4bb43..0000000
--- a/utils/set-kernel-params
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
-PROJECT_DIR="${SCRIPT_DIR}/.."
-UTILS_DIR="${PROJECT_DIR}/utils"
-DISTRO=$("${UTILS_DIR}/distro-info")
-DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
-
-source "$DISTRO_UTILS_DIR/kernel-param-utils"
-
-echo "Adding kernel parameters..."
-# Docs: https://www.kernel.org/doc/Documentation/admin-guide/kernel-parameters.txt
-# More docs: https://lwn.net/Articles/252826/
-# https://www.kernel.org/doc/Documentation/x86/x86_64/boot-options.txt
-echo "Adding kernel parameters to enable IOMMU on Intel/AMD CPUs..."
-addKernelParam "iommu=1" # '1' is not a documented option. stop confusing me wendell! Maybe the "force" option should be used instead?
-addKernelParam "amd_iommu=on" # 'on' is not a docuemnted option for this parameter either! This is insanely confusing!
-addKernelParam "intel_iommu=on" # enable Intel VT-D ;# using "intel_iommu=on,igfx_off" iGPU gets no iommu group...
-echo "Adding kernel parameter to enable mediated iGPU passthrough support (GVT-g) on Intel iGPUs..."
-addKernelParam "i915.enable_gvt=1"
-echo "Adding a kernel parameter to prevent bluescreens when a VM does MSR reads / writes directly..."
-addKernelParam "kvm.ignore_msrs=1"
-echo "Adding a kernel parameter to tell dracut to load vfio-pci first..."
-addKernelParam "rd.driver.pre=vfio-pci" # tell dracut to load vfio-pci first
-
-# echo "Adding a kernel parameter to add skylake support..."
-# addKernelParam "i915.preliminary_hw_support=1" # add skylake support; probably only necessary with older kernels
-# echo "Adding a kernel parameter that may fix 'fix /dev/vfio/1 not found' errors..."
-# addKernelParam "pcie_acs_override=downstream" # fix /dev/vfio/1 not found error # shouldn't be necessary
-#addKernelParam "acpi_osi=!" # may fix problems with AMI style UEFIs
-#addKernelParam "acpi_osi='Windows 2009'" # may fix problems with AMI style UEFIs
-
-#echo "Adding vfio stub drivers to initramfs..."
-#addInitramfsDriver vfio_virqfd
-#addInitramfsDriver vfio_pci
-#addInitramfsDriver vfio_iommu_type1
-#addInitramfsDriver vfio
-#
-#
-#echo "(Re)building initramfs for the current kernel to apply driver changes..."
-#applyInitramfsChanges
-echo "Applying the kernel parameter changes..."
-applyKernelParamChanges
diff --git a/vm-files/network-scripts/nat_ifdown b/vm-files/network-scripts/nat_ifdown
deleted file mode 100755
index bda185b..0000000
--- a/vm-files/network-scripts/nat_ifdown
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash
-# qemu-ifdown script for QEMU/KVM with NAT network mode
-
-# set your bridge name
-BRIDGE="virbr0"
-
-if [ -n "$1" ]; then
- echo "Tearing down network bridge for $1" > /tmp/temp-nat.log
- ip link set $1 down
- brctl delif "$BRIDGE" $1
- ip link set "$BRIDGE" down
- brctl delbr "$BRIDGE"
- iptables -t nat -F
- exit 0
-else
- echo "Error: no interface specified" > /tmp/temp-nat.log
- exit 1
-fi
diff --git a/vm-files/network-scripts/nat_ifup b/vm-files/network-scripts/nat_ifup
deleted file mode 100755
index 2b130a1..0000000
--- a/vm-files/network-scripts/nat_ifup
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/bin/bash
-# qemu-ifup script for QEMU/KVM with NAT netowrk mode
-
-# set your bridge name
-BRIDGE=virbr0
-
-# Network information
-NETWORK=192.168.122.0
-NETMASK=255.255.255.0
-# GATEWAY for internal guests is the bridge in host
-GATEWAY=192.168.122.1
-DHCPRANGE=192.168.122.2,192.168.122.254
-
-# Optionally parameters to enable PXE support
-TFTPROOT=
-BOOTP=
-
-function check_bridge()
-{
- if brctl show | grep "^$BRIDGE" &> /dev/null; then
- return 1
- else
- return 0
- fi
-}
-
-function create_bridge()
-{
- brctl addbr "$BRIDGE"
- brctl stp "$BRIDGE" on
- brctl setfd "$BRIDGE" 0
- ifconfig "$BRIDGE" "$GATEWAY" netmask "$NETMASK" up
-}
-
-function enable_ip_forward()
-{
- echo 1 > /proc/sys/net/ipv4/ip_forward
-}
-
-function add_filter_rules()
-{
- iptables -t nat -A POSTROUTING -s "$NETWORK"/"$NETMASK" \
- ! -d "$NETWORK"/"$NETMASK" -j MASQUERADE
-}
-
-function start_dnsmasq()
-{
- # don't run dnsmasq repeatedly
- ps -ef | grep "dnsmasq" | grep -v "grep" &> /dev/null
- if [ $? -eq 0 ]; then
- echo "Warning:dnsmasq is already running. No need to run it again."
- return 1
- fi
-
- dnsmasq \
- --strict-order \
- --except-interface=lo \
- --interface=$BRIDGE \
- --listen-address=$GATEWAY \
- --bind-interfaces \
- --dhcp-range=$DHCPRANGE \
- --conf-file="" \
- --pid-file=/var/run/qemu-dnsmasq-$BRIDGE.pid \
- --dhcp-leasefile=/var/run/qemu-dnsmasq-$BRIDGE.leases \
- --dhcp-no-override \
- ${TFTPROOT:+"--enable-tftp"} \
- ${TFTPROOT:+"--tftp-root=$TFTPROOT"} \
- ${BOOTP:+"--dhcp-boot=$BOOTP"}
-}
-
-function setup_bridge_nat()
-{
- check_bridge "$BRIDGE"
- if [ $? -eq 0 ]; then
- create_bridge
- fi
- enable_ip_forward
- add_filter_rules "$BRIDGE"
- start_dnsmasq "$BRIDGE"
-}
-
-# need to check $1 arg before setup
-if [ -n "$1" ]; then
- setup_bridge_nat
- ifconfig "$1" 0.0.0.0 up
- brctl addif "$BRIDGE" "$1"
- exit 0
-else
- echo "Error: no interface specified."
- exit 1
-fi
diff --git a/vm-files/network-scripts/tap_ifdown b/vm-files/network-scripts/tap_ifdown
deleted file mode 100755
index 612d0d8..0000000
--- a/vm-files/network-scripts/tap_ifdown
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-# tap device name
-TAP=tap0
-
-# Network information
-NETWORK=192.168.99.0
-NETMASK=255.255.255.0
-GATEWAY=192.168.99.1
-
-DNSMASQPID=$(cat "/var/run/qemu-dnsmasq-$TAP.pid")
-
-if [ ! "$DNSMASQPID" = "" ]; then
- kill -s SIGTERM $DNSMASQPID && echo "DNSMASQ terminated"
-fi
-
-ip link set $TAP down
-ip addr flush dev $TAP
-
-iptables -t nat -D POSTROUTING -s $NETWORK/$NETMASK -j MASQUERADE
-iptables -D INPUT -i $TAP -s $NETWORK/$NETMASK -d $NETWORK/$NETMASK -j ACCEPT
-iptables -D INPUT -i $TAP -p tcp -m tcp --dport 67 -j ACCEPT
-iptables -D INPUT -i $TAP -p udp -m udp --dport 67 -j ACCEPT
-iptables -D INPUT -i $TAP -p tcp -m tcp --dport 53 -j ACCEPT
-iptables -D INPUT -i $TAP -p udp -m udp --dport 53 -j ACCEPT
-iptables -D FORWARD -i $TAP -o $TAP -j ACCEPT
-iptables -D FORWARD -s $NETWORK/$NETMASK -i $TAP -j ACCEPT
-iptables -D FORWARD -s $GATEWAY -i $TAP -j ACCEPT
-iptables -D FORWARD -d $NETWORK/$NETMASK -o $TAP -m state --state RELATED,ESTABLISHED -j ACCEPT
-
-echo 0 | dd of=/proc/sys/net/ipv4/ip_forward > /dev/null && echo "ip_forward disabled"
\ No newline at end of file
diff --git a/vm-files/network-scripts/tap_ifup b/vm-files/network-scripts/tap_ifup
deleted file mode 100755
index e89ac40..0000000
--- a/vm-files/network-scripts/tap_ifup
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/bash
-
-# Set to the name of your tap device
-TAP=tap0
-
-# Network information
-NETWORK=192.168.99.0
-NETMASK=255.255.255.0
-GATEWAY=192.168.99.1
-DHCPRANGE=192.168.99.2,192.168.99.10
-
-check_tap() {
- if ip link show | grep $TAP > /dev/null; then
- return
- else
- exit 1
- fi
-}
-
-enable_ip_forward() {
- echo 1 | dd of=/proc/sys/net/ipv4/ip_forward > /dev/null
-}
-
-start_dnsmasq(){
- dnsmasq \
- --strict-order \
- --interface=$TAP \
- --listen-address=$GATEWAY \
- --bind-interfaces \
- --dhcp-range=$DHCPRANGE \
- --dhcp-no-override \
- --pid-file=/var/run/qemu-dnsmasq-$TAP.pid
-}
-
-add_iptable_rules() {
-iptables-restore -n <