Log hwinfo output with etckeeper

I like etckeeper. It does store the etc/ directory in a git repository.

This way I have a nice history of what changed.

Of course we have backups, but this is convenient.

I would like to store additional data like the output of hwinfo --all.

The tool etckeeper seems to have a plugin “framework” via “.d” directories.

But I could not get it working.

How to store the output of hwinfo in a way, that etckeeper adds it to the git repo?

Answer

What about creating pre-commit hook for this:

You will create for example file /etc/etckeeper/pre-commit.d/40hwinfo with this code in it:

#!/bin/sh
set -e

hwinfo --all > /etc/hwinfo.txt
git add /etc/hwinfo.txt

then run:

$ chmod +x /etc/etckeeper/pre-commit.d/40hwinfo 

and commit changes:

etckeeper commit

This will take little bit longer (because of time needed to complete the hwinfo command), but then you will see, you have your hwinfo output inside /etc/hwinfo.txt file and it will be tracked by git as well.

Attribution
Source : Link , Question Author : guettli , Answer Author : patok

Leave a Comment