install.fairie/home/.chezmoiscripts/universal/run_onchange_after_45-vmware.tmpl

49 lines
1.9 KiB
Cheetah
Raw Normal View History

{{- if ne .host.distro.family "windows" -}}
#!/usr/bin/env bash
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
### Run logic if VMWare is installed
if command -v vmware > /dev/null; then
### Build kernel modules
# TODO - Add check to see if kernel modules are required before running this logic
if sudo vmware-modconfig --console --install-all; then
:
else
logg info 'Acquiring VMWare version from CLI'
VMW_VERSION=$(vmware --version | cut -f 3 -d' ')
mkdir -p /tmp/vmw_patch
cd /tmp/vmw_patch
logg info 'Downloading VMWare host module patches'
curl -sSL https://github.com/mkubecek/vmware-host-modules/archive/workstation-$VMW_VERSION.tar.gz -o /tmp/vmw_patch/workstation.tar.gz
tar -xzf /tmp/vmw_patch/workstation.tar.gz
cd vmware*
logg info 'Running `sudo make` and `sudo make install`'
sudo make
sudo make install
logg success 'Successfully configured VMWare host module patches'
fi
### Patch VMWare with Unlocker
if [ ! -f /usr/lib/vmware/isoimages/darwin.iso ]; then
logg info 'Acquiring VMWare Unlocker latest release version'
UNLOCKER_URL=$(curl -sSL https://api.github.com/repos/DrDonk/unlocker/releases/latest | jq -r '.assets[0].browser_download_url')
mkdir -p /tmp/vmware-unlocker
cd /tmp/vmware-unlocker
logg info 'Downloading unlocker.zip'
curl -sSL "$UNLOCKER_URL" -o unlocker.zip
unzip unlocker.zip
cd linux
logg info 'Running the unlocker'
echo "y" | sudo ./unlock
logg success 'Successfully unlocked VMWare for macOS compatibility'
else
logg info '/usr/lib/vmware/isoimages/darwin.iso is already present on the system so VMWare macOS unlocking will not be performed'
fi
else
logg warn 'VMware Workstation is not installed so the VMware Unlocker will not be installed'
fi
{{ end -}}