#!/bin/sh # # rpm-V_all # # AUTHOR: # Dan Harkless # # COPYRIGHT: # This file is Copyright (C) 2019 by Dan Harkless, and is released under the # GNU General Public License . # # DESCRIPTION: # Runs 'rpm -V' on all packages installed on the system, prompting the user # for their desired action when any differences are found. Particularly # useful if some system files have been accidentally deleted or modified since # the last backup. # # Each package name being verified will be printed on a new line (in # alphabetical order), and if rpm -V doesn't find any differences, the script # will move on to the next one. # # If differences are found, the user will be prompted to type i, r, R, u, or # V, followed by , or simply by itself. To expand on the # capsule descriptions in the prompt, the choices have the following effects. # Except as stated, the user is prompted again for the next action after the # chosen one is completed. # # i: Info. Run 'rpm -qi' on the package. # # r: Reinstall + Verify. Run 'yum reinstall' on the package (to replace # missing or damaged files), then reverify with 'rpm -V'. If there are # no longer any differences, the script moves on to the next RPM. # # R: Same as 'r', but 'yum reinstall -y' is run so that it's not necessary # to enter 'y' at rpm's prompt to proceed with the reinstall. # # u: Uninstall. 'yum remove' the package. # # v: Verify. 'rpm -V' the package. This is useful if rather than # reinstalling, manual changes have been made outside the script to bring # the package back into line. As with r/R, if differences are no longer # found, the script will move on to the next package. # # : Ignores any differences in the current package (e.g. because edits # have been made to config files since the package was installed, # or because some file attributes change while the package is in # a running state), and moves on to the next package. # # The user can also hit Ctrl-C at the prompt to stop execution of the script. # # DATE MODIFICATION # ========== ================================================================== # 2019-01-24 Original. for p in `rpm -qa | sort`; do echo $p rpm -V $p stay_on_target=$? if [ $stay_on_target -ne 0 ]; then echo; echo "WARNING: Differences found in $p." fi while [ $stay_on_target -ne 0 ]; do echo -n "[i: Info. r/R: Reinstall+Verify / -y. u: Uninstall."\ "v: Verify. : Skip.] " read input if [ x"$input" = x"i" ]; then rpm -qi $p elif [ x"$input" = x"r" ]; then yum reinstall $p rpm -V $p stay_on_target=$? elif [ x"$input" = x"R" ]; then yum reinstall -y $p rpm -V $p stay_on_target=$? elif [ x"$input" = x"u" ]; then yum remove $p stay_on_target=$? elif [ x"$input" = x"v" ]; then rpm -V $p stay_on_target=$? elif [ x"$input" = x ]; then stay_on_target=0 else echo "ERROR: Unknown option '$input'." fi echo done done