Zoom: Update pattern for major release number

This commit is contained in:
Jeremy Gardais 2021-10-27 14:28:52 +02:00
parent 866f928f78
commit 565304f72d
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 36 additions and 29 deletions

View File

@ -41,7 +41,7 @@ fi
# }}} # }}}
# Vars {{{ # Vars {{{
DEBUG=0 DEBUG=1
if [ $# -eq 1 ] && [ "${1}" = "repo" ] ## If repository's version should be compared if [ $# -eq 1 ] && [ "${1}" = "repo" ] ## If repository's version should be compared
then then
@ -51,8 +51,8 @@ else
fi fi
zoom_new_version=$(curl --silent 'https://zoom.us/support/download' --header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' | grep "class=\"linux-ver-text\"" | sed -e 's/.*Version \(.*\)<.*/\1/') zoom_new_version=$(curl --silent 'https://zoom.us/support/download' --header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' | grep "class=\"linux-ver-text\"" | sed -e 's/.*Version \(.*\)<.*/\1/')
zoom_new_version_major=$(echo "${zoom_new_version}" | sed -e 's/\([^\.]\+\.[^\.]\+\).*/\1/') zoom_new_version_major=$(echo "${zoom_new_version}" | sed -e 's/\(.*\) .*/\1/')
zoom_new_version_minor=$(echo "${zoom_new_version}" | sed -e 's/[^\(]\+(\(.*\)).*/\1/') zoom_new_version_minor=$(echo "${zoom_new_version}" | sed -e 's/.* (\(.*\))/\1/')
zoom_new_version_file="/tmp/.zoom.upgrade" zoom_new_version_file="/tmp/.zoom.upgrade"
@ -70,39 +70,46 @@ if [ "${zoom_current_version}" != "${zoom_new_version_major}.${zoom_new_version_
wget --quiet https://zoom.us/client/latest/zoom_amd64.deb --output-document="${zoom_new_pkg_path}" wget --quiet https://zoom.us/client/latest/zoom_amd64.deb --output-document="${zoom_new_pkg_path}"
fi fi
else # Verify downloaded package {{{
[ "${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}" "${zoom_tmp_pkg_path}"
fi
# }}}
# Verify downloaded package {{{ # Check the version from dpkg info {{{
zoom_dpkg_version=$(dpkg --info -- "${zoom_new_pkg_path}" | awk '/ Version/ { print $2 }')
# Check the version from dpkg info {{{ if [ "${zoom_dpkg_version}" = "${zoom_new_version_major}.${zoom_new_version_minor}" ]; then
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 — \ [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Check dpkg version — \
New version and .deb file informations are correct." New version and .deb file informations are correct."
## Create a temp file to monitor ## Create a temp file to monitor
touch -- "${zoom_new_version_file}" 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}" 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
exit 0 exit 0
else else
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Check dpkg version — \ [ "${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." New version and .deb file informations mismatch, don't need to go further."
### Ensure to remove the file to monitor
## Ensure to remove the file to monitor
rm --force -- "${zoom_new_version_file}" rm --force -- "${zoom_new_version_file}"
### Keep a record of the downloaded package because as a new release might come soon ## 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}" mv --force -- "${zoom_new_pkg_path}" "${zoom_tmp_pkg_path}"
## Exit
exit 0
fi
# }}}
# }}}
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}" "${zoom_tmp_pkg_path}"
## Exit
exit 0
fi fi
# }}}
# }}} # }}}
exit 255 exit 255