Check Nextcloud's apps upgrade

This commit is contained in:
Jeremy Gardais 2019-10-16 16:55:42 +02:00
parent 91f963774d
commit 7b3c343ee7
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 29 additions and 1 deletions

View File

@ -1,9 +1,10 @@
#!/bin/sh
# Purpose {{{
## Create a temp file (to monitor) if an upgrade is available for Nextcloud
## project on Github.
## project on Github or one of it's application.
## It based on the nextcloud's root directory to get the current version and
## supposed to be install from source (github) or at least get a VERSION file.
## For Nextcloud's apps, the `occ` command is used with sudo www-data.
## How-to use {{{
### 1. Needs releasetags script, in the same directory
### cf. https://git.ipr.univ-rennes1.fr/cellinfo/scripts/src/master/github/releasetags
@ -42,6 +43,9 @@ DEBUG=1
script_wd=$(dirname "${0}")
nc_install_dir="${1}"
nc_occ_path="${nc_install_dir}/occ"
## Nextcloud core {{{
nc_current_version=$(grep -- OC_VersionString "${nc_install_dir}"/version.php | sed "s/^\$OC.* = '\(.*\)';$/\1/" || exit 1)
nc_current_major=$(grep -- OC_VersionString "${nc_install_dir}"/version.php | sed "s/^\$OC.* = '\(.*\)';$/\1/" | cut -d"." -f1 || exit 2)
@ -50,8 +54,17 @@ nc_new_version_list="/tmp/.github.nextcloud.taglist"
#nc_new_version=$("${script_wd}"/releasetags "${nc_repo_url}" | grep -v -E -- "(^v|alpha|beta|RC)" | head -n3)
nc_new_version_file="/tmp/.github.nextcloud.upgrade"
## }}}
## Apps {{{
nc_app_upgrade=$(sudo -u www-data php --file "${nc_occ_path}" app:update --showonly)
nc_app_new_version_file="/tmp/.github.nextcloud.app.upgrade"
## }}}
# }}}
# Check Nextcloud upgrade {{{
# Get the 3 last tags releses for Nextcloud
## Exclude tag starting with "v", and those contains alpha, beta or RC
rm -f -- "${nc_new_version_list}" ; touch -- "${nc_new_version_list}"
@ -93,5 +106,20 @@ while IFS= read -r nc_new_version; do
done < "${nc_new_version_list}"
rm -f -- "${nc_new_version_list}"
# }}}
# Check apps upgrade {{{
rm -f -- "${nc_app_new_version_file}" ; touch -- "${nc_app_new_version_file}"
printf '%s' "${nc_app_upgrade}" >> "${nc_app_new_version_file}"
## If the file exists with a size bigger than 0
if [ -s "${nc_app_new_version_file}" ]; then
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Apps test — Upgrade seems to be available for apps. Please check ${nc_app_new_version_file}."
else
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Apps test — All apps seems up-to-date."
rm -f -- "${nc_app_new_version_file}"
fi
# }}}
exit 0