Re: Restoring rpm packages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 15 Mar 2005 18:05:12 +0000, Timothy Murphy
<tim@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> On Tue 15 Mar 2005 00:36, Matthew Miller wrote:
> 
> > > In any case, what I would like to do is to verify all the rpm packages
> > > on the system, and to re-install any that are damaged.
> > > Is that possible?
> > > If it is, is there any script that would simplify the task?
> >
> > Try 'rpm -Va', to verify all installed packages. (Look at the rpm man page
> > to see what the resulting codes mean.) You'll get some "false positives"
> > from config files, etc., which change in the course of normal events.
> 
> Thanks for your response.
> I knew of the "rpm -V" command, though it didn't occur to me
> that one could combine it with "-a";
> my idea was just to run through all the packages listed in /var/log/rpmpkgs .
> 
> However, I ran "rpm -Va" on my laptop last night
> (capturing the response with script)
> but I am not really sure how to use the result.
> For one thing, it would be tedious to find all the packages
> in which the files mention occur.
> 
> As I said, it would be nice to have a script "CheckMyPackages"
> which would just go through installed packages
> running "rpm -Uvh --force" for those that have been changed.
> 

I had a similar problem with the hard disk getting randomly corrupted
on my laptop (Compaq Armada M700). It turned out to be because I'd
switched DMA on, which the disk didn't like.

Before I discovered this, I wrote the attached script which emails a
list of rpms for which verify failed. It's then up to you to
re-install or ignore. The script allows you to cache 'expected
failures', so that you can e.g. ignore a changed /etc/passwd. I hope
it is self explanatory.

NB prelink causes rpm -V to fail, so you will get a lot of false positives.

Chris
#!/bin/bash
##############################################################################
# This really shouldn't be necessary...
# Author: Chris Rouch
# Date: 31/05/2002
# Changelog:
##############################################################################
CACHEDIR=/var/cache/verify
MISSING=$CACHEDIR/missingok
PATTERNS=$CACHEDIR/patternok
OUTPUT=$CACHEDIR/verify.out
FAILED=$CACHEDIR/failedfiles
FAILEDRPMS=$CACHEDIR/failedrpms
WHOTO=root

if [ ! -d $CACHEDIR ]; then
    mkdir $CACHEDIR
    touch $MISSING
    touch $PATTERNS
fi
rpm -Va > $OUTPUT 2>/dev/null
grep -v -f $MISSING -f $PATTERNS $OUTPUT > $FAILED
if [ -s "$FAILED" ]
then
    rpm -qf --queryformat="%{NAME}\n" `cut -c12-  $FAILED` | \
	sort -u > $FAILEDRPMS
    mail -s "`hostname`: Corrupt rpms" $WHOTO < $FAILEDRPMS
else
     echo "All rpms intact"
fi

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux