etc snapshots with git

You can track your /etc directory with git, and have apt update it automatically each time a package is installed.

install git

apt-get install git-core

initialize /etc to be a git repo

cd /etc
git init-db
chmod og-rwx .git

commit the current state

git add .
git commit -a -m"initial import"

install a snapshot script for apt to call
cat apt/git-snapshot-script

#!/bin/bash
set -e
caller=$(ps axww | grep "^ *$$" -B3 | grep " apt-get " | head -n1 | sed 's/^.*\(apt-get .*\)/\1/' )
/usr/bin/git add .
/usr/bin/git commit -a -m"snapshot after: $caller"

make it executable

chmod +x apt/git-snapshot-script

configure apt to track changes
cat apt/apt.conf


DPkg {
          Post-Invoke {"cd /etc ; ./apt/git-snapshot-script";};
}

track these two files

git add .
git commit -a -m"apt will track /etc automagically using git"

… and you’re done.




coded by nessus