You are here

Auto-configure vmware-tools at boottime on CentOS 6

So, a few years ago I wrote a simple script to configure the vmware-tools at boot after a kernel upgrade. This worked well for us ever since. However, on CentOS 6 machines I noticed there's no vmware-tools service anymore after the latest vmware-tools upgrade (version 8.6.11 on our machines).

It seems VMware moved the starting/stopping of VMware-tools from an old style sysv-rc script to an upstart script in /etc/init (/etc/init/vmware-tools.conf to be exactly). In this script a subscript /etc/vmware-tools/services.sh is executed to start the vmware-tools.

So, there's an updated version that should work well on both CentOS 6 and older versions:

#!/bin/bash
#
# check-vmware-tools
#
# chkconfig:   - 00 99
# description: Check whether or not the vmware-tools are installed at boot time.
# processname: check-vmware-tools
#

loadvmxnet() {
  if [ "`uname -i`" != "x86_64" ]; then
        echo -n "Reloading vmxnet driver... "
        /sbin/rmmod pcnet32
        /sbin/rmmod vmxnet
        /sbin/depmod -a
        /sbin/modprobe vmxnet
        echo "done"
  fi
}

case $1 in
  start)
    echo -n $"Checking VMware-tools: "
   if [ ! -e /lib/modules/`/bin/uname -r`/misc/vmci.ko ]; then
      echo "Not available, running vmware-config-tools..."
      /usr/bin/vmware-config-tools.pl --default && loadvmxnet
      [ -f /etc/vmware-tools/services.sh ] && /etc/vmware-tools/services.sh start
   else
     echo "OK"
   fi
  ;;
  *)
    echo "Usage: $0 start"
    exit 1
  ;;
esac

The only big difference is that it checks for the existence of /etc/vmware-tools/services.sh and runs it if it's there.