diff options
author | Patrick Spek <p.spek@tyil.nl> | 2022-12-04 11:27:44 +0100 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2022-12-04 11:27:44 +0100 |
commit | f4ece68ecf8cfc855e54f2d5935ed2a2b8b0c4af (patch) | |
tree | 9b043bcd1c8fc8390af14a82edebee9dfc7cc3c5 /lib/util.bash | |
parent | 3fdeadf1f19f08995d610d0dc4cf7fb2893bd8f1 (diff) | |
download | bashtard-f4ece68ecf8cfc855e54f2d5935ed2a2b8b0c4af.tar.gz bashtard-f4ece68ecf8cfc855e54f2d5935ed2a2b8b0c4af.tar.bz2 |
Add file_rhash utility
Diffstat (limited to 'lib/util.bash')
-rw-r--r-- | lib/util.bash | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/util.bash b/lib/util.bash index 6ad69e1..604e3e5 100644 --- a/lib/util.bash +++ b/lib/util.bash @@ -130,6 +130,16 @@ join_args() { printf "%s" "$*" } +# Recursively hash files in a directory, and hashing the output of all those +# hashes again. This results in a single hash representing the state of files +# in a directory. It can be used to check whether contents changed after +# templating files in a given directory. +file_rhash() { + find "$1" -type f -exec sha1sum {} \; \ + | sha1sum \ + | awk '{ print $1 }' +} + file_template() { local file="$BASHTARD_ETCDIR/playbooks.d/$BASHTARD_PLAYBOOK/share/$1" ; shift |