71 lines
2.3 KiB
Plaintext
71 lines
2.3 KiB
Plaintext
|
#!/bin/sh
|
|||
|
# Purpose {{{
|
|||
|
## Create a 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.101010.fr/gardouille-dotfiles/scripts/src/branch/master/github/releasetags
|
|||
|
# wget https://git.101010.fr/gardouille-dotfiles/scripts/raw/branch/master/github/releasetags
|
|||
|
### 2. Create a cron job, eg :
|
|||
|
#00 20 * * * root /opt/repos/gardouille.scripts/github/check_ceph_update
|
|||
|
### 3. Monitor the file : /srv/.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="/srv/.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 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
|