From 7b3c343ee7e6da6a4f4aa670bf1e45b5b32ab0a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Wed, 16 Oct 2019 16:55:42 +0200 Subject: [PATCH] Check Nextcloud's apps upgrade --- github/check.nextcloud.update | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/github/check.nextcloud.update b/github/check.nextcloud.update index 76008aa..6b23f87 100755 --- a/github/check.nextcloud.update +++ b/github/check.nextcloud.update @@ -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