Files
kefu/deploy/ark-chat-config-20260917/01-stage.sh
T
2026-09-21 10:34:06 +08:00

30 lines
1.7 KiB
Bash

set -euo pipefail
release=/home/ps/ark-chat-config-20260917
cd /opt/im-admin/deploy/im-admin
test ! -e "$release"
test "$(docker image inspect zyt/wecom-admin:current --format '{{.Id}}')" = 'sha256:1d6df0547b32c29ab28c6d96c0a434f5587cb1b62e97c7aaa0a454c4932c1976'
df -h /opt/im-admin /home/ps
mkdir -m 700 "$release"
cd /opt/im-admin
tar -czf "$release/source-before.tar.gz" wechat_rpa admin-web/apps/web-antd/src admin-web/apps/web-antd/dist deploy/im-admin/compose.yaml
docker tag zyt/wecom-admin:current zyt/wecom-admin:before-ark-chat-config-20260917
docker image inspect zyt/wecom-admin:current --format '{{.Id}}' > "$release/image-before.txt"
docker exec -i im-admin-api-1 python - <<'PY' > "$release/before.json"
import sqlite3,json,hashlib
from pathlib import Path
c=sqlite3.connect('file:/data/backend.db?mode=ro',uri=True,timeout=30)
tables=['archive_message','knowledge_item','desktop_accounts','model_providers','users']
counts={t:c.execute('SELECT COUNT(*) FROM '+t).fetchone()[0] for t in tables}
providers=c.execute('SELECT * FROM model_providers ORDER BY id').fetchall()
print(json.dumps({'counts':counts,'providers_digest':hashlib.sha256(json.dumps(providers,ensure_ascii=True,default=str).encode()).hexdigest(),'runtime_hashes':{f:hashlib.sha256((Path('/app/wechat_rpa')/f).read_bytes()).hexdigest() for f in ['admin_backend.py','model_protocol.py']}}))
PY
python3 - <<'PY'
import json,hashlib
from pathlib import Path
root=Path('/opt/im-admin')
x=json.loads(Path('/home/ps/ark-chat-config-20260917/before.json').read_text())
for f,h in x['runtime_hashes'].items():
assert hashlib.sha256((root/'wechat_rpa'/f).read_bytes()).hexdigest()==h, f+' runtime/source mismatch'
print(json.dumps(x))
PY