Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff changed config files with the default ones on a debian system
#!/bin/bash
name=`basename $0`
tmp=/tmp/$name.tmp
missingPattern='^debsums: missing file'
# get differing files using debsums
debsums -e| awk '$2 !~ /OK/{print $1}' > $tmp.1
# print missing
cat $tmp.1 | grep "$missingPattern"
# get non-missing
cat $tmp.1 | grep -v "$missingPattern" > $tmp.2
# find the installed packages that contain the differing files
cat $tmp.2 | xargs dpkg -S | cut -d: -f1 | sort -u | xargs dpkg-query -W -f='${Package} ${Status}\n' | awk '$4 ~ /installed/{print $1}' > $tmp.3
# here we lose some information on which config files are in uninstalled packages... oh well
# download packages
cat $tmp.3 | xargs apt-get install -qdy --force-yes --reinstall
# extract packages to a temp dir
mkdir -p $tmp.4/
cat $tmp.3 | xargs -I%%% find /var/cache/apt/archives -name '%%%_*' | xargs -I%%% dpkg-deb --extract %%% $tmp.4/
# diff them!
cat $tmp.2 | xargs -I%%% diff %%% $tmp.4/%%% | less
# clean up
rm -rf $tmp.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.