Compare the ID of Docker images instead of tags
This commit is contained in:
parent
6ecb6df66e
commit
85878043ea
|
@ -26,9 +26,11 @@ rkt_repo_name="rocketchat"
|
|||
rkt_image_name="rocket.chat"
|
||||
|
||||
rkt_current_version=$(docker container ls | grep -- "${rkt_repo_name}/${rkt_image_name}" | sed -- "s/.*${rkt_repo_name}\/${rkt_image_name}:\([^ ]*\) .*/\1/")
|
||||
rkt_current_imageid=$(docker image inspect "${rkt_repo_name}/${rkt_image_name}:${rkt_current_version}" | grep -m 1 -- "Image.*sha256" | sed "s/.*Image.*sha256:\(.*\)\",/\1/")
|
||||
|
||||
rkt_grep_pattern="[[:digit:]]\\.\\+[[:digit:]]*\\.\\?[[:digit:]]*$"
|
||||
rkt_new_version=$("${script_wd}"/imagetags "${rkt_repo_name}/${rkt_image_name}" "${rkt_grep_pattern}" | tail -n1)
|
||||
rkt_new_imageid=$(docker image inspect "${rkt_repo_name}/${rkt_image_name}:${rkt_new_version}" | grep -m 1 -- "Image.*sha256" | sed "s/.*Image.*sha256:\(.*\)\",/\1/")
|
||||
|
||||
rkt_new_version_file="/tmp/.docker.rocket.chat.upgrade"
|
||||
# }}}
|
||||
|
@ -45,11 +47,25 @@ fi
|
|||
|
||||
# Check if the current version is the last one {{{
|
||||
if [ "${rkt_current_version}" != "${rkt_new_version}" ]; then
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Test version — An upgrade is available for ${rkt_image_name}: ${rkt_new_version}."
|
||||
# Create a temp file to monitor
|
||||
touch -- "${rkt_new_version_file}"
|
||||
printf '\e[1;35m%-6s\e[m\n' "An upgrade is available for ${rkt_image_name}: ${rkt_new_version}." >> "${rkt_new_version_file}"
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Test version — Current version (${rkt_current_version}) and new one (${rkt_new_version}) of ${rkt_image_name} seems to be different."
|
||||
# Ensure to download this new version of the image
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Test version — Download ${rkt_repo_name}/${rkt_image_name}:${rkt_new_version} image to compare ImageID."
|
||||
docker pull "${rkt_repo_name}/${rkt_image_name}:${rkt_new_version}" > /dev/null
|
||||
|
||||
## Compare the ImageID of current and new version {{{
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ImageID — ID of the current version is ${rkt_current_imageid}."
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ImageID — ID of the new version is ${rkt_new_imageid}."
|
||||
if [ "${rkt_current_imageid}" != "${rkt_new_imageid}" ]; then
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ImageID — An upgrade is available for ${rkt_image_name}: ${rkt_new_version}."
|
||||
## Create a temp file to monitor
|
||||
touch -- "${rkt_new_version_file}"
|
||||
printf '\e[1;35m%-6s\e[m\n' "An upgrade is available for ${rkt_image_name}: ${rkt_new_version}." >> "${rkt_new_version_file}"
|
||||
else
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ImageID — The current version is up-to-date."
|
||||
rm -f -- "${rkt_new_version_file}"
|
||||
fi
|
||||
## }}}
|
||||
|
||||
else
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Test version — The current version is up-to-date."
|
||||
rm -f -- "${rkt_new_version_file}"
|
||||
|
|
Loading…
Reference in New Issue