#!/usr/bin/env bash set -euo pipefail test "${PATIENT_RELEASE_APPROVED:-}" = patient-session-20260918 release=/home/ps/patient-session-20260918 cd /opt/im-admin/deploy/im-admin test -d "$release/source-before" test "$(docker image inspect zyt/wecom-admin:before-patient-session-20260918 --format '{{.Id}}')" = "$(cat "$release/image-before.txt")" docker compose stop -t 190 knowledge-worker docker compose stop -t 65 gateway python3 - <<'PY' from pathlib import Path import hashlib,json,os r=Path('/home/ps/patient-session-20260918');base=json.loads((r/'server-baseline-patient.json').read_text()) for name in json.loads((r/'patient-release-plan.json').read_text())['backendFiles']: data=(r/'source-before'/name).read_bytes();assert hashlib.sha256(data).hexdigest()==base['expected'][name] target=Path('/opt/im-admin/wechat_rpa')/name;tmp=target.with_name(name+'.rollback-patient.tmp') with tmp.open('xb') as f:f.write(data) os.chmod(tmp,target.stat().st_mode & 0o777);os.replace(tmp,target) PY docker tag zyt/wecom-admin:before-patient-session-20260918 zyt/wecom-admin:current docker compose up -d --no-build --wait --wait-timeout 180 api gateway knowledge-worker curl -fsS -o /dev/null http://127.0.0.1:18766/api/v2/health curl -fsS -o /dev/null http://127.0.0.1:18770/health printf '%s\n' 'Previous image and four source files restored; live database retained (no schema migration).'