Download|rm .deb file for rocketchat if necessary

This commit is contained in:
Jeremy Gardais 2021-06-11 15:41:29 +02:00
parent b9a950c091
commit 4e18f0d46d
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 10 additions and 1 deletions

View File

@ -58,6 +58,8 @@ fi
rkt_new_version=$("${script_wd}"/releasetags "${rkt_repo_url}" | head -n1 | sed 's/v//g')
rkt_new_version_file="/tmp/.github.rocketchat-electron.upgrade"
rkt_new_pkg_url="https://github.com/RocketChat/Rocket.Chat.Electron/releases/download/${rkt_new_version}/rocketchat_${rkt_new_version}_amd64.deb"
rkt_new_pkg_path="/tmp/rocketchat_${rkt_new_version}_amd64.deb"
# }}}
# Check if the current version is the last one {{{
@ -68,9 +70,16 @@ if [ "${rkt_current_version}" != "${rkt_new_version}" ]; then
touch -- "${rkt_new_version_file}"
printf '\e[1;35m%-6s\e[m\n' "An upgrade is available for Rocket.Chat client Electron (current: ${rkt_current_version}): ${rkt_new_version}." >> "${rkt_new_version_file}"
## If it doesn't already exists, download this new package
if [ ! -f "${rkt_new_pkg_path}" ]; then
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Download .deb file from Rocket.Chat.Electron repository on Github to ${rkt_new_pkg_path} ."
wget --quiet "${rkt_new_pkg_url}" --output-document="${rkt_new_pkg_path}"
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}"
## Ensure to remove any temp file and useless .deb file
rm -f -- "${rkt_new_version_file}" "${rkt_new_pkg_path}"
fi
# }}}