From b3e62562c0c0d0d0cd531a21e5c06c4cd8309995 Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Mon, 15 Aug 2016 03:21:24 -0500 Subject: [PATCH] Add debugging options --- fetch | 12 ++++++++++++ lib/kvs.sh | 7 +++++++ lib/taggery.sh | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/fetch b/fetch index e10686d..47cd949 100755 --- a/fetch +++ b/fetch @@ -65,6 +65,18 @@ image_tags() { taggery_image_tags "${@}"; } id="$(url_id "${url}")" file="$(image_url "${id}")" tags="$(image_tags "${id}")" +[ "${file}" ] || name="${hash}" +extn="${name#*.}" + +[ "${DEBUG}" ] && { + echo "id: ${id}" + echo "file: ${file}" + echo "tags: ${tags}" + echo "name: ${name}" + echo "" + kvs_get_all "${taggery_name}/${id}" + kill -KILL $$ +} [ "${file}" -o "${hash}" ] || { echo "No download URL (deleted?) and -f not provided" >&2; kill -ABRT $$; exit 1; } [ "${tags}" ] || { echo "No tags found" >&2; kill -ABRT $$; exit 1; } diff --git a/lib/kvs.sh b/lib/kvs.sh index 2a08225..f4cd8cd 100644 --- a/lib/kvs.sh +++ b/lib/kvs.sh @@ -33,6 +33,13 @@ kvs_get() { grep "^${id}${t}${var}${t}" "${kvs}" | tail -n 1 | cut -d"${t}" -f3- } +# Fetch all values stored for a given id +kvs_get_all() { + [ "${1}" ] || return 255 + local id="${1}" + grep "^${id}${t}" "${kvs}" +} + # Does the kvs have any entries for a given ID? kvs_has_id() { [ "${1}" ] || return 255 diff --git a/lib/taggery.sh b/lib/taggery.sh index 30aee81..16f5c23 100644 --- a/lib/taggery.sh +++ b/lib/taggery.sh @@ -49,7 +49,7 @@ taggery_cleanup() { fi kvs_unset "${taggery_name}" cleanup } -trap "taggery_cleanup" EXIT HUP INT TERM KILL +[ "${DEBUG}" ] || trap "taggery_cleanup" EXIT HUP INT TERM KILL taggery_register_cleanup() { [ "${1}" ] || return 1 -- 2.42.0