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

16 lines
1.1 KiB
Bash

set -euo pipefail
cd /opt/im-admin
python3 - <<'PY'
from pathlib import Path
import hashlib,json,subprocess
root=Path('/opt/im-admin')
files=['wechat_rpa/admin_backend.py','wechat_rpa/model_protocol.py','wechat_rpa/model_gateway.py','deploy/im-admin/compose.yaml']
files += [str(p.relative_to(root)) for p in (root/'admin-web').rglob('*') if p.is_file() and 'node_modules' not in p.parts and 'dist' not in p.parts and '.git' not in p.parts and p.suffix in ('.vue','.ts','.js','.json','.yaml','.yml','.css','.html','.mjs')]
rows={p:hashlib.sha256((root/p).read_bytes()).hexdigest() for p in files}
names=['im-admin-api-1','im-admin-gateway-1','im-admin-knowledge-worker-1']
states=[]
for c in json.loads(subprocess.check_output(['docker','inspect',*names])):
states.append({'name':c['Name'],'image':c['Image'],'running':c['State']['Running'],'health':c['State'].get('Health',{}).get('Status'),'restart_count':c['RestartCount']})
print(json.dumps({'files':rows,'containers':states,'current_image':subprocess.check_output(['docker','image','inspect','zyt/wecom-admin:current','--format','{{.Id}}'],text=True).strip()}))
PY