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>
This commit is contained in:
Claude
2026-04-08 13:26:56 +00:00
parent 9a662c1251
commit 4d1845c6bc

View File

@@ -596,7 +596,7 @@ phase5_create_ct() {
ct_hostname=$(pct config "$vmid" 2>/dev/null | grep "^hostname:" | awk '{print $2}')
if [ "$ct_hostname" = "ubuntu-api" ]; then
CT_VMID="$vmid"
CT_LAN_IP=$(pct config "$vmid" 2>/dev/null | grep "^net0:" | grep -oP 'ip=\K[^/]+')
CT_LAN_IP=$(pct config "$vmid" 2>/dev/null | grep "^net0:" | sed 's/.*ip=\([^/]*\).*/\1/' || true)
print_ok "CT $CT_VMID (ubuntu-api) 이미 존재 — 생성 스킵"
# CT가 꺼져있으면 시작
if pct status "$vmid" 2>/dev/null | grep -q "stopped"; then
@@ -693,8 +693,8 @@ phase6_setup_ct() {
}
# 이미 CT에 Tailscale이 등록되어있고 API 코드가 있으면 스킵
local existing_vpn
existing_vpn=$(ct_exec "tailscale ip -4 2>/dev/null" 2>/dev/null | tr -d '[:space:]')
local existing_vpn=""
existing_vpn=$(ct_exec "tailscale ip -4 2>/dev/null" 2>/dev/null | tr -d '[:space:]' || true)
if [ -n "$existing_vpn" ] && ct_exec "test -d /srv/person-lookup-web-local" 2>/dev/null; then
CT_VPN_IP="$existing_vpn"
print_ok "CT 환경 이미 구축됨 (VPN: $CT_VPN_IP) — 스킵"