Skip to content

Instantly share code, notes, and snippets.

@jblaine
Created June 4, 2012 21:33
Show Gist options
  • Select an option

  • Save jblaine/2870955 to your computer and use it in GitHub Desktop.

Select an option

Save jblaine/2870955 to your computer and use it in GitHub Desktop.
Safer yum
#!/bin/sh
#
# If yum experiences a corrupt database it very frequently
# just hangs. This most commonly seen as a hung 'rpmq'
# command (a child of yum). When performing automated yum
# commands, this is bad news, as they can just start piling up.
#
# Try to determine if there are any corrupt RPM database files, try
# to rebuild them if so, THEN run yum.
#
# jblaine 6/4/2012
if [ -x /usr/lib/rpm/rpmdb_verify ]; then
/usr/lib/rpm/rpmdb_verify /var/lib/rpm/[A-Z]* > /dev/null 2>&1
if [ $? -ne 0 ]; then
rpm --rebuilddb
fi
fi
/usr/bin/yum "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment