- 37개 파일 IP → zioinfo.co.kr 치환 (소스/매뉴얼/설정/하네스) - Manager DrConsole/NetworkConsole/CsapConsole 빌드 + /var/www/manager/ 배포 - 테스트: Manager HTTP 200, ITSM 신규 API 7개 전체 200 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
import os, subprocess
|
|
from fastapi import APIRouter, Depends, HTTPException
|
|
from core.auth import require_admin
|
|
|
|
router = APIRouter()
|
|
ENV_FILES = [
|
|
"/opt/guardia/app/.env",
|
|
"/opt/manager/backend/.env",
|
|
]
|
|
SENSITIVE = {"SECRET", "PASSWORD", "KEY", "TOKEN", "PASS", "PWD"}
|
|
|
|
def _mask(k: str, v: str) -> str:
|
|
return "****" if any(s in k.upper() for s in SENSITIVE) else v
|
|
|
|
@router.get("/env")
|
|
async def get_env(_=Depends(require_admin)):
|
|
result: dict[str, str] = {}
|
|
for path in ENV_FILES:
|
|
try:
|
|
with open(path) as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
if line and not line.startswith("#") and "=" in line:
|
|
k, _, v = line.partition("=")
|
|
result[k.strip()] = _mask(k.strip(), v.strip())
|
|
except FileNotFoundError:
|
|
pass
|
|
return result
|
|
|
|
@router.post("/nginx/reload")
|
|
async def nginx_reload(_=Depends(require_admin)):
|
|
test = subprocess.run(["nginx", "-t"], capture_output=True, text=True)
|
|
if test.returncode != 0:
|
|
raise HTTPException(status_code=400, detail=f"설정 오류: {test.stderr[:300]}")
|
|
subprocess.run(["systemctl", "reload", "nginx"])
|
|
return {"message": "Nginx 리로드 완료"}
|