After publishing my recent article on automating the silent installation of VMware Tools for Linux guestOSes, I received a similar question regarding Mac OS X guests and whether the existing script would also apply. The answer is no since Mac OS X packages differ from the Linux installres, but it is possible to automate the installation of VMware Tools for Mac OS X guests.
After quickly looking into this, I realized there are actually several options that are available to customers and it would depend on how you would like to install VMware Tools and what platform you are running your Mac OS X guests on. I will share a couple of options which also includes existing solutions that have already been developed. At the end of the day, the choice will ultimately be up to the administrator on how he/she would like to proceed.
Option 1 - If you are a vSphere/ESXi customer running Mac OS X, you will probably want to mount the VMware Tools installer and then initiate an installation within the Guest. You can actually perform the entire operation within a single context by leveraging our vSphere API to issue the VMware Tools installer and then using the Guest Operations API to perform the installation.
Option 2 - Similar to the above option, if you do not wish to use the vSphere API, you can simply copy the darwin.iso (VMware Tools) image onto your Mac OS X guests and then perform the automated install. This would be the most simplistic option and would apply to running Mac OS X guests on either vSphere/ESXi or Fusion.
Option 3 - You can also download VMware Tools using VMware's online repository (thanks to Rich Trouton for sharing this tidbit) and then performing the installation which is very similar to Option 2. The only downside is if you are running Mac OS X on vSphere/ESXi, the status of VMware Tools will show "unsupported" as the version will differ from version distributed with vSphere/ESXi. In fact, Rich Trouton has an existing solution that he has published here which you can read more about.
If you are already familiar with using the vSphere API and are using vSphere/ESXi, I personally would go with Option 1 just because you can stay within a single context from an automation standpoint and not have to jump between different interfaces. If you not comfortable, want a quick solution or running just Fusion, then Option 2 and 3 would be ideal. Below is an example Gist demonstrating a simple shell script which implements Option 2 and Option 3 with a slight twist from what Rich has done which does not require Git.
Here's an example of running the script using Option 2:
I am sure there are probably other methods out there, but the great news is that it is indeed possible to automate VMware Tools for Mac OS X guests 🙂
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 1 = VMware Tools ISO is mounted from vSphere | |
# 2 = Download VMware Tools (assumes you can connect to internet) | |
INSTALL_METHOD=2 | |
# Thanks to Rich Trouton for tip on Tools being available online | |
VMWARE_TOOLS_DOWNLOAD_URL=http://softwareupdate.vmware.com/cds/vmw-desktop/fusion/7.1.2/2779224/packages/com.vmware.fusion.tools.darwin.zip.tar | |
# DO NOT MODIFY BEYOND HERE # | |
VMWARE_TOOLS_INSTALLER_DIR="/Volumes/VMware Tools/Install VMware Tools.app/Contents/Resources" | |
VMWARE_TOOLS_INSTALLER_FILE="VMware Tools.pkg" | |
if [ $EUID -ne 0 ]; then | |
echo "Please run the script with sudo ..." | |
exit 1 | |
fi | |
if [ ${INSTALL_METHOD} == "1" ]; then | |
if [ -d "${VMWARE_TOOLS_INSTALLER_DIR}" ]; then | |
/usr/sbin/installer -pkg "${VMWARE_TOOLS_INSTALLER_DIR}/${VMWARE_TOOLS_INSTALLER_FILE}" -target / | |
echo "Please reboot the system for the installation to complete ..." | |
fi | |
elif [ ${INSTALL_METHOD} == "2" ]; then | |
TMP_DIR=/tmp/osx-vmware-tools | |
mkdir -p "${TMP_DIR}" | |
VMWARE_TOOLS_TAR_FILE=com.vmware.fusion.tools.darwin.zip.tar | |
VMWARE_TOOLS_ZIP_FILE=com.vmware.fusion.tools.darwin.zip | |
VMWARE_TOOLS_ISO_FILE="payload/darwin.iso" | |
cd ${TMP_DIR} | |
# Download VMware Tools from online repo | |
curl -O "${VMWARE_TOOLS_DOWNLOAD_URL}" | |
# Extract the VMware Tools tar file | |
tar -xf "${VMWARE_TOOLS_TAR_FILE}" | |
# Unzip the VMware Tools zip file | |
unzip "${VMWARE_TOOLS_ZIP_FILE}" | |
# Mount VMware Tools ISO (similiar to vSphere/ESXi) | |
hdiutil attach "${VMWARE_TOOLS_ISO_FILE}" | |
# Perform installation | |
/usr/sbin/installer -pkg "${VMWARE_TOOLS_INSTALLER_DIR}/${VMWARE_TOOLS_INSTALLER_FILE}" -target / | |
# Detach mount & clean up | |
hdiutil detach '/Volumes/VMware Tools' | |
rm -rf "${TMP_DIR}" | |
echo "Please reboot the system for the installation to complete ..." | |
else | |
echo "Invalid Selection" | |
fi |
Abdel Gomez says
Hey William,
Great post. Wondering if this is at all possible on OS X 10.11 and mac OS 10.12. For me there seems to be an issue doing any sort of operation involving the FileManager on these platforms. e.g. : listFilesInGuest() or initiateFileTransferToGuest() will fail with "unable to authenticate" right after validateCredentialsInGuest() succeeds.
Cheers!