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, conversely, restores the same services before the custom scripts attempt to use the services.
The VMware Tools service, or daemon (vmtoolsd), runs scripts. Because vmtoolsd runs as root on Linux, Mac, Solaris, and FreeBSD, and as System on Windows, the scripts 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, to test, edit, or disable the running of a script, log in as root.
- On Linux, Mac OS X, Solaris, and FreeBSD guest operating systems, to edit a script, make sure xterm and vi are installed in the guest operating system and are in your PATH, or specify which editor to use by setting the EDITOR environment variable.
- 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 Directory Linux, Solaris, FreeBSD /etc/vmware-tools 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.