feat(F6-3): version-watch — реальное сравнение версий, дедупликация, реестр по факту

This commit is contained in:
root committed 2026-10-14 12:43:15 +03:00
1 parent eaa34591d9
commit 114f8cf101
3 files changed
+518 -139

No files matched your search

+105
View File
@@ -0,0 +1,105 @@
#!/bin/bash
# ============================================================
# version-watch.sh — F6-3: слежение за выходом новых версий
# ============================================================
# Сравнивает версии из stable-versions.json с последними стабильными тегами
# соответствующих образов на Docker Hub и уведомляет n8n об обновлении.
#
# Что исправлено по сравнению с прежней версией:
# 1. Раньше скрипт сравнивал зафиксированный тег со строкой "latest"
# (page_size=1&name=latest), поэтому находил «обновление» при каждом
# запуске. Теперь берётся старший semver-тег и сравнение осмысленно.
# 2. Добавлен файл состояния: об одной и той же версии сообщается один раз.
# 3. Первый запуск только фиксирует текущие версии, не рассылая уведомлений.
# 4. Образы с плавающими тегами (latest/edge/nightly) пропускаются:
# их версию по тегу определить нельзя, а сравнивать нечего.
#
# Запуск: вручную или по cron каждые 6 часов.
# ============================================================
set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BASE_DIR="$(dirname "$(dirname "$SCRIPT_DIR")")"
VERSIONS_FILE="${VERSIONS_FILE:-$BASE_DIR/ops/state/stable-versions.json}"
STATE_FILE="${STATE_FILE:-$BASE_DIR/ops/state/version-watch-seen.json}"
N8N_WEBHOOK="${N8N_WEBHOOK:-http://192.168.1.108:5678/webhook/version-update-available}"
LOG_TAG="version-watch"
log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"; }
command -v jq >/dev/null 2>&1 || { log "нужен jq"; exit 1; }
command -v curl >/dev/null 2>&1 || { log "нужен curl"; exit 1; }
[ -f "$VERSIONS_FILE" ] || { log "нет файла $VERSIONS_FILE"; exit 1; }
[ -f "$STATE_FILE" ] || echo '{}' > "$STATE_FILE"
is_semver() { echo "$1" | grep -qE '^v?[0-9]+(\.[0-9]+){1,2}$'; }
# Старший стабильный semver-тег образа на Docker Hub.
# pre-release и служебные теги (latest, edge, stable, nightly) отбрасываются.
latest_stable_tag() {
local image="$1"
curl -s -m 25 \
"https://hub.docker.com/v2/repositories/${image}/tags/?page_size=100&ordering=last_updated" \
| jq -r '.results[]?.name' 2>/dev/null \
| grep -E '^v?[0-9]+(\.[0-9]+){1,2}$' \
| sed 's/^v//' \
| sort -t. -k1,1n -k2,2n -k3,3n \
| tail -1
}
save_state() { # $1 service, $2 value
local tmp
tmp=$(mktemp)
jq --arg s "$1" --arg v "$2" '.[$s] = $v' "$STATE_FILE" > "$tmp" && mv "$tmp" "$STATE_FILE"
}
checked=0; skipped=0; found=0; baseline=0
for service in $(jq -r 'keys[]' "$VERSIONS_FILE"); do
image=$(jq -r --arg s "$service" '.[$s].image // empty' "$VERSIONS_FILE")
current=$(jq -r --arg s "$service" '.[$s].stable_tag // empty' "$VERSIONS_FILE")
ct=$(jq -r --arg s "$service" '.[$s].ct // empty' "$VERSIONS_FILE")
[ -n "$image" ] || continue
if ! is_semver "$current"; then
log "пропуск $service: плавающий тег '$current' — версия не определяется"
skipped=$((skipped + 1))
continue
fi
checked=$((checked + 1))
latest=$(latest_stable_tag "$image")
[ -n "$latest" ] || { log "не удалось узнать версию $image"; continue; }
seen=$(jq -r --arg s "$service" '.[$s] // empty' "$STATE_FILE")
# Первый запуск: фиксируем базу, не уведомляя.
if [ -z "$seen" ]; then
save_state "$service" "$latest"
baseline=$((baseline + 1))
[ "$latest" = "$current" ] && continue
log "базовая версия $service: зафиксировано $current, доступно $latest (уведомление со следующего изменения)"
continue
fi
[ "$latest" = "$seen" ] && continue
log "обновление: $service $current -> $latest ($image)"
payload=$(jq -n \
--arg s "$service" --arg i "$image" \
--arg c "$current" --arg n "$latest" --arg ct "$ct" \
'{service:$s, image:$i, current_version:$c, new_version:$n, ct:$ct}')
if curl -s -m 20 -X POST -H 'Content-Type: application/json' \
-d "$payload" "$N8N_WEBHOOK" >/dev/null; then
save_state "$service" "$latest"
found=$((found + 1))
else
log "не удалось отправить уведомление для $service"
fi
done
log "[$LOG_TAG] проверено: $checked, пропущено (плавающий тег): $skipped, база зафиксирована: $baseline, новых обновлений: $found"
exit 0
+412 -139
View File
@@ -1,170 +1,443 @@
{
"npm": {
"version": "jc21/nginx-proxy-manager:latest (sha256:2aa69b382a384)",
"baseline": "2026-10-09T16:01:20+03:00",
"ct_id": 101,
"adguard": {
"ct": "107",
"host": "utils-lxc",
"image": "adguard/adguardhome",
"stable_tag": "latest",
"type": "docker"
},
"authentik": {
"version": "ghcr.io/goauthentik/server:latest (sha256:36233579415aa)",
"baseline": "2026-10-09T16:01:21+03:00",
"ct_id": 114,
"authentik-security-redis-1": {
"ct": "114",
"host": "authentik-security",
"image": "redis",
"stable_tag": "7-alpine",
"type": "docker"
},
"gitea": {
"version": "4c697a48a247",
"updated": "2026-10-09T16:05:54+03:00",
"ct_id": 140,
"snapshot": "pre-update-20261009-160526"
},
"vaultwarden": {
"version": "mariadb:10.6 (sha256:4c3275637f132)",
"baseline": "2026-10-09T16:01:23+03:00",
"ct_id": 109,
"authentik-security-server-1": {
"ct": "114",
"host": "authentik-security",
"image": "ghcr.io/goauthentik/server",
"stable_tag": "latest",
"type": "docker"
},
"matrix": {
"version": "coturn/coturn:latest (sha256:f4c2af06c3c53)",
"baseline": "2026-10-09T16:01:24+03:00",
"ct_id": 155,
"type": "docker"
},
"n8n": {
"version": "n8nio/n8n:latest (sha256:a8c95f75c6fdf)",
"baseline": "2026-10-09T16:01:25+03:00",
"ct_id": 108,
"type": "docker"
},
"prometheus": {
"version": "prom/prometheus:latest (sha256:5a2c7fe424271)",
"baseline": "2026-10-09T16:01:26+03:00",
"ct_id": 134,
"type": "docker"
},
"grafana": {
"version": "grafana/grafana:latest (sha256:e89290a84a722)",
"baseline": "2026-10-09T16:01:27+03:00",
"ct_id": 113,
"type": "docker"
},
"uptime-kuma": {
"version": "adguard/adguardhome:latest (sha256:4956b35b59028)",
"baseline": "2026-10-09T16:01:28+03:00",
"ct_id": 107,
"type": "docker"
},
"dashy": {
"version": "lissy93/dashy:latest (sha256:cab27aa8c7d67)",
"baseline": "2026-10-09T16:01:28+03:00",
"ct_id": 102,
"type": "docker"
},
"paperless": {
"version": "ghcr.io/paperless-ngx/paperless-ngx:latest (sha256:1d99ede700ffd)",
"baseline": "2026-10-09T16:01:29+03:00",
"ct_id": 105,
"type": "docker"
},
"syncthing": {
"version": "syncthing/syncthing:latest (sha256:1766cd0254a21)",
"baseline": "2026-10-09T16:01:30+03:00",
"ct_id": 139,
"type": "docker"
},
"linkding": {
"version": "quay.io/oauth2-proxy/oauth2-proxy:latest (sha256:cf3a5d50849b1)",
"baseline": "2026-10-09T16:01:31+03:00",
"ct_id": 127,
"type": "docker"
},
"jellyfin": {
"version": "jellyfin/jellyfin:latest (sha256:333b647716631)",
"baseline": "2026-10-09T16:01:32+03:00",
"ct_id": 103,
"type": "docker"
},
"plex": {
"version": "linuxserver/plex:latest (sha256:a6a34bc2f65ab)",
"baseline": "2026-10-09T16:01:33+03:00",
"ct_id": 116,
"type": "docker"
},
"sonarr": {
"version": "lscr.io/linuxserver/sonarr:latest (sha256:ddf896fd2d36a)",
"baseline": "2026-10-09T16:01:34+03:00",
"ct_id": 117,
"type": "docker"
},
"radarr": {
"version": "lscr.io/linuxserver/radarr:latest (sha256:c6e558907241b)",
"baseline": "2026-10-09T16:01:35+03:00",
"ct_id": 118,
"type": "docker"
},
"prowlarr": {
"version": "lscr.io/linuxserver/prowlarr:latest (sha256:057051bac5002)",
"baseline": "2026-10-09T16:01:36+03:00",
"ct_id": 119,
"authentik-security-worker-1": {
"ct": "114",
"host": "authentik-security",
"image": "ghcr.io/goauthentik/server",
"stable_tag": "latest",
"type": "docker"
},
"bazarr": {
"version": "lscr.io/linuxserver/bazarr:latest (sha256:1156fdc4c6cb1)",
"baseline": "2026-10-09T16:01:37+03:00",
"ct_id": 120,
"ct": "120",
"host": "bazarr-lxc",
"image": "lscr.io/linuxserver/bazarr",
"stable_tag": "latest",
"type": "docker"
},
"overseerr": {
"version": "lscr.io/linuxserver/overseerr:latest (sha256:3b6ccb144973d)",
"baseline": "2026-10-09T16:01:38+03:00",
"ct_id": 121,
"calibre-web": {
"ct": "111",
"host": "reading-lxc",
"image": "linuxserver/calibre-web",
"stable_tag": "latest",
"type": "docker"
},
"tautulli": {
"version": "quay.io/oauth2-proxy/oauth2-proxy:latest (sha256:cf3a5d50849b1)",
"baseline": "2026-10-09T16:01:39+03:00",
"ct_id": 122,
"dashy": {
"ct": "102",
"host": "portal-lxc",
"image": "lissy93/dashy",
"stable_tag": "latest",
"type": "docker"
},
"navidrome": {
"version": "deluan/navidrome:latest (sha256:427667d980b08)",
"baseline": "2026-10-09T16:01:40+03:00",
"ct_id": 125,
"duplicati": {
"ct": "111",
"host": "reading-lxc",
"image": "duplicati/duplicati",
"stable_tag": "latest",
"type": "docker"
},
"calibre": {
"version": "duplicati/duplicati:latest (sha256:eb0c1298a1974)",
"baseline": "2026-10-09T16:01:41+03:00",
"ct_id": 111,
"element-web": {
"ct": "155",
"host": "matrix",
"image": "vectorim/element-web",
"stable_tag": "latest",
"type": "docker"
},
"files_db": {
"ct": "109",
"host": "cloud-lxc",
"image": "mariadb",
"stable_tag": "10.6",
"type": "docker"
},
"firefly": {
"ct": "110",
"host": "office-lxc",
"image": "fireflyiii/core",
"stable_tag": "latest",
"type": "docker"
},
"freshrss": {
"version": "duplicati/duplicati:latest (sha256:eb0c1298a1974)",
"baseline": "2026-10-09T16:01:42+03:00",
"ct_id": 111,
"ct": "111",
"host": "reading-lxc",
"image": "freshrss/freshrss",
"stable_tag": "latest",
"type": "docker"
},
"gitea": {
"ct": "140",
"host": "gitea-lxc",
"image": "4c697a48a247",
"stable_tag": "latest",
"type": "docker"
},
"grafana": {
"ct": "113",
"host": "backup-lxc",
"image": "grafana/grafana",
"stable_tag": "latest",
"type": "docker"
},
"homeassistant": {
"ct": "106",
"host": "smart-lxc",
"image": "ghcr.io/home-assistant/home-assistant",
"stable_tag": "stable",
"type": "docker"
},
"jellyfin": {
"ct": "103",
"host": "media-lxc",
"image": "jellyfin/jellyfin",
"stable_tag": "latest",
"type": "docker"
},
"linkding": {
"ct": "127",
"host": "linkwarden-lxc",
"image": "sissbruecker/linkding",
"stable_tag": "latest",
"type": "docker"
},
"livekit": {
"ct": "155",
"host": "matrix",
"image": "livekit/livekit-server",
"stable_tag": "latest",
"type": "docker"
},
"matrix-coturn": {
"ct": "155",
"host": "matrix",
"image": "coturn/coturn",
"stable_tag": "latest",
"type": "docker"
},
"matrix-synapse": {
"ct": "155",
"host": "matrix",
"image": "matrixdotorg/synapse",
"stable_tag": "latest",
"type": "docker"
},
"mautrix-telegram": {
"ct": "155",
"host": "matrix",
"image": "dock.mau.dev/mautrix/telegram",
"stable_tag": "latest",
"type": "docker"
},
"mealie": {
"version": "fireflyiii/core:latest (sha256:28a4c105fac89)",
"baseline": "2026-10-09T16:01:43+03:00",
"ct_id": 110,
"ct": "110",
"host": "office-lxc",
"image": "ghcr.io/mealie-recipes/mealie",
"stable_tag": "latest",
"type": "docker"
},
"postgres-rbac": {
"version": "14+238",
"baseline": "2026-10-09T16:01:43+03:00",
"ct_id": 151,
"type": "native"
"mosquitto": {
"ct": "106",
"host": "smart-lxc",
"image": "eclipse-mosquitto",
"stable_tag": "latest",
"type": "docker"
},
"headscale": {
"version": "",
"baseline": "2026-10-09T16:01:44+03:00",
"ct_id": 201,
"type": "native"
"n8n": {
"ct": "108",
"host": "automation-lxc",
"image": "n8nio/n8n",
"stable_tag": "latest",
"type": "docker"
},
"nats": {
"ct": "115",
"host": "OpenClaw",
"image": "nats",
"stable_tag": "2.10.17-alpine",
"type": "docker"
},
"navidrome": {
"ct": "125",
"host": "navidrome-lxc",
"image": "deluan/navidrome",
"stable_tag": "latest",
"type": "docker"
},
"nextcloud": {
"ct": "109",
"host": "cloud-lxc",
"image": "nextcloud",
"stable_tag": "latest",
"type": "docker"
},
"node_red": {
"ct": "108",
"host": "automation-lxc",
"image": "nodered/node-red",
"stable_tag": "latest",
"type": "docker"
},
"npm-app-1": {
"ct": "101",
"host": "proxy-lxc",
"image": "jc21/nginx-proxy-manager",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-bazarr": {
"ct": "120",
"host": "bazarr-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-calibre": {
"ct": "111",
"host": "reading-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-dashy": {
"ct": "102",
"host": "portal-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-freshrss": {
"ct": "111",
"host": "reading-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-jellyfin": {
"ct": "103",
"host": "media-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-n8n": {
"ct": "108",
"host": "automation-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-navidrome": {
"ct": "125",
"host": "navidrome-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-nodered": {
"ct": "108",
"host": "automation-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-overseerr": {
"ct": "121",
"host": "overseerr-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-paperless": {
"ct": "110",
"host": "office-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-plex": {
"ct": "116",
"host": "plex-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-prowlarr": {
"ct": "119",
"host": "prowlarr-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-radarr": {
"ct": "118",
"host": "radarr-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-sonarr": {
"ct": "117",
"host": "sonarr-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-tautulli": {
"ct": "122",
"host": "tautulli-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"oauth2-proxy-vaultwarden": {
"ct": "109",
"host": "cloud-lxc",
"image": "quay.io/oauth2-proxy/oauth2-proxy",
"stable_tag": "latest",
"type": "docker"
},
"openclaw": {
"version": "ghcr.io/openclaw/openclaw:latest (sha256:3814fb1f62f9c)",
"baseline": "2026-10-09T16:01:45+03:00",
"ct_id": 115,
"ct": "115",
"host": "OpenClaw",
"image": "ghcr.io/openclaw/openclaw",
"stable_tag": "latest",
"type": "docker"
},
"overseerr": {
"ct": "121",
"host": "overseerr-lxc",
"image": "lscr.io/linuxserver/overseerr",
"stable_tag": "latest",
"type": "docker"
},
"paperless": {
"ct": "105",
"host": "files-lxc",
"image": "ghcr.io/paperless-ngx/paperless-ngx",
"stable_tag": "latest",
"type": "docker"
},
"paperless_redis": {
"ct": "110",
"host": "office-lxc",
"image": "redis",
"stable_tag": "7-alpine",
"type": "docker"
},
"paperless_web": {
"ct": "110",
"host": "office-lxc",
"image": "ghcr.io/paperless-ngx/paperless-ngx",
"stable_tag": "latest",
"type": "docker"
},
"paperless_worker": {
"ct": "110",
"host": "office-lxc",
"image": "ghcr.io/paperless-ngx/paperless-ngx",
"stable_tag": "latest",
"type": "docker"
},
"plex": {
"ct": "116",
"host": "plex-lxc",
"image": "linuxserver/plex",
"stable_tag": "latest",
"type": "docker"
},
"prometheus": {
"ct": "134",
"host": "prometheus-lxc",
"image": "prom/prometheus",
"stable_tag": "latest",
"type": "docker"
},
"prowlarr": {
"ct": "119",
"host": "prowlarr-lxc",
"image": "lscr.io/linuxserver/prowlarr",
"stable_tag": "latest",
"type": "docker"
},
"radarr": {
"ct": "118",
"host": "radarr-lxc",
"image": "lscr.io/linuxserver/radarr",
"stable_tag": "latest",
"type": "docker"
},
"sonarr": {
"ct": "117",
"host": "sonarr-lxc",
"image": "lscr.io/linuxserver/sonarr",
"stable_tag": "latest",
"type": "docker"
},
"swarm-redis": {
"ct": "115",
"host": "OpenClaw",
"image": "redis",
"stable_tag": "7-alpine",
"type": "docker"
},
"syncthing": {
"ct": "139",
"host": "syncthing-lxc",
"image": "syncthing/syncthing",
"stable_tag": "latest",
"type": "docker"
},
"tautulli": {
"ct": "122",
"host": "tautulli-lxc",
"image": "tautulli/tautulli",
"stable_tag": "latest",
"type": "docker"
},
"tg-admin-bot": {
"ct": "108",
"host": "automation-lxc",
"image": "telegram-admin-bot-tg-admin-bot",
"stable_tag": "latest",
"type": "docker"
},
"uptime_kuma": {
"ct": "107",
"host": "utils-lxc",
"image": "louislam/uptime-kuma",
"stable_tag": "latest",
"type": "docker"
},
"vaultwarden": {
"ct": "109",
"host": "cloud-lxc",
"image": "vaultwarden/server",
"stable_tag": "latest",
"type": "docker"
},
"zigbee2mqtt": {
"ct": "106",
"host": "smart-lxc",
"image": "koenkk/zigbee2mqtt",
"stable_tag": "latest",
"type": "docker"
}
}
}
+1
View File
@@ -0,0 +1 @@
{}