aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2023-03-08 08:13:05 +0100
committerPatrick Spek <p.spek@tyil.nl>2023-03-08 08:13:05 +0100
commit0ba83d1c8aa8e7806c381916af4628305fcc64f2 (patch)
tree386e587656fd10c370e1e38c6b35f2b5d30e3e01
parente263f8606a9cbbe68595db68b4a56e34866a8d1d (diff)
Rename file_rhash to dir_hash
-rw-r--r--CHANGELOG.md2
-rw-r--r--lib/util.bash20
2 files changed, 11 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9e5c2cd..fd66446 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,7 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
GNU+Linux distributions.
- The `$BASHTARD_PLATFORM` variable now contains an additional entry, `init`, to
allow for handling different init systems on GNU+Linux in a cleaner fashion.
-- A `file_rhash` utility function has been added, which will give you a hash based
+- A `dir_hash` utility function has been added, which will give you a hash based
on the file contents of a directory. This function will find files
recursively, calculate a hash for each of them, and then calculate a hash
based on the total result. The intended goal is to allow running before and
diff --git a/lib/util.bash b/lib/util.bash
index 604e3e5..f2cd4a7 100644
--- a/lib/util.bash
+++ b/lib/util.bash
@@ -56,6 +56,16 @@ die() {
exit "${code:-1}"
}
+# 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.
+dir_hash() {
+ find "$1" -type f -exec sha1sum {} \; \
+ | sha1sum \
+ | awk '{ print $1 }'
+}
+
# Fetch a file from an URL. Using this function introduces a dependency on curl.
fetch_http() {
local OPTIND
@@ -130,16 +140,6 @@ 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