diff options
author | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2017-07-22 12:26:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2017-07-22 22:28:26 +0000 |
commit | 3cce7eac1e56e30761b46aa383d1eb8582f6a5fb (patch) | |
tree | f8ca289ce6cc6bbd1cc828eab86a59d980f38e7e /share/scripts | |
parent | Adding knot-resolver to dschinn-backports preseed example. (diff) | |
download | compute-tools-3cce7eac1e56e30761b46aa383d1eb8582f6a5fb.tar.xz compute-tools-3cce7eac1e56e30761b46aa383d1eb8582f6a5fb.zip |
Making sha512 checksum optional for image downloads in curl container create script.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to 'share/scripts')
-rwxr-xr-x | share/scripts/curl | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/share/scripts/curl b/share/scripts/curl index f7419e9..3d81807 100755 --- a/share/scripts/curl +++ b/share/scripts/curl @@ -172,32 +172,39 @@ then CURL_OPTIONS="${CURL_OPTIONS} --http2" fi -curl --fail --location --progress-bar --user-agent container-tools/${VERSION} ${CURL_OPTIONS} \ - "${SERVER}/${IMAGE}" -o "${CACHE}/${IMAGE}" +for FILE in "${SERVER}/${IMAGE}" "${SERVER}/${IMAGE}.sha512" +do + if curl --fail --head --output /dev/null --silent "${FILE}" + then + curl --fail --location --progress-bar --user-agent container-tools/${VERSION} ${CURL_OPTIONS} \ + "${FILE}" -o "${CACHE}/$(basename ${FILE})" + fi +done -curl --fail --location --progress-bar --user-agent container-tools/${VERSION} ${CURL_OPTIONS} \ - "${SERVER}/${IMAGE}.sha512" -o "${CACHE}/${IMAGE}.sha512" +if [ -e "${CACHE}/${IMAGE}.sha512" ] && [ -e "${CACHE}/${IMAGE}" ] +then + echo -n "Verifying ${IMAGE}.sha512" -echo -n "Verifying ${IMAGE}.sha512" -cd "${CACHE}" -set +e + cd "${CACHE}" + set +e -sha512sum --check "${IMAGE}.sha512" --status -SHA512SUM="${?}" + sha512sum --check "${IMAGE}.sha512" --status + SHA512SUM="${?}" -case "${SHA512SUM}" in - 0) - echo " ok." - ;; + case "${SHA512SUM}" in + 0) + echo " ok." + ;; - *) - echo " failed." - exit 1 - ;; -esac + *) + echo " failed." + exit 1 + ;; + esac -set -e -cd "${OLDPWD}" + set -e + cd "${OLDPWD}" +fi echo "Unpacking ${IMAGE}" mkdir -p "${MACHINES}/${NAME}" |