| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- # -*- coding: utf-8 -*-
- """
- Installations-Schritte pro Modus.
- Definiert gewichtete Schritte fuer den InstallRunner.
- """
- from __future__ import annotations
- from dataclasses import dataclass
- @dataclass
- class InstallationStep:
- """Ein einzelner Installationsschritt."""
- id: str
- name: str
- description: str
- weight: int
- command_fn: str # Name der Runner-Methode
- def get_steps(mode: str) -> list[InstallationStep]:
- """Gibt die Schrittliste fuer den jeweiligen Modus zurueck."""
- stop_service_step = InstallationStep(
- id="stop_service",
- name="Laufenden Service stoppen",
- description="Stoppt einen bestehenden trixy-Service vor dem Update",
- weight=2,
- command_fn="step_stop_service",
- )
- start_service_step = InstallationStep(
- id="start_service",
- name="Service starten",
- description="Startet den trixy-Service nach der Installation",
- weight=2,
- command_fn="step_start_service",
- )
- common_steps = [
- InstallationStep(
- id="extract",
- name="Quellcode entpacken",
- description="Entpacke .tar.gz nach Installationspfad",
- weight=10,
- command_fn="step_extract",
- ),
- InstallationStep(
- id="apt_packages",
- name="System-Pakete",
- description="Installiere benoetigte apt-Pakete",
- weight=25,
- command_fn="step_apt_packages",
- ),
- InstallationStep(
- id="hostname",
- name="Hostname setzen",
- description="Setze System-Hostname",
- weight=2,
- command_fn="step_hostname",
- ),
- ]
- wifi_step = InstallationStep(
- id="wifi_ap",
- name="WiFi-Hotspot",
- description="Konfiguriere hostapd, dnsmasq, dhcpcd und NAT",
- weight=8,
- command_fn="step_wifi_ap",
- )
- venv_step = InstallationStep(
- id="venv",
- name="Python venv",
- description="Erstelle venv und installiere Kern-Requirements",
- weight=15,
- command_fn="step_venv",
- )
- plugin_step = InstallationStep(
- id="plugin_deps",
- name="Plugin-Abhaengigkeiten",
- description="Installiere Requirements der ausgewaehlten Plugins",
- weight=20,
- command_fn="step_plugin_deps",
- )
- dirs_step = InstallationStep(
- id="directories",
- name="Verzeichnisse",
- description="Erstelle Verzeichnisse und setze Berechtigungen",
- weight=5,
- command_fn="step_directories",
- )
- systemd_step = InstallationStep(
- id="systemd",
- name="systemd-Service",
- description="Erstelle und aktiviere systemd-Service",
- weight=5,
- command_fn="step_systemd",
- )
- models_step = InstallationStep(
- id="download_models",
- name="Modelle herunterladen",
- description="Lade ML-Modelle herunter (optional)",
- weight=15,
- command_fn="step_download_models",
- )
- wifi_connect_step = InstallationStep(
- id="wifi_connect",
- name="WLAN-Verbindung",
- description="Konfiguriere WLAN-Verbindung (wpa_supplicant)",
- weight=5,
- command_fn="step_wifi_connect",
- )
- swap_check_step = InstallationStep(
- id="check_swap",
- name="Speicher-Check",
- description="Pruefe RAM+Swap und lege bei Bedarf Swap-Datei an",
- weight=3,
- command_fn="step_check_swap",
- )
- swap_cleanup_step = InstallationStep(
- id="cleanup_swap",
- name="Swap abschliessen",
- description="Swap-Datei permanent behalten oder entfernen",
- weight=2,
- command_fn="step_cleanup_swap",
- )
- verify_step = InstallationStep(
- id="verify",
- name="Verifizierung",
- description="Pruefe installierte Abhaengigkeiten",
- weight=10,
- command_fn="step_verify",
- )
- if mode == "server":
- return [
- stop_service_step,
- swap_check_step,
- *common_steps,
- wifi_step,
- venv_step,
- plugin_step,
- dirs_step,
- models_step,
- systemd_step,
- start_service_step,
- verify_step,
- swap_cleanup_step,
- ]
- if mode == "client":
- return [
- stop_service_step,
- swap_check_step,
- common_steps[0], # extract
- common_steps[1], # apt
- common_steps[2], # hostname
- wifi_connect_step,
- venv_step,
- dirs_step,
- systemd_step,
- start_service_step,
- verify_step,
- swap_cleanup_step,
- ]
- if mode == "standalone":
- return [
- stop_service_step,
- swap_check_step,
- *common_steps,
- wifi_connect_step,
- venv_step,
- plugin_step,
- dirs_step,
- models_step,
- systemd_step,
- start_service_step,
- verify_step,
- swap_cleanup_step,
- ]
- if mode == "config":
- return [
- common_steps[0], # extract
- venv_step,
- verify_step,
- ]
- return common_steps
|