Skip to content

Instantly share code, notes, and snippets.

@timsutton
Created April 9, 2017 23:38
Show Gist options
  • Save timsutton/f5525e81beba52f678845be8d67b5942 to your computer and use it in GitHub Desktop.
Save timsutton/f5525e81beba52f678845be8d67b5942 to your computer and use it in GitHub Desktop.
Use AutoPkg and Rich Trouton's VMware Tools recipe to download and install the 'darwin' VMware guest tools on a macOS system
#!/bin/sh -e
# Downloading VMware Tools within guest automatically using AutoPkg and Rich Trouton's
# VMware Tools recipe - used within ESXi build to workaround complicated tools
# upload issues (https://github.com/timsutton/osx-vm-templates/pull/30)
tmpdir=$(mktemp -d /tmp/vmware-tools-XXXXXX)
(
cd "${tmpdir}"
curl -fsL -o autopkg.zip \
https://github.com/autopkg/autopkg/archive/master.zip
curl -fsL -o rtrouton-recipes.zip\
https://github.com/autopkg/rtrouton-recipes/archive/master.zip
unzip rtrouton-recipes.zip
unzip autopkg.zip
autopkg-master/Code/autopkg run -v \
rtrouton-recipes-master/VMware-Tools/VMwareTools.download.recipe -v
mountpoint=$(mktemp -d /tmp/tools-mount-XXXX)
hdiutil attach -mountpoint "${mountpoint}" ~/Library/AutoPkg/Cache/com.github.rtrouton.download.VMwareTools/VMwareTools.iso
pkg_location="$mountpoint/Install VMware Tools.app/Contents/Resources/VMware Tools.pkg"
if [ ! -e "$pkg_location" ]; then
echo "Couldn't locate VMware installer pkg at $pkg_location!"
exit 1
fi
echo "Installing VMware tools.."
installer -pkg "$mountpoint/Install VMware Tools.app/Contents/Resources/VMware Tools.pkg" -target /
hdiutil detach "$mountpoint"
)
# clean up
rm -rf "${tmpdir}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment