Script to check if installed Searx is uptodate
This commit is contained in:
parent
b640945618
commit
99062b251c
|
@ -0,0 +1,67 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Purpose {{{
|
||||||
|
## Create a temp file (to monitor) if an upgrade is available for Searx
|
||||||
|
## project on Github.
|
||||||
|
## It based on the searx's root directory to get the current version and
|
||||||
|
## supposed to be install from source (github).
|
||||||
|
## 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 with Searx directory as first argument, eg.
|
||||||
|
#00 20 * * * root /opt/repos/ipr.scripts/github/check.searx.update /var/www/searx
|
||||||
|
### 3. Monitor the temp file : /tmp/.github.searx.upgrade
|
||||||
|
# Or enable MAILTO in cronjob and edit the script to print a message.
|
||||||
|
# Or send a mail.
|
||||||
|
# …
|
||||||
|
## }}}
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# Expect 1 argument {{{
|
||||||
|
if [ $# -ne 1 ]
|
||||||
|
then
|
||||||
|
cat << HELP
|
||||||
|
|
||||||
|
check.searx.update --
|
||||||
|
Compare current version of an installed Searx and the last available.
|
||||||
|
|
||||||
|
EXAMPLE :
|
||||||
|
- Compare the current version installed in /var/www/searx.domain.tld
|
||||||
|
check.searx.update /var/www/searx.domain.tld
|
||||||
|
|
||||||
|
HELP
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# Vars {{{
|
||||||
|
DEBUG=1
|
||||||
|
|
||||||
|
script_wd=$(dirname "${0}")
|
||||||
|
|
||||||
|
searx_install_dir="${1}"
|
||||||
|
searx_current_version=$(cd "${searx_install_dir}" || exit 1 ; git describe --match "v[0-9]*\.[0-9]*\.[0-9]*" HEAD 2>/dev/null | awk -F'-' '{ print $1 }' ; cd - > /dev/null || exit 1)
|
||||||
|
|
||||||
|
searx_repo_url="https://github.com/asciimoo/searx"
|
||||||
|
searx_new_version=$("${script_wd}"/releasetags "${searx_repo_url}" | head -n1)
|
||||||
|
|
||||||
|
searx_new_version_file="/tmp/.github.searx.upgrade"
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# Check if the current version is the last one {{{
|
||||||
|
if [ "${searx_current_version}" != "${searx_new_version}" ]; then
|
||||||
|
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Test version — Current version (${searx_current_version}) and new one (${searx_new_version}) seems to be different."
|
||||||
|
|
||||||
|
## Create a temp file to monitor
|
||||||
|
touch -- "${searx_new_version_file}"
|
||||||
|
printf '\e[1;35m%-6s\e[m\n' "An upgrade is available for Searx : ${searx_new_version}." >> "${searx_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 -- "${searx_new_version_file}"
|
||||||
|
fi
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue