On Linux, Mac OS X, Solaris, and FreeBSD guest operating systems, you can write scripts to automate guest operating system operations when you change the power state of a virtual machine.

For Linux, Mac OS X, Solaris, and FreeBSD guests, you can write scripts and place them in a certain directory, and then VMware Tools runs your scripts in addition to the default scripts. For power-on and resume operations, the default scripts run before the custom scripts. For suspend and power-off, the default scripts run after the custom scripts. This way, VMware Tools stops services only after the custom scripts finish their work, and restores the same services before the custom scripts attempt to use the services.)

Scripts are run by the VMware Tools service, or daemon (vmtoolsd). Because vmtoolsd is run as root on Linux, Solaris, and FreeBSD, the scripts are run in a separate session from the session of the logged-in user. The VMware Tools daemon does not detect desktop sessions, which means that it cannot display graphical applications. Do not attempt to use custom scripts to display graphical applications.

Prerequisites

Procedure

  1. Log in to the guest operating system as root.
  2. Write the custom scripts and place them in the correct directory, as instructed by the comments in the default script files for each power operation.
    Guest Operating System Directory
    Linux, Solaris, FreeBSD /etc/vmware-tools
    Mac OS X /Library/Application Support/VMware Tools

    Do not make changes to the default scripts.

Results

The VMware Tools service runs the script whenever the specified power operation occurs.