#!/bin/sh # Instant auto-update: poll the registry and redeploy a container as soon as # its published image differs from what is running. Cron runs this every 2 min # (/boot/config/plugins/dynamix/registry-autoupdate.cron). # Skips entirely while a CI job container is active: recreating gitgudlab would # kill the registry mid-push, and the runner must not recreate itself mid-job # (redeploy-gitgudlab-runner.sh also guards this itself). LOCK=/var/run/registry-autoupdate.lock mkdir "$LOCK" 2>/dev/null || exit 0 trap 'rmdir "$LOCK"' EXIT if docker ps --format '{{.Names}}' | grep -q '^gitgud-job-'; then exit 0 fi check() { name=$1; ref=$2; script=$3 docker pull -q "$ref" >/dev/null 2>&1 || return 0 latest=$(docker image inspect --format '{{.Id}}' "$ref" 2>/dev/null) || return 0 running=$(docker inspect --format '{{.Image}}' "$name" 2>/dev/null) if [ "$latest" != "$running" ]; then logger -t registry-autoupdate "updating $name ($running -> $latest)" if sh "$script" >/dev/null 2>&1; then logger -t registry-autoupdate "$name updated" else logger -t registry-autoupdate "$name redeploy failed or refused, will retry" fi fi } check gitgudlab git.nas.home.htl-sky.net/permissionbrick/gitgudlab:latest /boot/config/redeploy-gitgudlab.sh check gitgudlab-runner git.nas.home.htl-sky.net/permissionbrick/gitgudlab:runner-latest /boot/config/redeploy-gitgudlab-runner.sh check sillytavern ghcr.io/sillytavern/sillytavern:latest /boot/config/redeploy-sillytavern.sh check runpod-lazy ghcr.io/permissionbrick/st-runpod-proxy:latest /boot/config/redeploy-runpod-lazy.sh