- Updated .gitignore to include gpu-rent.vars. - Modified env.example to introduce the UPDATE_GIT variable for controlling git updates during execution. - Implemented Import-GpuRentVars function in gpu-rent.ps1 to load environment variables from gpu-rent.vars. - Enhanced gpu-rent.sh to support loading variables from gpu-rent.vars and added logic for handling default and extra arguments. - Updated CLI documentation to reflect the new gpu-rent.vars file and its usage in configuration. - Improved bootstrap and provisioning logic to conditionally perform git updates based on the new configuration.
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""Upload and run the idempotent SwarmUI bootstrap on the VM."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Callable
|
|
from importlib.resources import files
|
|
|
|
from gpu_rent.config import Config
|
|
from gpu_rent.errors import CloudError
|
|
from gpu_rent.ssh_ops import run_script_sudo
|
|
|
|
Log = Callable[[str], None]
|
|
|
|
|
|
def bootstrap_script() -> str:
|
|
return files("gpu_rent.remote").joinpath("bootstrap.sh").read_text(encoding="utf-8")
|
|
|
|
|
|
def run_bootstrap(cfg: Config, host: str, log: Log, *, update: bool = True) -> None:
|
|
log("bootstrap SwarmUI на VM (идемпотентно, без Docker)")
|
|
if update:
|
|
log("git update: SwarmUI on")
|
|
else:
|
|
log("git update: SwarmUI off (--no-update)")
|
|
script = bootstrap_script()
|
|
out = run_script_sudo(
|
|
cfg,
|
|
host,
|
|
script,
|
|
remote_path="/tmp/gpu-rent-bootstrap.sh",
|
|
timeout=1800,
|
|
env={
|
|
"SWARM_USER": cfg.ssh_user,
|
|
"GPU_RENT_UPDATE_GIT": "1" if update else "0",
|
|
},
|
|
log=log,
|
|
)
|
|
if "bootstrap ok" not in out:
|
|
raise CloudError(f"bootstrap не подтвердил успех:\n{out[-800:]}")
|
|
log("диски и systemd unit готовы; дальше seed, потом start swarmui")
|