Last active
July 4, 2024 17:28
-
-
Save pallinger/cdb70d73cb922baa43d2 to your computer and use it in GitHub Desktop.
diff changed config files with the default ones on a debian system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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