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, conversely, 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, Mac, Solaris, and FreeBSD and as System on Windows, 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, 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 the commands used in this procedure and need to know what the exit codes are, see Exit Codes.
- 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.
On Linux, Solaris, and FreeBSD guest operating systems, the default scripts are located in the /etc/vmware-tools directory. On Mac OS X operating systems the default scripts are located in the /Library/Application Support/VMware Tools directory.
Do not make changes to the default scripts.
After you complete this procedure, the VMware Tools service runs the script whenever the specified power operation occurs.