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.
About this task
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.
Familiarize yourself with the default VMware Tools scripts. See Default VMware Tools Scripts.
On Linux, Mac OS X, Solaris, and FreeBSD guest operating systems, if you plan to test, edit, or disable the running of a script, log in as root.
If you plan to script commands and need to know what the exit codes are, see Exit Codes for the VMware Tools Configuration Utility.
- Log in to the guest operating system as root.
- 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
Linux, Solaris, FreeBSD
Mac OS X
/Library/Application Support/VMware Tools
Do not make changes to the default scripts.
The VMware Tools service runs the script whenever the specified power operation occurs.