Code:
#!/bin/bash
# Purpose: Restore filesystem permissions from RPM database
# distro's that don't do package management suck major.
# *Make sure yer RPM database is sane...
# Args: none or package name
# Deps: Bash, GNU utils, rpm
# Run from: manual, emergency only
case "$#" in
0) rpmopt="a"; unset pkg;;
*) unset rpmopt; pkg="$1";;
esac
rpm -q${rpmopt} --dump ${pkg}|while read t; do
t=( ${t} ); for i in 3 4; do
case "${#t[$i]}" in
7) echo "${t[$i]:3:4} ${t[0]}";;
esac; done
done
Save this as "/tmp/rpm-perms" and make executable.
Running it as "/tmp/rpm-perms > /tmp/rpm-perms.log" should give you the log. Check the contents for errors, then running it as "/tmp/rpm-perms|while read perm file; do chmod ${perm} ${file}; done" should
restore all
permissions.
If you want to test it, you can also supply a packagename: "/tmp/rpm-perms adore" for instance would list the files and filepermissions of the Adore package.