Skip to content

Instantly share code, notes, and snippets.

@joshuar
Created November 20, 2014 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuar/11a57620601e04156ba0 to your computer and use it in GitHub Desktop.
Save joshuar/11a57620601e04156ba0 to your computer and use it in GitHub Desktop.
Email a diff of .rpmnew and .rpmsave file changes to an admin to consider
#!/usr/bin/env bash
mail_to=root
ignorefile=/etc/rpm-dispatch-conf.ignore
newfiles=$(find / -noleaf -ignore_readdir_race -xdev -name \*.rpmsave -or -name \*.rpmnew 2>/dev/null)
for f in $newfiles; do
newfile=$f
oldfile=$f
oldfile=${oldfile%%.rpmnew}
oldfile=${oldfile%%.rpmsave}
grep $oldfile /etc/rpm-dispatch-conf.ignore 1>/dev/null 2>&1
if [[ $? ]]; then
mailfile=$(mktemp)
mail_subject="Subject: File needs updating: $oldfile"
echo >> ${mailfile}
echo "Add file to ${ignorefile} to ignore changes." >> ${mailfile}
echo >> ${mailfile}
diff -u $oldfile $newfile 1>> ${mailfile} 2>&1
mail -s "${mail_subject}" ${mail_to} < ${mailfile}
test -e ${mailfile} && rm -f ${mailfile}
fi
done
exit 0
@joshuar
Copy link
Author

joshuar commented Dec 14, 2014

Details

This is a simple script that trawls your filesystem looking for 'rpmsave' or 'rpmnew' files that indicate a new upstream configuration changes that conflict with your local modifications. It will send an email to root for each of these files it encounters with a diff detailing what the changes are.

It is heavily inspired by Gentoo's dispatch-conf tool.

Instructions

Download this gist, make the script executable and then either configure it to run under cron (or another task scheduler) or run manually after updating your system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment