Script to verify Zoom version
This commit is contained in:
parent
350cb2941f
commit
8f2df93b83
|
@ -0,0 +1,74 @@
|
|||
#!/bin/sh
|
||||
# Purpose {{{
|
||||
## Create a temp file (to monitor) if an upgrade is available for Zoom client
|
||||
## from official website − https://zoom.us/download
|
||||
## It's based on .deb package installation to check the current version.
|
||||
## It can also compare the current available version in APT repositories
|
||||
## if "repo" is given as first argument.
|
||||
## How-to use {{{
|
||||
### 1. Create a cron job, eg :
|
||||
#00 20 * * * root /opt/repos/ipr.scripts/app/check.zoom.update
|
||||
### 2-1 Create a cron job to compare the version available in an APT repository :
|
||||
#00 20 * * * root /opt/repos/ipr.scripts/app/check.zoom.update repo
|
||||
### 2. Monitor the temp file : /tmp/.zoom.upgrade
|
||||
# Or enable MAILTO in cronjob and edit the script to print a message.
|
||||
# Or send a mail.
|
||||
# …
|
||||
## }}}
|
||||
|
||||
## Inspired by https://github.com/pazepaze/zoom-autoupdater/blob/master/autoupdate-zoom.sh
|
||||
# }}}
|
||||
|
||||
# Expect maximum 1 argument {{{
|
||||
if [ $# -gt 1 ]
|
||||
then
|
||||
cat << HELP
|
||||
|
||||
check.zoom.update --
|
||||
Compare current version of an installed Zoom client and the last available.
|
||||
|
||||
EXAMPLE :
|
||||
- Compare the current version installed from .deb file
|
||||
check.zoom.update
|
||||
|
||||
- Compare the current version from apt's repository
|
||||
check.zoom.update repo
|
||||
|
||||
HELP
|
||||
|
||||
exit 1
|
||||
fi
|
||||
# }}}
|
||||
|
||||
# Vars {{{
|
||||
DEBUG=1
|
||||
|
||||
if [ $# -eq 1 ] && [ "${1}" = "repo" ] ## If repository's version should be compared
|
||||
then
|
||||
zoom_current_version=$(apt-cache policy -- zoom | awk '/Candidate:/ {print $2}' | sed 's/.:\(.*\)-.*/\1/')
|
||||
else
|
||||
zoom_current_version=$(dpkg --list -- zoom | awk '/^ii *zoom/ {print $3}' | sed 's/.:\(.*\)-.*/\1/')
|
||||
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_major=$(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"
|
||||
# }}}
|
||||
|
||||
# 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}." >> "${zoom_new_version_file}"
|
||||
|
||||
else
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Test version — The current version is up-to-date."
|
||||
rm -f -- "${zoom_new_version_file}"
|
||||
fi
|
||||
# }}}
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue