2020-06-29 18:56:08 +02:00
|
|
|
#! /bin/bash
|
|
|
|
#
|
2020-06-30 11:27:12 +02:00
|
|
|
# Copyright (C) 2020 Laurent Poujoulat <lpoujoulat@april.org>
|
2020-06-29 18:56:08 +02:00
|
|
|
#
|
|
|
|
# This file is part of valise.chapril.org
|
|
|
|
#
|
|
|
|
# This script is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
# ================================================
|
|
|
|
# This checks for updates of nextcloud components.
|
|
|
|
# If any update is present, they are listed in human readable form on stdout, and 1 is returned,
|
|
|
|
# and if everything is OK, tell it on stdout "OK", and returns 0.
|
|
|
|
# ================================================
|
|
|
|
|
|
|
|
# Configuration data
|
2020-06-30 12:01:03 +02:00
|
|
|
NEXTCLOUD_ROOT="/var/www/valise.chapril.org"
|
2020-06-29 18:56:08 +02:00
|
|
|
|
|
|
|
# Returns script usage
|
|
|
|
function usage()
|
|
|
|
{
|
|
|
|
echo "Usage: $(basename $0)"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Main entry point
|
2020-06-30 12:06:23 +02:00
|
|
|
|
|
|
|
# By default, we assume to fail
|
2020-06-29 18:56:08 +02:00
|
|
|
EXIT_RESULT=1
|
|
|
|
|
2020-06-30 12:01:03 +02:00
|
|
|
# Usage check
|
2020-06-29 18:56:08 +02:00
|
|
|
if [ "$#" -ne 0 ]
|
|
|
|
then
|
|
|
|
usage
|
|
|
|
else
|
|
|
|
|
2020-06-30 12:01:03 +02:00
|
|
|
# Currently, nor the serverinfo API, nor the occ command has a clean way of checking both the core and apps update status
|
|
|
|
# So we trick this by calling the occ update:check command and processing the output
|
|
|
|
cd ${NEXTCLOUD_ROOT}
|
|
|
|
UPDATE_LIST=$(sudo -u www-data php occ update:check)
|
|
|
|
|
|
|
|
if [ $? != 0 ]
|
|
|
|
then
|
|
|
|
echo "Failed to check Nextcloud update"
|
|
|
|
else
|
|
|
|
|
|
|
|
# OK, we have the human readable status, let's process it
|
|
|
|
echo ${UPDATE_LIST} | grep -q "Everything up to date"
|
|
|
|
|
|
|
|
if [ $? == 0 ]
|
|
|
|
then
|
|
|
|
echo "OK"
|
|
|
|
EXIT_RESULT=0
|
|
|
|
else
|
|
|
|
echo ${UPDATE_LIST}
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
2020-06-29 18:56:08 +02:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit ${EXIT_RESULT}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|