I came across this site when researching a way to automatically get the VMware tools re-installed on kernel updates.

http://www.tuxyturvy.com/blog/index.php?/archives/48-Automating-VMware-modules-reinstall-after-Linux-kernel-upgrades.html

There were plenty of comments but it seemed everybody had a different way of implementing how and when the script to update gets called. Plus, as there are so many init variations amongst the distributions, some SuSe stuff would not work on Red Hat.

Anyway, I have implemented yet another solution for Red Hat / CentOS. (I’m using 5.3).

I pinched this script from the very bottom of the site on tuxy.turvy.com.

#! /bin/bash
# Following lines auto-recompile VM Tools when kernel updated
 VMToolsCheckFile="/lib/modules/`uname -r`/misc/.vmware_installed"
 VMToolsVersion=`vmware-config-tools.pl --help 2>&1 | awk '$0 ~ /^VMware Tools [0-9]/ { print $3,$4 }'`

 printf "\nCurrent VM Tools version: $VMToolsVersion\n\n"

 if [[ ! -e $VMToolsCheckFile || `grep -c "$VMToolsVersion" $VMToolsCheckFile` -eq 0 ]]; then
 [ -x /usr/bin/vmware-config-tools.pl ] && \
 printf "Automatically compiling new build of VMware Tools\n\n" && \
 /usr/bin/vmware-config-tools.pl --default && \
 printf "$VMToolsVersion" > $VMToolsCheckFile && \
 rmmod pcnet32
 rmmod vmxnet
 depmod -a
 modprobe vmxnet
 fi

Save the above as file on your server called vmware-check-tools. Then do the following as root.

# cp vmware-check-tools /etc/init.d

# chmod 755 /etc/init.d/vmware-check-tools

# cd /etc/rc.d/rc3.d

# ln -s ../init.d/vmware-check-tools S09vmware-check-tools

All Done ! That is a zero-nine BTW.  S09. If you look in that rc3.d directory, you will notice lots of scripts starting with S and K and various numbers after them. This is how the init system starts/stops processes and in which order. We want the module check script to run before the network starts (so we load the vmxnet module). The network script is listed as S10network. So, I chose s09vmware-check-tools so it would run immediately before the network starts.

This actually works and I’ve rolled it out to all my CentOS boxes. There is no need for a K script as we don’t need to run the script when the server shuts down.

What the script does is check the current kernel misc module directory for the file, ‘.vmware_installed’. If it does not find it, vmware-config-tools.pl will be run with the default flag and then the .vmware_installed file will be created so the tools won’t re-install next boot (on the same kernel).

With the above, I’m only looking after runlevel 3.  That is, boot to the prompt. If you are one of those people who feel more secure booting to X windows, that would mean you are in runlevel 5. (Check /etc/inittab). In that case, you would want to create the symbolic link S09vmware-check-tools in the rc5.d directory.

Cheers