Compare current Fusioninventory and last update
This commit is contained in:
parent
d0311a61b8
commit
fa6fe80e27
|
@ -0,0 +1,65 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Purpose {{{
|
||||||
|
## 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.
|
||||||
|
## 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
|
||||||
|
### 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.
|
||||||
|
# …
|
||||||
|
## }}}
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# Expect no argument {{{
|
||||||
|
if [ $# -gt 0 ]
|
||||||
|
then
|
||||||
|
cat << HELP
|
||||||
|
|
||||||
|
check.fusioninventory-agent.update --
|
||||||
|
Compare current version of an installed FusionInventory-Agent and the last available.
|
||||||
|
|
||||||
|
EXAMPLE :
|
||||||
|
- Compare the current version installed from .deb file
|
||||||
|
check.fusioninventory-agent.update
|
||||||
|
|
||||||
|
HELP
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# Vars {{{
|
||||||
|
DEBUG=1
|
||||||
|
|
||||||
|
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/')
|
||||||
|
|
||||||
|
fi_new_version=$("${script_wd}"/releasetags "${fi_repo_url}" | head -n1 | sed 's/v//g')
|
||||||
|
|
||||||
|
fi_new_version_file="/tmp/.github.fusioninventory-agent.upgrade"
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# Check if the current version is the last one {{{
|
||||||
|
if [ "${fi_current_version}" != "${fi_new_version}" ]; then
|
||||||
|
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Test version — Current version (${fi_current_version}) and new one (${fi_new_version}) seems to be different."
|
||||||
|
|
||||||
|
## Create a temp file to monitor
|
||||||
|
touch -- "${fi_new_version_file}"
|
||||||
|
printf '\e[1;35m%-6s\e[m\n' "An upgrade is available for FusionInventory-Agent : ${fi_new_version}." >> "${fi_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 -- "${fi_new_version_file}"
|
||||||
|
fi
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue