Add controller onboarding flow for primary drive setup

Introduce an onboarding system in the Controller that guides users
through selecting and mounting their primary media drive. This is
the fallback UI flow used when the main React app is unavailable.

Key changes:
- Add onboarding API endpoints and schemas (controller/api/onboarding.py)
- Add onboarding logic to detect drives, handle already-mounted drives
  (needed for RPi which auto-mounts), and save primary drive selection
  to the controller config when no mounts are configured
- Extend the Controller's index.html template with the onboarding UI
- Skip root cert creation until onboarding is complete
- Update first_startup.sh to support the onboarding/repair flow
- Add comprehensive tests for onboarding logic and API
This commit is contained in:
Roland 2026-03-14 14:56:32 -06:00
parent f146b332a8
commit 07f601e77f
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
15 changed files with 1464 additions and 66 deletions

View file

@ -362,3 +362,53 @@ class ReadyResponse(BaseModel):
api: bool = Field(description="Whether the main WROLPi API is responding")
app: bool = Field(description="Whether the React app is responding")
# ============================================================================
# Onboarding
# ============================================================================
class OnboardingCandidateResponse(BaseModel):
"""A drive that could be selected as the primary WROLPi drive."""
path: str = Field(description="Device path (e.g., /dev/sda1)")
name: str = Field(description="Device name (e.g., sda1)")
size: str = Field(description="Human-readable size (e.g., 1.8T)")
fstype: Optional[str] = Field(default=None, description="Filesystem type")
label: Optional[str] = Field(default=None, description="Filesystem label")
uuid: Optional[str] = Field(default=None, description="Filesystem UUID")
model: Optional[str] = Field(default=None, description="Drive model")
mountpoint: Optional[str] = Field(default=None, description="Current mount point if auto-mounted (e.g., /media/pi/MyDrive)")
class OnboardingProbeRequest(BaseModel):
"""Request to probe a drive for WROLPi configuration."""
device_path: str = Field(description="Device path to probe (e.g., /dev/sda1)")
fstype: str = Field(description="Filesystem type (e.g., ext4)")
class OnboardingProbeResponse(BaseModel):
"""Result of probing a drive for WROLPi configuration."""
config_found: bool = Field(description="Whether a controller.yaml was found on the drive")
mounts: list = Field(default_factory=list, description="Mount entries from config if found")
device_path: str = Field(description="Device path that was probed")
fstype: str = Field(description="Filesystem type")
class OnboardingCommitRequest(BaseModel):
"""Request to execute onboarding setup."""
device_path: str = Field(description="Device path to use as primary drive")
fstype: str = Field(description="Filesystem type")
force: bool = Field(default=False, description="Proceed even if no config found on drive")
class OnboardingCommitResponse(BaseModel):
"""Result of onboarding setup."""
success: bool = Field(description="Whether onboarding completed successfully")
error: Optional[str] = Field(default=None, description="Error message if failed")
mounts: list[str] = Field(default_factory=list, description="Mount points that were mounted")
repair_started: bool = Field(default=False, description="Whether repair script was started")