1

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?

guettli
  • 3,113
  • 14
  • 59
  • 110

1 Answers1

1

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.

patok
  • 693
  • 1
  • 5
  • 14
  • AFAIK the pre-commit hook will only run, if there are changes in the /etc directory. This means the @daily cron-job will do nothing, except there are by change changes in /etc. – guettli Mar 19 '18 at 12:06
  • regarding to what I see in the file /etc/etckeeper/daily, there is nothing that should prevent running hooks (at least on my Debian Stretch); but still you can do this without a hook, only with Cron, when you send output of `hwinfo --all` to file and then you'll call `git add /etc/hwinfo.txt` and also `etckeeper commit -m "...something..."` in this cron job. – patok Mar 19 '18 at 12:33
  • You said "there is nothing that should prevent running hooks". I think the hook `40hwinfo` won't get executed if the etc directory is clean. – guettli Mar 20 '18 at 09:51
  • The probmel is in `/etc/etckeeper/daily` which gets executed by `/etc/cron.daily/etckeeper`. It only does commit if the repo is unclean. – guettli Mar 20 '18 at 11:12
  • Yes, your answer works. BUT: I need to activate this "AVOID_DAILY_AUTOCOMMITS=1" and create an own daily-cronjob with just does "etckeeper commit daily". The upstream cronjob does a lot of if-ing and else-ing and checking if clean or not ... Conditionless as goal seems to be new to the upstream author. – guettli Mar 20 '18 at 11:15