Script to verify Ceph version
This commit is contained in:
parent
fd63db37d2
commit
10aed6c7f1
|
@ -0,0 +1,70 @@
|
|||
#!/bin/sh
|
||||
# Purpose {{{
|
||||
## Create a temp file (to monitor) if an upgrade is available for Ceph
|
||||
## project on Github.
|
||||
## It's based on .deb package (or repository) 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.ceph.update
|
||||
### 3. Monitor the temp file : /tmp/.github.ceph.upgrade
|
||||
# Or enable MAILTO in cronjob and edit the script to print a message.
|
||||
# Or send a mail.
|
||||
# …
|
||||
## }}}
|
||||
# }}}
|
||||
|
||||
# Don't expect any argument {{{
|
||||
if [ $# -gt 0 ]
|
||||
then
|
||||
cat << HELP
|
||||
|
||||
check.ceph.update --
|
||||
Compare current version of an installed Ceph and the last available (filtered according to current major version).
|
||||
|
||||
EXAMPLE :
|
||||
- Compare the current version installed from .deb file or repository
|
||||
check.ceph.update
|
||||
HELP
|
||||
|
||||
exit 1
|
||||
fi
|
||||
# }}}
|
||||
|
||||
# Vars {{{
|
||||
DEBUG=1
|
||||
|
||||
script_wd=$(dirname "${0}")
|
||||
|
||||
ceph_repo_url="https://github.com/ceph/ceph"
|
||||
|
||||
ceph_current_version=$(dpkg -l ceph | awk '/^ii.*ceph/ { print $3}' | sed 's/\(.*\)-.*/\1/')
|
||||
ceph_current_major_version=$(printf -- '%s' "${ceph_current_version}" | cut -d"." -f1)
|
||||
|
||||
## Filter new versions to get only same major releases
|
||||
ceph_new_version=$("${script_wd}"/releasetags "${ceph_repo_url}" | \
|
||||
grep "v${ceph_current_major_version}" | \
|
||||
head -n1 | \
|
||||
sed 's/v//g')
|
||||
|
||||
ceph_new_version_file="/tmp/.github.ceph.upgrade"
|
||||
# }}}
|
||||
|
||||
# Check if the current version is the last one {{{
|
||||
if [ "${ceph_current_version}" != "${ceph_new_version}" ]; then
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Test version — Current version (${ceph_current_version}) and new one (${ceph_new_version}) seems to be different."
|
||||
|
||||
## Create a temp file to monitor
|
||||
touch -- "${ceph_new_version_file}"
|
||||
printf '\e[1;35m%-6s\e[m\n' "An upgrade is available for Ceph (current : ${ceph_current_version}) : ${ceph_new_version}." >> "${ceph_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 -- "${ceph_new_version_file}"
|
||||
fi
|
||||
# }}}
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue