Compare commits
3 Commits
b68858713d
...
62f23dc0bf
Author | SHA1 | Date | |
---|---|---|---|
62f23dc0bf | |||
6faa1ec942 | |||
d20bf19da1 |
@ -1,6 +1,6 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
#
|
#
|
||||||
# Copyright (C) 2019 Laurent Poujoulat <lpoujoulat@april.org>
|
# Copyright (C) 2020 Laurent Poujoulat <lpoujoulat@april.org>
|
||||||
#
|
#
|
||||||
# This file is part of valise.chapril.org
|
# This file is part of valise.chapril.org
|
||||||
#
|
#
|
||||||
@ -25,15 +25,7 @@
|
|||||||
# ================================================
|
# ================================================
|
||||||
|
|
||||||
# Configuration data
|
# Configuration data
|
||||||
CURL_CREDENTIAL="/etc/valise.chapril.org/curl_credential"
|
NEXTCLOUD_ROOT="/var/www/valise.chapril.org"
|
||||||
|
|
||||||
# Extract a json value by path (given as argument)
|
|
||||||
# The global JSON state is expected to be in NEXTCLOUD_STATE
|
|
||||||
# Only give the path part within the ocs.data section
|
|
||||||
getNcState()
|
|
||||||
{
|
|
||||||
echo ${NEXTCLOUD_STATE} | jq ".ocs.data.$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Returns script usage
|
# Returns script usage
|
||||||
function usage()
|
function usage()
|
||||||
@ -41,22 +33,39 @@ function usage()
|
|||||||
echo "Usage: $(basename $0)"
|
echo "Usage: $(basename $0)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Main entry point
|
# Main entry point
|
||||||
|
|
||||||
|
# By default, we assume to fail
|
||||||
EXIT_RESULT=1
|
EXIT_RESULT=1
|
||||||
|
|
||||||
# Read and store the current service state
|
# Usage check
|
||||||
NEXTCLOUD_STATE=`curl --silent --netrc-file ${CURL_CREDENTIAL} http://localhost/ocs/v2.php/apps/serverinfo/api/v1/info?format=json`
|
|
||||||
|
|
||||||
if [ "$#" -ne 0 ]
|
if [ "$#" -ne 0 ]
|
||||||
then
|
then
|
||||||
usage
|
usage
|
||||||
else
|
else
|
||||||
|
|
||||||
# Read and store the current service state
|
# Currently, nor the serverinfo API, nor the occ command has a clean way of checking both the core and apps update status
|
||||||
NEXTCLOUD_STATE=`curl --silent --netrc-file ${CURL_CREDENTIAL} http://localhost/ocs/v2.php/apps/serverinfo/api/v1/info?format=json`
|
# 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)
|
||||||
|
|
||||||
getNcState "nextcloud.system.apps.num_updates_available"
|
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
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user