Files
docu/pve1/scripts/vm101-nextcloud-maintain.sh
root 2edf5e69b1 Doku: VM-101-Skripte ins Repo (NAT, Wartung, Crontab).
Skripte unter pve1/scripts/ mit Install-Anleitung in 06_ubuntu-vm-nextcloud.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 11:01:59 +02:00

55 lines
1.4 KiB
Bash

#!/bin/bash
# Weekly maintenance: Nextcloud apps + notify_push sidecar sync.
# Container images (nextcloud stack): Dockge or manual compose pull.
#
# Install: /usr/local/sbin/nextcloud-maintain.sh (chmod +x)
# Cron: 30 4 * * 0 (root, Sonntag 04:30 UTC)
# Log: /var/log/nextcloud-maintain.log
set -euo pipefail
STACK=/opt/stacks/nextcloud
LOG_TAG="nextcloud-maintain"
LOCK=/run/nextcloud-maintain.lock
PUSH_URL="https://cloud.jeanavril.com/push"
log() { echo "[$(date -Iseconds)] $LOG_TAG: $*"; }
exec 9>"$LOCK"
if ! flock -n 9; then
log "already running, exit"
exit 0
fi
log "start"
if ! docker ps --format '{{.Names}}' | grep -qx nextcloud; then
log "nextcloud container not running, abort"
exit 1
fi
log "app:update notify_push"
docker exec -u abc nextcloud php /app/www/public/occ app:update notify_push 2>&1 || log "notify_push app update skipped or failed"
log "app:update --all"
docker exec -u abc nextcloud php /app/www/public/occ app:update --all 2>&1 || log "app:update --all had failures"
log "pull + restart notify_push sidecar"
cd "$STACK"
docker compose pull notify_push
docker compose up -d notify_push
sleep 3
log "notify_push:setup"
if docker exec -u abc nextcloud php /app/www/public/occ notify_push:setup "$PUSH_URL" 2>&1; then
log "notify_push sync OK"
else
log "notify_push:setup FAILED"
exit 1
fi
log "notify_push:metrics"
docker exec -u abc nextcloud php /app/www/public/occ notify_push:metrics 2>&1 || true
log "done"