Wednesday, May 15, 2013

CentOS - Install VMWare Tools after kernel update

create file vmware-checktools , touch vmware-checktools , contents of file below,

#! /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


copy the file vmware-checktools into the directory  /etc/init.d , cp vmware-checktools /etc/init.d

change permissions on the file,  chmod 755 /etc/init.d/vmware-checktools

create symbolic link in startup directory to the script, ln -s /etc/init.d/vmware-checktools /etc/rc3.d/S09vmware-checktools