30 lines
1.7 KiB
Bash
30 lines
1.7 KiB
Bash
set -euo pipefail
|
|
release=/home/ps/token-usage-20260917
|
|
cd /opt/im-admin/deploy/im-admin
|
|
test ! -e "$release"
|
|
test "$(docker image inspect zyt/wecom-admin:current --format '{{.Id}}')" = 'sha256:6e1ef31d8d419be0cdb15db49377aea66556379742442c5fd843ff455b5e8da7'
|
|
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-token-usage-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/token-usage-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
|