From 6ecb7419becf7cb2887b866d019020e76d327aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 19 Aug 2019 15:55:10 +0200 Subject: [PATCH] Also compare version in Debian's repo --- github/check.fusioninventory-agent.update | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/github/check.fusioninventory-agent.update b/github/check.fusioninventory-agent.update index c868c30..b437736 100755 --- a/github/check.fusioninventory-agent.update +++ b/github/check.fusioninventory-agent.update @@ -3,12 +3,16 @@ ## Create a temp file (to monitor) if an upgrade is available for FusionInventory-Agent ## project on Github. ## It's based on .deb package installation to check the current version. +## It can also compare the current available version in a debian repository +## if "repo" is given as first argument. ## How-to use {{{ ### 1. Needs releasetags script, in the same directory ### cf. https://git.ipr.univ-rennes1.fr/cellinfo/scripts/src/master/github/releasetags # wget https://git.ipr.univ-rennes1.fr/cellinfo/scripts/raw/master/github/releasetags ### 2. Create a cron job, eg : #00 20 * * * root /opt/repos/ipr.scripts/github/check.fusioninventory-agent.update +### 2-1 Create a cron job to compare the version available in a Debian repository : +#00 20 * * * root /opt/repos/ipr.scripts/github/check.fusioninventory-agent.update repo ### 3. Monitor the temp file : /tmp/.github.fusioninventory-agent.upgrade # Or enable MAILTO in cronjob and edit the script to print a message. # Or send a mail. @@ -16,8 +20,8 @@ ## }}} # }}} -# Expect no argument {{{ -if [ $# -gt 0 ] +# Expect maximum 1 argument {{{ +if [ $# -gt 1 ] then cat << HELP @@ -28,6 +32,9 @@ EXAMPLE : - Compare the current version installed from .deb file check.fusioninventory-agent.update + - Compare the current version in Debian's repository + check.fusioninventory-agent.update repo + HELP exit 1 @@ -41,7 +48,12 @@ script_wd=$(dirname "${0}") fi_repo_url="https://github.com/fusioninventory/fusioninventory-agent" -fi_current_version=$(dpkg -l fusioninventory-agent | awk '/^ii.*fusioninventory-agent/ {print $3}' | sed 's/.:\(.*\)-.*/\1/') +if [ $# -eq 1 ] && [ "${1}" = "repo" ] ## If repository's version should be compared +then + fi_current_version=$(apt-cache policy fusioninventory-agent | awk '/Candidate:/ {print $2}' | sed 's/.:\(.*\)-.*/\1/') +else + fi_current_version=$(dpkg -l fusioninventory-agent | awk '/^ii.*fusioninventory-agent/ {print $3}' | sed 's/.:\(.*\)-.*/\1/') +fi fi_new_version=$("${script_wd}"/releasetags "${fi_repo_url}" | head -n1 | sed 's/v//g')