After installation and various custom configurations, is it possible to use eg. apt and some shell-fu to produce a diff for every file in /etc/ that differs from the standard configuration? This would provide a means to generate a short summary of the configuration state after the fact, rather than having to rely on manual logging along the way, should one desire to remember what was changed at a later time.
2 Answers
You should take a look to etckeeper :
etckeeper is a collection of tools to let /etc be stored in a git, mercurial, darcs, or bzr repository. It hooks into apt (and other package managers including yum and pacman-g2) to automatically commit changes made to /etc during package upgrades. It tracks file metadata that revison control systems do not normally support, but that is important for /etc, such as the permissions of /etc/shadow. It's quite modular and configurable, while also being simple to use if you understand the basics of working with revision control.

- 2,797
I'm in the middle of developing a solution to the same kind of problem.
Basically, my objective is a system allowing undo and redo with file-level granularity.
Starting with your question and working backwards...
- In order to compare to the default configuration, we have to store the originals of all those files somewhere first. Then we can produce what you want with something like...
DIFFDIR= ......
ARCDIR=./.archives # see below
function getlastarchive() {
... code to return last archived version ...
}
for FILE in /etc/*
do
ARCFILE="$(getlastarchive $FILE)"
diff $ARCDIR/$ARCFILE /etc/$FILE >$DIFFDIR/$FILE.diff
done
- To store the originals, I've chosen to adopt the convention of having a single
.archives
subdirectory in any directory with an altered file. It's created as necessary by afile-archive
script. - If you only want one level of undo, you only need copy the unaltered file to the
.archives
directory before it is changed. - For unlimited-undo, we need a versioning scheme. An obvious choice is a datetime stamp appended to the name of the archived version. Something like...
Files: /etc/hosts
/etc/resolv.conf
Archived Versions: /etc/.archives/hosts.20121219015459
/etc/.archives/resolv.conf.20121219015459
- Instead, I'm using just an auto-calculated incremental version#, as in...
Files: /etc/hosts
/etc/resolv.conf
Archived Versions: /etc/.archives/hosts.00
/etc/.archives/resolv.00.conf
- The version# is before the extension since I also use this for edited versions of images which need their extensions (.jpg, .png, etc) intact in order to be detected properly by a lot of software. If a file has no extension, the version# is just appended to the end. The code to do this is more complex, but runs instantly so no problem. A case can be made for a number of other schemes but this works for me.
Hope this helps!

- 680