Commit Graph

20 Commits

Author SHA1 Message Date
Claude
b37b1281a5 noVNC 스크립트 CLI 인자 지원 + Phase 9 자동 PVE 접속 정보 전달
- VNC/pharmq-novnc-setup.sh: --pve-host, --pve-password, --pharmacy-code, --pharmacy-name 인자 추가
  - 인자 있으면 대화형 입력 스킵, 없으면 기존대로 대화형
  - set -euo → set -eo (unset 변수 에러 방지)
- pharmq-setup.sh Phase 9: PVE LAN IP 자동 감지 + 약국 정보 인자로 전달

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 14:12:32 +00:00
Claude
05b01e111b Phase 9: noVNC를 PVE host가 아닌 CT 내부에서 pct exec로 실행
- noVNC는 Ubuntu CT(ubuntu-api)에서 돌아야 함
- pct exec로 CT 안에서 설치 스크립트 실행
- CT 내부에 이미 설치돼있으면 스킵

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 14:02:24 +00:00
Claude
16fd28662c VPN IP로 약국 검색 API 추가 + Phase 3 기존 약국 감지 수정
- 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) <noreply@anthropic.com>
2026-04-08 13:57:03 +00:00
Claude
3359ca04f6 Phase 3: PVE Tailscale IP로 기존 약국 자동 감지 + Phase 7 중복 등록 방지
- Phase 3: PVE VPN IP로 farmq API 조회하여 이미 등록된 약국이면
  약국 정보 자동 로드 + 사용자 확인 후 스킵
- Phase 7: PHARMACY_CODE가 이미 있으면 등록 스킵, hostname만 업데이트
- 재실행 시 불필요한 약국 중복 생성 방지

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 13:51:15 +00:00
Claude
1f2939cca4 Phase 8(RDP), Phase 9(noVNC) 통합 — 총 10단계로 확장
- Phase 8: RDP 자동 연결 (xorg+openbox+freerdp+toggle API)
  - VM 201(192.168.0.201) 자동 감지, rdpuser 자동 로그인
  - RDP Toggle API (포트 8090) 설치
  - 이미 설치돼있으면 스킵
- Phase 9: noVNC 웹 서비스 (기존 스크립트 호출)
  - 이미 설치돼있으면 스킵
- Phase 10: 검증 + 결과 출력 (기존 Phase 8)
  - RDP API 정보 출력 추가
- 모든 Phase 번호 /8 → /10으로 변경

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 13:44:16 +00:00
Claude
8419c4271c Phase 8 검증: ping → tailscale ping으로 변경
일반 ping은 Tailscale iptables 규칙에 의해 DROP될 수 있음.
tailscale ping으로 변경하여 실제 VPN 통신 상태를 정확히 확인.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 13:33:27 +00:00
Claude
4d1845c6bc Phase 5/6 스킵 감지 안정화: set -e 충돌 방지 + grep -P 호환성 수정
- ct_exec 실패 시 || true로 스크립트 종료 방지
- grep -oP → sed로 변경 (Debian/PVE 호환)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 13:26:56 +00:00
Claude
9a662c1251 스마트 재실행: 기존 VM/CT/VPN 감지하여 완료된 Phase 자동 스킵
- Phase 4: VM이 이미 존재하면 PBS 복원 스킵 (qm status 체크)
- Phase 5: ubuntu-api CT가 이미 있으면 생성 스킵 (200~299 스캔)
- Phase 6: CT에 Tailscale + API 코드가 있으면 환경 구축 스킵
- PBS 인증 실패 시 exit 대신 스킵 후 계속 진행
- 상태 파일 없이 시스템 상태만 보고 판단

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 13:22:57 +00:00
Claude
566280f4c5 Fix Phase 7 crash + improve error handling across all phases
- Fixed: farmq.db empty date strings causing API 500 error
- Phase 7: exit 1 → return 1 (skip and continue instead of crash)
- Phase 4/7 failures no longer kill the script
- Error trap now shows current progress info (pharmacy, VPN IP, CT VMID, etc.)
- Helps debugging when script fails mid-execution

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 10:55:02 +00:00
Claude
dd53e869d0 Fix: VM selection by list number instead of raw backup ID
Users were entering list number (e.g. 4) but script expected backup ID (e.g. 201).
Now maps selection number to actual VM ID via temp file.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 00:36:43 +00:00
Claude
36fdae3eb1 Don't exit on PBS snapshot not found — skip and continue
VM restore failure should not kill the entire script.
Skip to Phase 5 (CT creation) instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 00:35:15 +00:00
Claude
f89bbecdcd Fix script crash: remove set -u, handle python exit safely
- set -euo → set -eo (unset var no longer fatal)
- Python snapshot lookup: catch exceptions, use || true
- Prevents script exit on empty PBS responses

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 00:27:23 +00:00
Claude
394a0b0a7c Fix: empty Enter on VM selection crashes due to set -u (unset variable)
Added || true on read and ${:-} default expansion to handle empty input safely.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 00:23:07 +00:00
Claude
f0900204fb Auto-default storage to local-lvm in non-interactive VM restore mode
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 15:47:52 +00:00
Claude
8d76dc8da2 Add --vm-id, --vm-vmid, --vm-storage for fully non-interactive PBS restore
Auto-selects VM backup, target VMID, storage, and auto-confirms existing VM deletion.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 15:44:35 +00:00
Claude
a0e94682bf Add --skip-pbs flag for non-interactive PBS phase
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 15:42:31 +00:00
Claude
6834612deb Add CLI args support: --name, --hira, --addr, --owner, --phone, --mssql
Allows non-interactive execution via SSH pipe or automation.
Falls back to interactive /dev/tty input when no args provided.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 15:40:53 +00:00
Claude
d08ff19470 Improve LAN detection: check Headscale port response, not just ping
Ping 192.168.0.100 can false-positive if external pharmacy has a device
at that IP. Now checks if 192.168.0.100:8070 actually responds like Headscale.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 14:48:21 +00:00
Claude
985ec18651 Fix Headscale connection: auto-detect LAN vs external network
Same-LAN PVE hosts can't reach head.pharmq.kr via public IP (NAT hairpinning).
Script now pings 192.168.0.100 to detect LAN and uses direct IP:8070 instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 14:45:58 +00:00
Claude
d0cd2b1137 Add unified PharmQ PVE setup script + design doc
Single script that handles: PVE repo fix, Tailscale/Headscale VPN registration,
PBS Windows VM restore, Ubuntu CT creation with API environment,
pharmacy + device registration in farmq.db, and gateway account creation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 14:31:05 +00:00