Running post-install/update scripts with yum-plugin-post-transaction-actions

June 6, 2013 under Main

Ever had the problem where periodic security/bug fix updates installed via yum end up breaking things because the RPM packages run post-install scripts that do annoying things like change ownership or permissions on files or directories?

For example the httpd package on CentOS always resets the owner of /var/www/html post-update. If you’ve changed this directory to be owned by another user on your system, chances are it’ll get reverted every time httpd is updated. Same goes for the tomcat log and temp directories when updating the tomcat6 package.

CentOS 6 includes a helpful new plugin for yum called yum-plugin-post-transaction-actions. It doesn’t get installed by default but a simple ‘yum -y install yum-plugin-post-transaction-actions’ will install it for you.

To use it all you have to do is create a new file in /etc/yum/post-actions/ like this, which resets the owner of the Tomcat log and temp dirs post-update: (file: /etc/yum/post-actions/tomcat6.action)

#!/bin/sh
tomcat6*:update:/bin/chown -R myuername /var/cache/tomcat6/temp /var/log/tomcat6

For further information on the syntax and variables available to your script, see the docs at fedoraproject.org.

comments: Comments Off on Running post-install/update scripts with yum-plugin-post-transaction-actions