123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #!/bin/bash
- RELEASEURL="https://download.nextcloud.com/server/releases/"
- BASEPATH="/var/www/html"
- APACHEUSER="apache"
- /usr/bin/which jq >/dev/null 2>&1
- if [ $? -ne 0 ]; then
- echo "2 \"NextCloud\" - NextCloud localcheck requires jq package to be installed"
- echo "2 \"NextCloud Apps\" - NextCloud localcheck requires jq package to be installed"
- exit;
- fi
- if ! id -u "$APACHEUSER" >/dev/null 2>&1; then
- echo "2 \"NextCloud\" - NextCloud localcheck webserver user does not exist, check configuration!"
- echo "2 \"NextCloud Apps\" - NextCloud localcheck webserver user does not exist, check configuration!"
- exit;
- fi
- if [ ! -d "$BASEPATH" ]; then
- echo "2 \"NextCloud\" - NextCloud localcheck could not find configured basepath, check configuration!"
- echo "2 \"NextCloud Apps\" - NextCloud localcheck could not find configured basepath, check configuration!"
- exit;
- fi
- NCINSTALLED=$(sudo -u $APACHEUSER php $BASEPATH/occ status --output=json | jq -r '.versionstring')
- NCAVAILABLE=$(curl -s $RELEASEURL | sed -e 's/<[^>]*>//g' | grep -o "^nextcloud.*.zip" | tail -n1 | cut -d'-' -f 2 | sed 's/.\{4\}$//')
- if [ $NCINSTALLED != $NCAVAILABLE ]; then
- echo "1 \"NextCloud\" - A new NextCloud version ($NCAVAILABLE)is available, running version $NCINSTALLED please upgrade"
- else
- sudo -u $APACHEUSER php $BASEPATH/occ status -e
- if [ $? -eq 0 ]; then
- echo "0 \"NextCloud\" - NextCloud all up to date"
- elif [ $? -eq 1 ]; then
- echo "1 \"NextCloud\" - NextCloud maintenance-mode is enabled"
- elif [ $? -eq 2 ]; then
- echo "2 \"NextCloud\" - NextCloud Core needs updating"
- fi
- fi
- APPRESULT=$(sudo -u $APACHEUSER php $BASEPATH/occ app:update --showonly)
- if [[ $APPRESULT == *"All apps are up-to-date"* ]]; then
- echo "0 \"NextCloud Apps\" - NextCloud Apps all up to date"
- else
- UPDATECOUNT=$(echo "$APPRESULT" | wc -l)
- echo "1 \"NextCloud Apps\" - $UPDATECOUNT NextCloud Apps requires updates"
- fi
|