Blame rpmconfigcheck

Bernhard M. Wiedemann dbd852
#! /bin/sh
Bernhard M. Wiedemann 1250f9
# Copyright (c) 2002 SUSE GmbH Nuernberg, Germany.
Bernhard M. Wiedemann 1250f9
#
Bernhard M. Wiedemann 1250f9
# Author: Michael Schroeder <feedback@suse.de>
Bernhard M. Wiedemann 1250f9
#
Bernhard M. Wiedemann 1250f9
# Script to scan for unresolved .rpmnew, .rpmorig, and .rpmsave files
Bernhard M. Wiedemann 1250f9
#
Bernhard M. Wiedemann 1250f9
Bernhard M. Wiedemann 1250f9
configcheckfile=/var/adm/rpmconfigcheck
Bernhard M. Wiedemann 4b0d85
packages=/var/lib/rpm/Packages.db
Bernhard M. Wiedemann 1250f9
Bernhard M. Wiedemann 1250f9
if test -s $packages -a \( ! -e $configcheckfile -o -s $configcheckfile -o ! $packages -ot $configcheckfile \) ; then
Bernhard M. Wiedemann 1250f9
    echo "Searching for unresolved configuration files"
Bernhard M. Wiedemann 1250f9
    if test ! -e $configcheckfile -o ! $packages -ot $configcheckfile ; then
Bernhard M. Wiedemann 1250f9
	test -e $configcheckfile && mv -f $configcheckfile $configcheckfile.old
Bernhard M. Wiedemann 88e749
	rpm -qalc | sort | while read line; do
Bernhard M. Wiedemann 88e749
            for suffix in new orig save; do
Bernhard M. Wiedemann dbd852
                [ -e "${line}.rpm${suffix}" ] && echo "${line}.rpm${suffix}"
Bernhard M. Wiedemann 88e749
            done
Bernhard M. Wiedemann 88e749
        done > $configcheckfile
Bernhard M. Wiedemann 1250f9
    else
Bernhard M. Wiedemann 1250f9
	mv -f $configcheckfile $configcheckfile.old
Bernhard M. Wiedemann 1250f9
	while read l; do
Bernhard M. Wiedemann 1250f9
	    test -e $l && echo $l
Bernhard M. Wiedemann 1250f9
	done < $configcheckfile.old > $configcheckfile
Bernhard M. Wiedemann 1250f9
    fi
Bernhard M. Wiedemann 1250f9
    if test -s $configcheckfile; then
Bernhard M. Wiedemann 1250f9
	echo "Please check the following files (see /var/adm/rpmconfigcheck):"
Bernhard M. Wiedemann 1250f9
	sed -e 's/^/    /' < $configcheckfile
Bernhard M. Wiedemann 1250f9
	touch $configcheckfile.old
Bernhard M. Wiedemann 1250f9
	cat $configcheckfile $configcheckfile.old | sort | uniq -d > $configcheckfile.dup
Bernhard M. Wiedemann 1250f9
	cat $configcheckfile $configcheckfile.dup | sort | uniq -u > $configcheckfile.new
Bernhard M. Wiedemann 1250f9
	if test -s $configcheckfile.new ; then
Bernhard M. Wiedemann 1250f9
	    (
Bernhard M. Wiedemann 1250f9
		echo "----------------------------------------------------------------------"
Bernhard M. Wiedemann 1250f9
		echo "----------------------------------------------------------------------"
Bernhard M. Wiedemann 1250f9
		echo "rpmconfigcheck"
Bernhard M. Wiedemann 1250f9
		date
Bernhard M. Wiedemann 1250f9
		echo "----------------------------------------"
Bernhard M. Wiedemann 1250f9
		echo "This is a warning message."
Bernhard M. Wiedemann 1250f9
		echo "rpmconfigcheck has found the following new unresolved config files"
Bernhard M. Wiedemann 1250f9
		echo "(all files are listed in /var/adm/rpmconfigcheck):"
Bernhard M. Wiedemann 1250f9
		cat $configcheckfile.new
Bernhard M. Wiedemann 1250f9
		echo "----------------------------------------"
Bernhard M. Wiedemann 1250f9
	    ) >> /var/log/update-messages
Bernhard M. Wiedemann 1250f9
	fi
Bernhard M. Wiedemann 1250f9
    fi
Bernhard M. Wiedemann 1250f9
    rm -f $configcheckfile.old $configcheckfile.dup $configcheckfile.new
Bernhard M. Wiedemann 1250f9
fi