Skip to content

Instantly share code, notes, and snippets.

@aarondill
Created September 19, 2024 02:54
Show Gist options
  • Save aarondill/07d1be02a922df7942acec5024a99c40 to your computer and use it in GitHub Desktop.
Save aarondill/07d1be02a922df7942acec5024a99c40 to your computer and use it in GitHub Desktop.
a script to install vmware on Ubuntu
#!/usr/bin/env bash
set -euC -o pipefail
version=17.5.0
vmware_lib="/usr/lib/vmware/modules/source"
product="$(vmware-installer -l 2>/dev/null | tail -n1 | cut -f1 -d' ')" || true
if [ -n "$product" ]; then
echo "Uninstalling $product"
sudo vmware-installer -u "$product"
fi
deps=(make gcc)
if ! command -v -- "${deps[@]}" &>/dev/null; then
echo "Installing dependencies (${deps[*]})"
sudo apt install "${deps[@]}"
fi
installers=(./VMware*.bundle) # hack to expand glob
installer="${installers[0]}"
echo "Using installer $installer"
chmod u+x -- "$installer"
sudo -- "$installer"
tar="$PWD/workstation-$version.tar.gz"
echo "Downaloading kernal modules ($version) from Github"
wget "https://github.com/mkubecek/vmware-host-modules/archive/$(basename -- "$tar")"
tar -xzf "$tar"
tar_out="$PWD/vmware-host-modules-workstation-$version"
pushd "$tar_out" &>/dev/null
tar -cf vmmon.tar vmmon-only/
tar -cf vmnet.tar vmnet-only/
echo "Installing kernal modules"
sudo mkdir -p -- "$vmware_lib"
sudo cp -v vmmon.tar vmnet.tar "$vmware_lib"
popd &>/dev/null
echo "Building kernal modules"
sudo vmware-modconfig --console --install-all
echo "Success!"
echo "Run these commands to cleanup:"
printf '%s\n' "rm -rf -- ${tar_out@Q}"
printf '%s\n' "rm -rf -- ${tar@Q}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment