From b870b6e43a0b83c2a3a192cff6846b9248e23e1c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 25 Feb 2018 09:51:51 +0100 Subject: [PATCH] bugfix: __consul fails if consul is already running #633 --- cdist/conf/type/__consul/gencode-remote | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__consul/gencode-remote b/cdist/conf/type/__consul/gencode-remote index 4426ea2b..22e9eea1 100755 --- a/cdist/conf/type/__consul/gencode-remote +++ b/cdist/conf/type/__consul/gencode-remote @@ -44,15 +44,17 @@ cksum_should=$(cat "$version_dir/cksum" | cut -d' ' -f1,2) cat << eof tmpdir=\$(mktemp -d --tmpdir="/tmp" "${__type##*/}.XXXXXXXXXX") curl -s -L "$source" > "\$tmpdir/$source_file_name" - unzip -p "\$tmpdir/$source_file_name" > "$destination" + unzip -p "\$tmpdir/$source_file_name" > "${destination}.tmp" rm -rf "\$tmpdir" - cksum_is=\$(cksum "$destination" | cut -d' ' -f1,2) + cksum_is=\$(cksum "${destination}.tmp" | cut -d' ' -f1,2) if [ "\$cksum_is" = "$cksum_should" ]; then + rm -f "${destination}" + mv "${destination}.tmp" "${destination}" chown root:root "$destination" chmod 755 "$destination" else - rm -f "$destination" + rm -f "${destination}.tmp" echo "Failed to verify checksum for $__object_name" >&2 exit 1 fi