From 16fd28662c902f473188842ce36f0e7fb4a92a85 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 8 Apr 2026 13:57:03 +0000 Subject: [PATCH] =?UTF-8?q?VPN=20IP=EB=A1=9C=20=EC=95=BD=EA=B5=AD=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=20API=20=EC=B6=94=EA=B0=80=20+=20Phase=203?= =?UTF-8?q?=20=EA=B8=B0=EC=A1=B4=20=EC=95=BD=EA=B5=AD=20=EA=B0=90=EC=A7=80?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - farmq-admin: GET /api/pharmacy/search?vpn_ip= 엔드포인트 추가 - pharmacy_devices + pharmacies 테이블 모두 검색 - 스크립트: 기존 복잡한 Python 파싱 → 단순 API 호출로 변경 - PVE IP, CT IP 둘 다 검색 가능 Co-Authored-By: Claude Opus 4.6 (1M context) --- pharmq-setup.sh | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/pharmq-setup.sh b/pharmq-setup.sh index dd6c38f..65ac3d2 100644 --- a/pharmq-setup.sh +++ b/pharmq-setup.sh @@ -299,32 +299,15 @@ phase3_collect_info() { local EXISTING_PHARMACY="" if [ -n "$PVE_VPN_IP" ]; then print_step "등록된 약국 조회 중... (VPN IP: $PVE_VPN_IP)" - EXISTING_PHARMACY=$(curl -s --connect-timeout 5 "${FARMQ_API}/api/pharmacies" 2>/dev/null | \ - python3 -c " -import json, sys -try: - data = json.load(sys.stdin) - pharmacies = data.get('pharmacies', data) if isinstance(data, dict) else data - if isinstance(pharmacies, list): - for p in pharmacies: - devices = p.get('devices', []) - for d in devices: - if d.get('tailscale_ip') == '$PVE_VPN_IP': - print(json.dumps(p, ensure_ascii=False)) - sys.exit(0) - if p.get('tailscale_ip') == '$PVE_VPN_IP': - print(json.dumps(p, ensure_ascii=False)) - sys.exit(0) -except: - pass -" 2>/dev/null || true) + EXISTING_PHARMACY=$(curl -s --connect-timeout 5 "${FARMQ_API}/api/pharmacy/search?vpn_ip=${PVE_VPN_IP}" 2>/dev/null || true) fi - if [ -n "$EXISTING_PHARMACY" ]; then + # success:true 인지 확인 + if echo "$EXISTING_PHARMACY" | grep -q '"success": true\|"success":true' 2>/dev/null; then # 기존 약국 정보 로드 local EXIST_NAME EXIST_CODE - EXIST_NAME=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin).get('pharmacy_name',''))" 2>/dev/null || true) - EXIST_CODE=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin).get('pharmacy_code',''))" 2>/dev/null || true) + EXIST_NAME=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin)['pharmacy']['pharmacy_name'])" 2>/dev/null || true) + EXIST_CODE=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin)['pharmacy']['pharmacy_code'])" 2>/dev/null || true) echo "" echo -e "${GREEN}이 PVE에 등록된 약국을 찾았습니다:${NC}" @@ -337,10 +320,10 @@ except: if [[ -z "${USE_EXISTING:-}" ]] || [[ "${USE_EXISTING}" =~ ^[Yy]$ ]]; then PHARMACY_NAME="$EXIST_NAME" PHARMACY_CODE="$EXIST_CODE" - HIRA_CODE=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin).get('institution_code','') or '')" 2>/dev/null || true) - PHARMACY_ADDRESS=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin).get('address','') or '')" 2>/dev/null || true) - OWNER_NAME=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin).get('owner_name','') or '')" 2>/dev/null || true) - PHARMACY_PHONE=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin).get('phone','') or '')" 2>/dev/null || true) + HIRA_CODE=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin)['pharmacy'].get('institution_code','') or '')" 2>/dev/null || true) + PHARMACY_ADDRESS=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin)['pharmacy'].get('address','') or '')" 2>/dev/null || true) + OWNER_NAME=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin)['pharmacy'].get('owner_name','') or '')" 2>/dev/null || true) + PHARMACY_PHONE=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin)['pharmacy'].get('phone','') or '')" 2>/dev/null || true) MSSQL_SERVER="${ARGS_MSSQL:-192.168.0.201\\PM2014}" print_ok "기존 약국 정보 로드됨: $PHARMACY_CODE ($PHARMACY_NAME)"