Publish Neo Roundtable 0.6.3 (ef795c074ce4b6c6e4f4241affa8aa84fc6e2742)

This commit is contained in:
GPT-6
2026-11-15 12:56:01 +01:00
parent d3adffdfaf
commit 5fc48bd77d
7 changed files with 748 additions and 49 deletions
+60 -31
View File
@@ -267,6 +267,31 @@ save_log() {
local app; app=$("${COMPOSE[@]}" ps -aq roundtable)
[[ -z $app ]] || docker logs --tail 5000 "$app" > "$ROOT/logs/previous-container.log" 2>&1
}
restore_command() {
local archive=$1 code=0
[[ $archive == /backups/roundtable-*.tar.gz && $archive != *..* ]] || { error 'Use the /backups/roundtable-*.tar.gz path printed by backup.'; return 1; }
locked
# Restore with the image associated with the backup when reverting a migration.
if [[ -f .neo-previous/backup && $(cat .neo-previous/backup) == "$archive" ]]; then
cp .neo-previous/images.yml "$STAGING/restore.yml"
else cp .neo-images.yml "$STAGING/restore.yml"; fi
COMPOSE+=(-f "$STAGING/restore.yml")
guard recovery; helper capacity
# A mistyped archive stops nothing.
"${COMPOSE[@]}" run --rm -T --no-deps --entrypoint test roundtable -f "$archive" || { error "Backup archive $archive does not exist; nothing stopped."; return 1; }
local -a writers=(roundtable)
if "${COMPOSE[@]}" config --services | grep -Fxq contacts-workshop; then writers+=(contacts-workshop); fi
"${COMPOSE[@]}" stop "${writers[@]}"
"${COMPOSE[@]}" run --rm -T --no-deps --entrypoint roundtable roundtable restore --app-stopped "$archive" || code=$?
# 3 is "restored, cleanup pending": the restored state is live and has to
# run. Any other failure was rolled back and leaves the writers stopped.
[[ $code == 0 || $code == 3 ]] || return "$code"
cp "$STAGING/restore.yml" .neo-images.yml
if [[ -f .neo-previous/release.manifest && $(cat .neo-previous/backup) == "$archive" ]]; then cp .neo-previous/release.manifest release.manifest; fi
setup_compose; health recovery
rm -f .neo-previous/pending
[[ $code == 0 ]] || { echo 'Restored and running. Finish the cleanup named above by hand; do not restore again.' >&2; return 3; }
}
install_command() {
terminal
command -v docker >/dev/null || { error 'Please install Docker properly https://docs.docker.com/engine/install/debian/'; return 1; }
@@ -285,7 +310,7 @@ install_command() {
docker pull --platform linux/amd64 "$helper_image"
printf '%s\n%s\n' "$rt_domain" "$neo_domain" | "${RUN[@]}" -i --entrypoint roundtable "$helper_image" admin validate-domains
host_checks install
mkdir -p "$ROOT"; chmod 700 "$ROOT"
mkdir -p "$ROOT/logs"; chmod 700 "$ROOT" "$ROOT/logs"
printf '%s\n%s\n' "$rt_domain" "$neo_domain" | "${RUN[@]}" -i -v "$ROOT:/target" --entrypoint roundtable "$helper_image" admin init /target "$(id -u)" "$(id -g)"
cp "$STAGING/compose.yml" "$ROOT/compose.yml"; cp "$STAGING/neo-admin" "$ROOT/neo-admin"; chmod 700 "$ROOT/neo-admin"
login "$ROOT/vault/docker-auth"; export DOCKER_CONFIG=$ROOT/vault/docker-auth; unset token
@@ -322,18 +347,24 @@ update_command() {
if [[ -n ${token:-} ]]; then login "$ROOT/vault/docker-auth"; export DOCKER_CONFIG=$ROOT/vault/docker-auth; unset token; fi
mkdir -p logs .neo-previous
save_log
if [[ -f release.manifest ]]; then cp release.manifest .neo-previous/release.manifest; fi
if [[ -f .neo-images.yml ]]; then cp .neo-images.yml .neo-previous/images.yml; else
# Adopted source builds may have no registry digest: retain exact local IDs.
local service image
printf 'services:\n' > .neo-previous/images.yml
for service in postgres roundtable ocr transcription contacts-workshop; do
image=$(docker inspect --format '{{.Image}}' "$("${COMPOSE[@]}" ps -aq "$service")" 2>/dev/null || true)
[[ -z $image ]] || printf ' %s:\n image: %s\n pull_policy: never\n' "$service" "$image" >> .neo-previous/images.yml
done
# Until an update passes its health check, the services may already run the
# new release: keep the record of the last healthy one for rollback/restore.
if [[ -f .neo-previous/pending ]]; then
echo 'An earlier update did not pass its health check; keeping its rollback record.'
else
if [[ -f release.manifest ]]; then cp release.manifest .neo-previous/release.manifest; fi
if [[ -f .neo-images.yml ]]; then cp .neo-images.yml .neo-previous/images.yml; else
# Adopted source builds may have no registry digest: retain exact local IDs.
local service image
printf 'services:\n' > .neo-previous/images.yml
for service in postgres roundtable ocr transcription contacts-workshop; do
image=$(docker inspect --format '{{.Image}}' "$("${COMPOSE[@]}" ps -aq "$service")" 2>/dev/null || true)
[[ -z $image ]] || printf ' %s:\n image: %s\n pull_policy: never\n' "$service" "$image" >> .neo-previous/images.yml
done
fi
printf '%s\n' "$old_schema" > .neo-previous/schema
printf '%s\n' "$backup_file" > .neo-previous/backup
fi
printf '%s\n' "$old_schema" > .neo-previous/schema
printf '%s\n' "$backup_file" > .neo-previous/backup
cp "$STAGING/current.identity" .neo-identity
# First adoption must retain an operable host launcher even if serve fails.
if [[ ! -f release.manifest ]]; then
@@ -341,9 +372,13 @@ update_command() {
cp "$STAGING/neo-admin" neo-admin; chmod 700 neo-admin
touch .neo-rolled-back
fi
make_override "$STAGING/images.yml"; mv "$STAGING/images.yml" .neo-images.yml
make_override "$STAGING/images.yml"
# From here the services may run the new release until health passes.
: > .neo-previous/pending
mv "$STAGING/images.yml" .neo-images.yml
# The original Compose file, .env and all mount sources remain intact.
setup_compose; guard; health
rm -f .neo-previous/pending
cp "$STAGING/release.manifest" release.manifest
cp "$STAGING/neo-admin" neo-admin.new; chmod 700 neo-admin.new; mv neo-admin.new neo-admin
rm -f .neo-rolled-back
@@ -359,6 +394,7 @@ rollback_command() {
schema=$(helper schema); IFS= read -r previous < .neo-previous/schema; IFS= read -r backup_file < .neo-previous/backup
[[ $schema == "$previous" ]] || { printf 'Schema changed. Run: ./neo-admin restore %q\n' "$backup_file" >&2; return 1; }
cp .neo-previous/images.yml .neo-images.yml; setup_compose; health recovery
rm -f .neo-previous/pending
if [[ -f .neo-previous/release.manifest ]]; then cp .neo-previous/release.manifest release.manifest; else touch .neo-rolled-back; fi
}
validate_purge_plan() {
@@ -412,8 +448,8 @@ main() {
[[ $# == 0 ]]; latest
if [[ -f $ROOT/release.manifest || -f $ROOT/compose.yml || -f $ROOT/docker-compose.yml ]]; then host_checks update; else host_checks install; fi ;;
update|adopt) [[ $# == 0 ]]; update_command "$operation" ;;
help|--help|-h) echo 'neo-admin install|check|status|update|rollback|backup|restore <archive>|reset-pwd <user>|logs|uninstall [--purge]|adopt' ;;
status|backup|rollback|restore|reset-pwd|logs|uninstall)
help|--help|-h) echo 'neo-admin install|check|status|disk-check|update|rollback|backup|restore <archive>|reset-pwd <user>|logs|uninstall [--purge]|adopt' ;;
status|disk-check|backup|rollback|restore|reset-pwd|logs|uninstall)
[[ -f $ROOT/release.manifest ]] || { error 'No managed release; use adopt.'; return 1; }
pin_docker
read_manifest "$ROOT/release.manifest"; helper_image=${manifest[image_roundtable]}; export DOCKER_CONFIG=$ROOT/vault/docker-auth
@@ -424,26 +460,19 @@ main() {
local app; app=$("${COMPOSE[@]}" ps -aq roundtable)
[[ -z $app ]] || { printf 'Running image '; docker inspect --format '{{.Image}}' "$app"; printf 'Running build metadata (version, revision):\n'; docker exec "$app" cat /usr/local/share/roundtable-build-info 2>/dev/null || echo unavailable; }
"${COMPOSE[@]}" ps ;;
disk-check)
[[ $# == 0 ]] || { error 'Usage: neo-admin disk-check'; return 1; }
# As tools/disk-check.sh: Postgres reports its own filesystem, the
# application measures data and backups and stores the mode. Kept
# sequential so a failed measurement never clears read-only mode;
# a new read-only transition exits 1.
"${COMPOSE[@]}" exec -T postgres df -Pk /var/lib/postgresql > "$STAGING/postgres.df"
"${COMPOSE[@]}" run --rm -T --no-deps roundtable disk-check --postgres-df - < "$STAGING/postgres.df" ;;
logs) "${COMPOSE[@]}" logs --tail 200 ;;
rollback) rollback_command ;;
backup) locked; guard; backup_now ;;
reset-pwd) [[ $# == 1 ]]; locked; guard; "${COMPOSE[@]}" exec roundtable roundtable admin reset-pwd "$1" ;;
restore)
[[ $# == 1 && $1 == /backups/roundtable-*.tar.gz && $1 != *..* ]] || { error 'Use the /backups/roundtable-*.tar.gz path printed by backup.'; return 1; }
locked
# Restore with the image associated with the backup when reverting a migration.
if [[ -f .neo-previous/backup && $(cat .neo-previous/backup) == "$1" ]]; then
cp .neo-previous/images.yml "$STAGING/restore.yml"
else cp .neo-images.yml "$STAGING/restore.yml"; fi
COMPOSE+=(-f "$STAGING/restore.yml")
guard recovery; helper capacity
local -a writers=(roundtable)
if "${COMPOSE[@]}" config --services | grep -Fxq contacts-workshop; then writers+=(contacts-workshop); fi
"${COMPOSE[@]}" stop "${writers[@]}"
"${COMPOSE[@]}" -f "$STAGING/restore.yml" run --rm -T --no-deps --entrypoint roundtable roundtable restore --app-stopped "$1"
cp "$STAGING/restore.yml" .neo-images.yml
if [[ -f .neo-previous/release.manifest && $(cat .neo-previous/backup) == "$1" ]]; then cp .neo-previous/release.manifest release.manifest; fi
setup_compose; health recovery ;;
restore) [[ $# == 1 ]] || { error 'Use the /backups/roundtable-*.tar.gz path printed by backup.'; return 1; }; restore_command "$1" ;;
uninstall)
locked; guard
if [[ ${1:-} == --purge ]]; then