steps.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. # -*- coding: utf-8 -*-
  2. """
  3. Installations-Schritte pro Modus.
  4. Definiert gewichtete Schritte fuer den InstallRunner.
  5. """
  6. from __future__ import annotations
  7. from dataclasses import dataclass
  8. @dataclass
  9. class InstallationStep:
  10. """Ein einzelner Installationsschritt."""
  11. id: str
  12. name: str
  13. description: str
  14. weight: int
  15. command_fn: str # Name der Runner-Methode
  16. def get_steps(mode: str) -> list[InstallationStep]:
  17. """Gibt die Schrittliste fuer den jeweiligen Modus zurueck."""
  18. common_steps = [
  19. InstallationStep(
  20. id="extract",
  21. name="Quellcode entpacken",
  22. description="Entpacke .tar.gz nach Installationspfad",
  23. weight=10,
  24. command_fn="step_extract",
  25. ),
  26. InstallationStep(
  27. id="apt_packages",
  28. name="System-Pakete",
  29. description="Installiere benoetigte apt-Pakete",
  30. weight=25,
  31. command_fn="step_apt_packages",
  32. ),
  33. InstallationStep(
  34. id="hostname",
  35. name="Hostname setzen",
  36. description="Setze System-Hostname",
  37. weight=2,
  38. command_fn="step_hostname",
  39. ),
  40. ]
  41. wifi_step = InstallationStep(
  42. id="wifi_ap",
  43. name="WiFi-Hotspot",
  44. description="Konfiguriere hostapd, dnsmasq, dhcpcd und NAT",
  45. weight=8,
  46. command_fn="step_wifi_ap",
  47. )
  48. venv_step = InstallationStep(
  49. id="venv",
  50. name="Python venv",
  51. description="Erstelle venv und installiere Kern-Requirements",
  52. weight=15,
  53. command_fn="step_venv",
  54. )
  55. plugin_step = InstallationStep(
  56. id="plugin_deps",
  57. name="Plugin-Abhaengigkeiten",
  58. description="Installiere Requirements der ausgewaehlten Plugins",
  59. weight=20,
  60. command_fn="step_plugin_deps",
  61. )
  62. dirs_step = InstallationStep(
  63. id="directories",
  64. name="Verzeichnisse",
  65. description="Erstelle Verzeichnisse und setze Berechtigungen",
  66. weight=5,
  67. command_fn="step_directories",
  68. )
  69. systemd_step = InstallationStep(
  70. id="systemd",
  71. name="systemd-Service",
  72. description="Erstelle und aktiviere systemd-Service",
  73. weight=5,
  74. command_fn="step_systemd",
  75. )
  76. models_step = InstallationStep(
  77. id="download_models",
  78. name="Modelle herunterladen",
  79. description="Lade ML-Modelle herunter (optional)",
  80. weight=15,
  81. command_fn="step_download_models",
  82. )
  83. wifi_connect_step = InstallationStep(
  84. id="wifi_connect",
  85. name="WLAN-Verbindung",
  86. description="Konfiguriere WLAN-Verbindung (wpa_supplicant)",
  87. weight=5,
  88. command_fn="step_wifi_connect",
  89. )
  90. verify_step = InstallationStep(
  91. id="verify",
  92. name="Verifizierung",
  93. description="Pruefe installierte Abhaengigkeiten",
  94. weight=10,
  95. command_fn="step_verify",
  96. )
  97. if mode == "server":
  98. return [
  99. *common_steps,
  100. wifi_step,
  101. venv_step,
  102. plugin_step,
  103. dirs_step,
  104. models_step,
  105. systemd_step,
  106. verify_step,
  107. ]
  108. if mode == "client":
  109. return [
  110. common_steps[0], # extract
  111. common_steps[1], # apt
  112. common_steps[2], # hostname
  113. wifi_connect_step,
  114. venv_step,
  115. dirs_step,
  116. systemd_step,
  117. verify_step,
  118. ]
  119. if mode == "standalone":
  120. return [
  121. *common_steps,
  122. wifi_connect_step,
  123. venv_step,
  124. plugin_step,
  125. dirs_step,
  126. models_step,
  127. systemd_step,
  128. verify_step,
  129. ]
  130. if mode == "config":
  131. return [
  132. common_steps[0], # extract
  133. venv_step,
  134. verify_step,
  135. ]
  136. return common_steps