update to 32.0.2; health script
This commit is contained in:
@@ -34,6 +34,11 @@ services:
|
|||||||
- nextcloud_db_v1:/var/lib/mysql
|
- nextcloud_db_v1:/var/lib/mysql
|
||||||
networks:
|
networks:
|
||||||
- nextcloud_v1_cloud
|
- nextcloud_v1_cloud
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "5"
|
||||||
|
|
||||||
nextcloud-redis-v1:
|
nextcloud-redis-v1:
|
||||||
image: redis:7.2-alpine
|
image: redis:7.2-alpine
|
||||||
@@ -46,9 +51,15 @@ services:
|
|||||||
- nextcloud_redis_v1:/data
|
- nextcloud_redis_v1:/data
|
||||||
networks:
|
networks:
|
||||||
- nextcloud_v1_cloud
|
- nextcloud_v1_cloud
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "5"
|
||||||
|
|
||||||
nextcloud-fpm-v1:
|
nextcloud-fpm-v1:
|
||||||
image: nextcloud:32.0.1-fpm
|
# image: nextcloud:32.0.1-fpm
|
||||||
|
image: nextcloud:32.0.2-fpm
|
||||||
container_name: nextcloud-fpm-v1
|
container_name: nextcloud-fpm-v1
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
@@ -76,6 +87,11 @@ services:
|
|||||||
- nextcloud_v1_cloud
|
- nextcloud_v1_cloud
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- "nextcloud.knusperkerne.de:89.58.0.1"
|
- "nextcloud.knusperkerne.de:89.58.0.1"
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "5"
|
||||||
|
|
||||||
nextcloud-nginx-v1:
|
nextcloud-nginx-v1:
|
||||||
image: nginx:1.26-alpine
|
image: nginx:1.26-alpine
|
||||||
@@ -89,9 +105,13 @@ services:
|
|||||||
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
- nextcloud_app_v1:/var/www/html:ro
|
- nextcloud_app_v1:/var/www/html:ro
|
||||||
- nextcloud_custom_apps_v1:/var/www/html/custom_apps:ro
|
- nextcloud_custom_apps_v1:/var/www/html/custom_apps:ro
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
- nextcloud_v1_cloud
|
- nextcloud_v1_cloud
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "5"
|
||||||
|
|
||||||
nextcloud-cron-v1:
|
nextcloud-cron-v1:
|
||||||
image: nextcloud:32.0.1-fpm
|
image: nextcloud:32.0.1-fpm
|
||||||
@@ -110,3 +130,8 @@ services:
|
|||||||
- nextcloud_themes_v1:/var/www/html/themes
|
- nextcloud_themes_v1:/var/www/html/themes
|
||||||
networks:
|
networks:
|
||||||
- nextcloud_v1_cloud
|
- nextcloud_v1_cloud
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: "2m"
|
||||||
|
max-file: "5"
|
||||||
|
|||||||
135
tools/nextcloud_healthcheck.sh
Executable file
135
tools/nextcloud_healthcheck.sh
Executable file
@@ -0,0 +1,135 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# nextcloud_healthcheck.sh
|
||||||
|
# Comprehensive health check for a Docker-based Nextcloud installation.
|
||||||
|
#
|
||||||
|
# Requirements:
|
||||||
|
# - Nextcloud running in a container named "nextcloud"
|
||||||
|
# - Access to the docker CLI
|
||||||
|
# - curl installed
|
||||||
|
#
|
||||||
|
# Author: Lars Klemstein (preferred setup preserved)
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
readonly CONTAINER="nextcloud-fpm-v1"
|
||||||
|
readonly NC_URL="https://nextcloud.knusperkerne.de" # adjust if needed
|
||||||
|
|
||||||
|
log() {
|
||||||
|
printf "[%s] %s\n" "$(date +'%Y-%m-%d %H:%M:%S')" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
err() {
|
||||||
|
printf "\033[31m[%s] ERROR: %s\033[0m\n" "$(date +'%Y-%m-%d %H:%M:%S')" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_container() {
|
||||||
|
if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then
|
||||||
|
err "Container '${CONTAINER}' not running."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
log "Container '${CONTAINER}' is running."
|
||||||
|
}
|
||||||
|
|
||||||
|
occ() {
|
||||||
|
docker exec -u www-data "${CONTAINER}" php occ "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_occ_status() {
|
||||||
|
log "Checking Nextcloud status via OCC..."
|
||||||
|
if ! occ status >/tmp/nc_status.txt 2>/tmp/nc_status_err.txt; then
|
||||||
|
err "OCC status failed. See /tmp/nc_status_err.txt"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat /tmp/nc_status.txt
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
check_integrity() {
|
||||||
|
log "Running integrity check..."
|
||||||
|
|
||||||
|
TMP_OUT="$(mktemp -t nc_integrity_out.XXXXXX)"
|
||||||
|
TMP_ERR="$(mktemp -t nc_integrity_err.XXXXXX)"
|
||||||
|
|
||||||
|
# execute OCC integrity check
|
||||||
|
if docker exec -u www-data "${CONTAINER}" php occ integrity:check-core >"$TMP_OUT" 2>"$TMP_ERR"; then
|
||||||
|
log "Integrity OK."
|
||||||
|
else
|
||||||
|
err "Integrity check failed."
|
||||||
|
err "Output: $TMP_OUT"
|
||||||
|
err "Errors: $TMP_ERR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f "$TMP_OUT" "$TMP_ERR"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_updates() {
|
||||||
|
log "Checking for available app updates..."
|
||||||
|
occ app:update --all >/tmp/nc_app_update.txt 2>/tmp/nc_app_update_err.txt || true
|
||||||
|
log "App update check completed."
|
||||||
|
}
|
||||||
|
|
||||||
|
check_http() {
|
||||||
|
log "Checking HTTP endpoint ${NC_URL}..."
|
||||||
|
HTTP_CODE=$(curl -k -s -o /dev/null -w "%{http_code}" "${NC_URL}")
|
||||||
|
|
||||||
|
case "$HTTP_CODE" in
|
||||||
|
200|301|302)
|
||||||
|
log "HTTP check OK (${HTTP_CODE})."
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
err "HTTP check returned ${HTTP_CODE}."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
check_cron() {
|
||||||
|
log "Checking background jobs mode..."
|
||||||
|
occ background:status >/tmp/nc_bg.txt 2>/tmp/nc_bg_err.txt
|
||||||
|
|
||||||
|
MODE=$(grep "Background mode" /tmp/nc_bg.txt | awk -F: '{print $2}' | xargs)
|
||||||
|
log "Background mode: ${MODE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_db() {
|
||||||
|
log "Checking database schema..."
|
||||||
|
occ db:convert-filecache-bigint --dry-run >/tmp/nc_db.txt 2>/tmp/nc_db_err.txt || true
|
||||||
|
|
||||||
|
if grep -q "All tables already up to date" /tmp/nc_db.txt; then
|
||||||
|
log "Database schema OK."
|
||||||
|
else
|
||||||
|
log "Database schema check: see /tmp/nc_db.txt (not an error, just info)."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
log "Starting Nextcloud health check..."
|
||||||
|
|
||||||
|
check_container
|
||||||
|
check_http
|
||||||
|
check_occ_status
|
||||||
|
check_integrity
|
||||||
|
check_cron
|
||||||
|
check_updates
|
||||||
|
check_db
|
||||||
|
|
||||||
|
log "Health check completed successfully."
|
||||||
|
}
|
||||||
|
|
||||||
|
final_status_ok=true
|
||||||
|
|
||||||
|
final_ok() {
|
||||||
|
printf "\033[32m[FINAL] OK\033[0m\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
final_not_ok() {
|
||||||
|
printf "\033[31m[FINAL] NOT_OK\033[0m\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
trap 'if [ "$final_status_ok" = true ]; then final_ok; else final_not_ok; fi' EXIT
|
||||||
|
|
||||||
|
|
||||||
|
main "$@"
|
||||||
Reference in New Issue
Block a user