1

This one is pretty much a straightfoward question/answer I just can't locate the information.

I'm trying to automate the re-installation of VMWare tools based off when a new kernel is installed. I seem to remember there being a directory somewhere underneath /etc and whenever new-kernel-pkg installs a new kernel and goes to build the initrd it will execute any executable scripts it finds in there. I looked through my history and have tried to locate it on my system and via google but I can't find it.

  • Do you mean something like this? However, /etc/kernel/postinst.d seems to be not present in RHEL. – Ramesh Oct 22 '14 at 15:36
  • Also, I found this one which says about some automated re-installation of VMWare tools. – Ramesh Oct 22 '14 at 15:39
  • @Ramesh, can you post both as an answer so I can accept it? I'm going to remove the rhel tag so it's generic to all distros. – Bratchley Oct 22 '14 at 16:58
  • It looks like the dkms package is mentioned a lot in relation to the postinst.d directory. Is that the package that handles the post-install actions? I installed it via epel and it didn't pull anything else in so I would assume that means /etc/kernel/postinst.d is operated by the dkms package itself. – Bratchley Oct 22 '14 at 17:08
  • But to answer your question, yes this is exactly what I was thinking of, I'm just trying to think of a way to get it to suit my purpose. – Bratchley Oct 22 '14 at 17:09
1

From here, I see that /etc/kernel/postinst.d is the place where scripts are placed when they need to be executed during the kernel installation time. This requires that DKMS is available on your system (many distributions, including RHEL, support it).

Since you had mentioned automating the re-installation of VMWare tools, I see that you could automate it as discussed here.

The link has this below script.

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

However, I am not sure if that script does the job as required since I do not have a way to test it in my setup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.