| 340 | |
| 341 | |
| 342 | def prepare_workdir(workdir: Path, plan: DeploymentPlan) -> None: |
| 343 | existing = [] |
| 344 | for name in ["docker-compose.yml", "db"]: |
| 345 | path = workdir / name |
| 346 | if path.exists(): |
| 347 | existing.append(str(path)) |
| 348 | |
| 349 | if platform.system() == "Linux": |
| 350 | for svc in [CONSOLE_SERVICE_NAME, "onlyboxes-worker-docker", "onlyboxes-worker-boxlite"]: |
| 351 | path = Path(f"/etc/systemd/system/{svc}.service") |
| 352 | if path.exists(): |
| 353 | existing.append(str(path)) |
| 354 | |
| 355 | if existing: |
| 356 | fatal( |
| 357 | "workdir", |
| 358 | "Existing installation detected. This installer only supports fresh installs.\n" |
| 359 | " Found: " + ", ".join(existing), |
| 360 | ) |
| 361 | |
| 362 | subdirs = ["db", "bin", "install-artifacts"] |
| 363 | if plan.worker_runtime == "boxlite": |
| 364 | subdirs.append("data/boxlite") |
| 365 | for sub in subdirs: |
| 366 | (workdir / sub).mkdir(parents=True, exist_ok=True) |
| 367 | |
| 368 | info(f"Working directory ready: {workdir}") |
| 369 | |
| 370 | |
| 371 | def download_and_extract_release(workdir: Path, tag: str, asset_template: str, binary_name: str) -> Path: |