From 413d20267af41c2500337bcf82ce125c7cfcdd8b Mon Sep 17 00:00:00 2001 From: Weezer Su Date: Fri, 27 Jan 2017 15:26:25 -0600 Subject: [PATCH] Add the md5 check on image Add the md5 image hash check, if the image exists, check the md5 hash, if the hash is not the same, remove the old image and download new one. Change-Id: I2232129a814e89aaac9bf54ee16ede983fff5b48 --- multi-node-aio/setup-cobbler.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/multi-node-aio/setup-cobbler.sh b/multi-node-aio/setup-cobbler.sh index 429c99bf..e60d5af6 100755 --- a/multi-node-aio/setup-cobbler.sh +++ b/multi-node-aio/setup-cobbler.sh @@ -94,13 +94,22 @@ update-rc.d cobblerd defaults # Update Cobbler Signatures cobbler signature update -# Get ubuntu server image +# Get ubuntu server image md5 hash file +wget -O /tmp/MD5SUM5 /tmp/MD5SUM5 http://releases.ubuntu.com/"${DEFAULT_IMAGE:0:5}"/MD5SUMS + +# Get ubuntu server image, if the server image exists, compare the md5, rm and download new image if the hash is not +# the same. mkdir_check "/var/cache/iso" pushd /var/cache/iso if [ -f "/var/cache/iso/ubuntu-"${DEFAULT_IMAGE}"-server-amd64.iso" ]; then - rm /var/cache/iso/ubuntu-"${DEFAULT_IMAGE}"-server-amd64.iso + md5=`md5sum ubuntu-"${DEFAULT_IMAGE}"-server-amd64.iso | awk '{ print $1 }'` + if ! grep ${md5} /tmp/MD5SUMS &>/dev/null ; then + rm /var/cache/iso/ubuntu-"${DEFAULT_IMAGE}"-server-amd64.iso + wget http://releases.ubuntu.com/"${DEFAULT_IMAGE:0:5}"/ubuntu-"${DEFAULT_IMAGE}"-server-amd64.iso + fi + else + wget http://releases.ubuntu.com/"${DEFAULT_IMAGE:0:5}"/ubuntu-"${DEFAULT_IMAGE}"-server-amd64.iso fi - wget http://releases.ubuntu.com/"${DEFAULT_IMAGE:0:5}"/ubuntu-"${DEFAULT_IMAGE}"-server-amd64.iso popd # import cobbler image