Run script after yum install & yum update

Rob Hassing <[email protected]>
Newsgroups gmane.linux.rpm.yum
Message-ID <[email protected]>
Hello all,

Would it be possible to run a script every time yum is finished after an 
update or install a package?
I would like to add the priority information in the specific files.
After an upgrade all priority information is missing in the .repo files.

The script looks like this:
#!/bin/bash
# Change the default CentOS repositories files to have priority 2
find /etc/yum.repos.d/Cent*.repo -size +1c > /tmp/files.tmp
while read filename
do
         grep -q "priority=" $filename
         if [ $? -ne 0 ] ; then
                 mv $filename $filename.BG
                 sed  -e "/^\[/a\priority=2" $filename.BG >> $filename
                 rm -f $filename.BG
                 echo $filename
         fi
done < /tmp/files.tmp
rm -f /tmp/files.tmp
# Change the "thirdparty"  repositories files to have priority 12
find /etc/yum.repos.d/*.repo -size +1c > /tmp/files.tmp
while read filename
do
         grep -q "priority=" $filename
         if [ $? -ne 0 ] ; then
                 mv $filename $filename.BG
                 sed  -e "/^\[/a\priority=12" $filename.BG >> $filename
                 rm -f $filename.BG
                 echo $filename
         fi
done < /tmp/files.tmp
rm -f /tmp/files.tmp


Best regards,
Rob
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.