Zoom: Check version with dpkg info

This commit is contained in:
Jeremy Gardais 2021-08-23 19:02:42 +02:00
parent 390e965ac0
commit 66ebcf6947
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
2 changed files with 32 additions and 8 deletions

View File

@ -41,7 +41,7 @@ fi
# }}}
# Vars {{{
DEBUG=1
DEBUG=0
if [ $# -eq 1 ] && [ "${1}" = "repo" ] ## If repository's version should be compared
then
@ -57,16 +57,13 @@ zoom_new_version_minor=$(echo "${zoom_new_version}" | sed -e 's/[^\(]\+(\(.*\)).
zoom_new_version_file="/tmp/.zoom.upgrade"
zoom_new_pkg_path="/tmp/zoom_${zoom_new_version_major}.${zoom_new_version_minor}_amd64.deb"
zoom_tmp_pkg_path="/tmp/.zoom_${zoom_new_version_major}.${zoom_new_version_minor}_amd64.deb"
# }}}
# Check if the current version is the last one {{{
if [ "${zoom_current_version}" != "${zoom_new_version_major}.${zoom_new_version_minor}" ]; then
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Test version — Current version (${zoom_current_version}) and new one (${zoom_new_version_major}.${zoom_new_version_minor}) seems to be different."
## Create a temp file to monitor
touch -- "${zoom_new_version_file}"
printf '\e[1;35m%-6s\e[m\n' "An upgrade is available for Zoom client (current: ${zoom_current_version}): ${zoom_new_version_major}.${zoom_new_version_minor}." >> "${zoom_new_version_file}"
## If it doesn't already exists, download this new package
if [ ! -f "${zoom_new_pkg_path}" ]; then
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Download .deb file from zoom.us to ${zoom_new_pkg_path} ."
@ -76,8 +73,36 @@ if [ "${zoom_current_version}" != "${zoom_new_version_major}.${zoom_new_version_
else
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Test version — The current version is up-to-date."
## Ensure to remove any temp file and useless .deb file
rm --force -- "${zoom_new_version_file}" "${zoom_new_pkg_path}"
rm --force -- "${zoom_new_version_file}" "${zoom_new_pkg_path}" "${zoom_tmp_pkg_path}"
fi
# }}}
exit 0
# Verify downloaded package {{{
# Check the version from dpkg info {{{
zoom_dpkg_version=$(dpkg --info -- "${zoom_new_pkg_path}" | awk '/ Version/ { print $2 }')
if [ "${zoom_dpkg_version}" = "${zoom_new_version_major}.${zoom_new_version_minor}" ]; then
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Check dpkg version — \
New version and .deb file informations are correct."
## Create a temp file to monitor
touch -- "${zoom_new_version_file}"
printf '\e[1;35m%-6s\e[m\n' "An upgrade is available for Zoom client (current: ${zoom_current_version}): ${zoom_new_version_major}.${zoom_new_version_minor}." >> "${zoom_new_version_file}"
### Exit
exit 0
else
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Check dpkg version — \
New version and .deb file informations mismatch, don't need to go further."
### Ensure to remove the file to monitor
rm --force -- "${zoom_new_version_file}"
### Keep a record of the downloaded package because as a new release might come soon
mv --force -- "${zoom_new_pkg_path}" "${zoom_tmp_pkg_path}"
fi
# }}}
# }}}
exit 255

View File

@ -110,5 +110,4 @@ fi
# }}}
exit 255