Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36816c57ef | ||
|
|
4a77a3ba32 | ||
|
|
7a1f2b164e | ||
|
|
682e9b4420 | ||
|
|
90e07aa310 | ||
|
|
c9ac0bf69b | ||
|
|
b70ebefb17 | ||
|
|
d90c27b8f8 | ||
|
|
8577cd24cd | ||
|
|
877903bd77 | ||
|
|
2b05d012ee |
+1
-1
@@ -1 +1 @@
|
||||
1.1.10
|
||||
1.2.1
|
||||
|
||||
+761
-51
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,281 @@
|
||||
"""
|
||||
TESM Lizenzsystem — gemeinsame Kryptographie- und Protokoll-Bausteine für
|
||||
Kundeninstanz (Client) UND Lizenzserver (Master). Beide Seiten importieren
|
||||
exakt dieselbe Datei (auf dem Master 1:1 mitkopiert) — Signieren und
|
||||
Verifizieren müssen bitidentisch funktionieren, jede Abweichung würde
|
||||
Lizenzen der jeweils anderen Seite unlesbar machen.
|
||||
|
||||
Vollständiges Design: siehe C:\\Users\\tim\\.claude\\plans\\toasty-twirling-hickey.md
|
||||
(Phase 0). Kurzfassung der Schlüsselhierarchie:
|
||||
|
||||
- Master-Signaturschlüssel (Ed25519): signiert Lizenzdateien selbst UND
|
||||
jede Aktivierungs-/Deaktivierungs-/Heartbeat-Antwort. Privater Teil bleibt
|
||||
ausschließlich auf dem Master, öffentlicher Teil steckt in jeder
|
||||
ausgestellten Lizenzdatei (ermöglicht rein OFFLINE verifizierbare
|
||||
Master-Antworten beim Kunden).
|
||||
- Pro-Lizenz-Schlüsselpaar (Ed25519, einmalig je Lizenz erzeugt): der
|
||||
private Teil reist in der Lizenzdatei zum Kunden und signiert dessen
|
||||
Aktivierungs-/Deaktivierungs-/Heartbeat-*Anfragen*; der öffentliche Teil
|
||||
bleibt beim Master in dessen Datenbank (ermöglicht dem Master, jede
|
||||
Anfrage einer bestimmten Lizenz zweifelsfrei zuzuordnen, ohne die
|
||||
ursprüngliche Aktivierung "live" gesehen haben zu müssen).
|
||||
|
||||
Ed25519 statt RSA: kleine Schlüssel/Signaturen (wichtig, da Aktivierungs-
|
||||
Anfragen/-Antworten für den Offline-Fall als von Hand kopierbarer Code
|
||||
dargestellt werden), fest vorgegebene, sichere Parameter (keine
|
||||
Padding-/Hash-Wahl wie bei RSA-PSS nötig).
|
||||
"""
|
||||
import base64
|
||||
import datetime
|
||||
import hashlib
|
||||
import json
|
||||
import socket
|
||||
import time
|
||||
import uuid
|
||||
|
||||
from cryptography.exceptions import InvalidSignature
|
||||
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
|
||||
|
||||
LICENSE_TYPES = ("trial", "standard", "custom", "enterprise")
|
||||
ALL_MODULES = ("dhcp", "fileshare", "maintenance")
|
||||
|
||||
GRACE_PERIOD_DAYS = 30 # nach Ablauf, bevor lizenzpflichtige Funktionen tatsächlich abgeschaltet werden
|
||||
EXPIRY_WARNING_DAYS = 30 # Vorlauf für die orange "läuft bald ab"-Anzeige
|
||||
HEARTBEAT_WARNING_DAYS = 14 # Nichterreichbarkeits-Hinweis (rein informativ, schaltet nie etwas ab)
|
||||
|
||||
|
||||
# ============================================================== Schlüssel ==
|
||||
|
||||
def generate_keypair():
|
||||
"""Erzeugt ein neues Ed25519-Schlüsselpaar. Rückgabe: (private_b64, public_b64)."""
|
||||
priv = Ed25519PrivateKey.generate()
|
||||
return _encode_private_key(priv), _encode_public_key(priv.public_key())
|
||||
|
||||
|
||||
def _encode_private_key(priv: Ed25519PrivateKey) -> str:
|
||||
return base64.urlsafe_b64encode(priv.private_bytes_raw()).decode("ascii")
|
||||
|
||||
|
||||
def _encode_public_key(pub: Ed25519PublicKey) -> str:
|
||||
return base64.urlsafe_b64encode(pub.public_bytes_raw()).decode("ascii")
|
||||
|
||||
|
||||
def _decode_private_key(s: str) -> Ed25519PrivateKey:
|
||||
return Ed25519PrivateKey.from_private_bytes(base64.urlsafe_b64decode(s.encode("ascii")))
|
||||
|
||||
|
||||
def _decode_public_key(s: str) -> Ed25519PublicKey:
|
||||
return Ed25519PublicKey.from_public_bytes(base64.urlsafe_b64decode(s.encode("ascii")))
|
||||
|
||||
|
||||
# ===================================================== Signieren/Prüfen ==
|
||||
|
||||
def _canonical_bytes(payload: dict) -> bytes:
|
||||
"""Deterministische JSON-Kodierung (sortierte Keys, kompakte Trenner) --
|
||||
Voraussetzung dafür, dass Signieren und Verifizieren exakt dieselben
|
||||
Bytes sehen, unabhängig von der Dict-Einfügereihenfolge."""
|
||||
return json.dumps(payload, sort_keys=True, separators=(",", ":")).encode("utf-8")
|
||||
|
||||
|
||||
def sign_payload(payload: dict, private_key_b64: str) -> str:
|
||||
priv = _decode_private_key(private_key_b64)
|
||||
return base64.urlsafe_b64encode(priv.sign(_canonical_bytes(payload))).decode("ascii")
|
||||
|
||||
|
||||
def verify_payload(payload: dict, signature_b64: str, public_key_b64: str) -> bool:
|
||||
"""Gibt bewusst nur True/False zurück (nie eine Exception nach außen) --
|
||||
ein Aufrufer soll "ungültig" nie mit einem Absturz verwechseln können."""
|
||||
try:
|
||||
pub = _decode_public_key(public_key_b64)
|
||||
pub.verify(base64.urlsafe_b64decode(signature_b64.encode("ascii")), _canonical_bytes(payload))
|
||||
return True
|
||||
except (InvalidSignature, ValueError, TypeError, KeyError):
|
||||
return False
|
||||
|
||||
|
||||
# ============================================================ Zeitformat ==
|
||||
|
||||
def _iso(ts: float) -> str:
|
||||
return datetime.datetime.fromtimestamp(ts, tz=datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
|
||||
def _parse_iso(s: str) -> float:
|
||||
return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=datetime.timezone.utc).timestamp()
|
||||
|
||||
|
||||
# ================================================================ Lizenz ==
|
||||
|
||||
def issue_license(*, customer, license_type, modules, valid_days,
|
||||
master_private_key_b64, master_public_key_b64,
|
||||
master_endpoint, vendor, license_id=None, now=None):
|
||||
"""Vom MASTER aufgerufen: erzeugt eine neue, signierte Lizenz samt
|
||||
frischem Pro-Lizenz-Schlüsselpaar.
|
||||
|
||||
Rückgabe: (license_file, license_pubkey) -- license_file ist die
|
||||
komplette, an den Kunden auszuhändigende Datei (inkl. dem PRIVATEN
|
||||
Lizenzschlüssel); license_pubkey ist NUR für die Master-Datenbank
|
||||
bestimmt (Verifikation künftiger Aktivierungs-/Heartbeat-Anfragen
|
||||
dieser Lizenz) und wird nicht an den Kunden weitergegeben."""
|
||||
if license_type not in LICENSE_TYPES:
|
||||
raise ValueError(f"Unbekannter Lizenztyp: {license_type!r} (erlaubt: {LICENSE_TYPES})")
|
||||
unknown = set(modules) - set(ALL_MODULES)
|
||||
if unknown:
|
||||
raise ValueError(f"Unbekannte Module: {sorted(unknown)} (erlaubt: {ALL_MODULES})")
|
||||
|
||||
license_priv, license_pub = generate_keypair()
|
||||
now = now if now is not None else time.time()
|
||||
payload = {
|
||||
"license_id": license_id or str(uuid.uuid4()),
|
||||
"customer": customer,
|
||||
"type": license_type,
|
||||
"modules": sorted(modules),
|
||||
"issued_at": _iso(now),
|
||||
"expires_at": _iso(now + valid_days * 86400),
|
||||
"license_pubkey": license_pub,
|
||||
"master_pubkey": master_public_key_b64,
|
||||
"master_endpoint": master_endpoint,
|
||||
"vendor": vendor,
|
||||
}
|
||||
signature = sign_payload(payload, master_private_key_b64)
|
||||
license_file = {**payload, "license_privkey": license_priv, "signature": signature}
|
||||
return license_file, license_pub
|
||||
|
||||
|
||||
def verify_license_file(license_file: dict) -> bool:
|
||||
"""Prüft die Master-Signatur über die Lizenz-Nutzdaten. license_privkey
|
||||
und signature selbst sind nicht Teil der signierten Nutzlast (die
|
||||
Signatur wurde ja gerade über den Rest gebildet, siehe issue_license)."""
|
||||
payload = {k: v for k, v in license_file.items() if k not in ("license_privkey", "signature")}
|
||||
return verify_payload(payload, license_file.get("signature", ""), license_file.get("master_pubkey", ""))
|
||||
|
||||
|
||||
def license_status(license_file: dict, now=None) -> dict:
|
||||
"""Berechnet den aktuellen Anzeige-/Gate-Status einer (bereits als
|
||||
signaturgültig geprüften!) Lizenz -- ruft NICHT selbst verify_license_file
|
||||
auf, das bleibt bewusst Sache des Aufrufers, damit hier niemand versehentlich
|
||||
den Status einer manipulierten Datei berechnet, ohne die Prüfung
|
||||
überhaupt gemacht zu haben."""
|
||||
now = now if now is not None else time.time()
|
||||
expires_at = _parse_iso(license_file["expires_at"])
|
||||
days_left = (expires_at - now) / 86400
|
||||
expired = days_left < 0
|
||||
days_since_expiry = -days_left if expired else 0.0
|
||||
grace_active = expired and days_since_expiry <= GRACE_PERIOD_DAYS
|
||||
modules_active = (not expired) or grace_active
|
||||
|
||||
return {
|
||||
"expired": expired,
|
||||
"days_left": days_left,
|
||||
"days_since_expiry": days_since_expiry,
|
||||
"expiring_soon": (not expired) and days_left <= EXPIRY_WARNING_DAYS,
|
||||
"grace_active": grace_active,
|
||||
"modules_active": modules_active,
|
||||
"modules": set(license_file.get("modules", [])) if modules_active else set(),
|
||||
"type": license_file.get("type"),
|
||||
"customer": license_file.get("customer"),
|
||||
"expires_at": license_file.get("expires_at"),
|
||||
}
|
||||
|
||||
|
||||
def heartbeat_stale_warning(last_heartbeat_ts, now=None) -> bool:
|
||||
"""True, wenn der letzte erfolgreiche Heartbeat HEARTBEAT_WARNING_DAYS
|
||||
oder länger zurückliegt. Rein informativ (siehe Moduldocstring) -- ein
|
||||
fehlender/alter Heartbeat schaltet nie ein Modul ab, nur das
|
||||
eingebettete Ablaufdatum selbst zählt dafür (siehe license_status)."""
|
||||
if last_heartbeat_ts is None:
|
||||
return False # noch nie verbunden gewesen ist der normale Ausgangszustand, kein Ausfall
|
||||
now = now if now is not None else time.time()
|
||||
return (now - last_heartbeat_ts) / 86400 >= HEARTBEAT_WARNING_DAYS
|
||||
|
||||
|
||||
# ========================================== Fingerprint (System-Bindung) ==
|
||||
|
||||
def system_fingerprint():
|
||||
"""Stabiler Identifikator dieses Hosts: /etc/machine-id (von systemd bei
|
||||
der Erstinstallation einmalig erzeugt, übersteht Reboots und normale
|
||||
Updates) kombiniert mit dem Hostnamen, gehasht damit die rohe
|
||||
machine-id nie im Klartext übertragen/gespeichert wird. Unter
|
||||
Windows/ohne /etc/machine-id fällt dies auf den Hostnamen allein
|
||||
zurück (nur für lokale Tests relevant, Produktivsysteme sind Linux)."""
|
||||
machine_id = ""
|
||||
try:
|
||||
with open("/etc/machine-id", "r", encoding="utf-8") as f:
|
||||
machine_id = f.read().strip()
|
||||
except OSError:
|
||||
pass
|
||||
raw = f"{machine_id}:{socket.gethostname()}".encode("utf-8")
|
||||
return hashlib.sha256(raw).hexdigest()
|
||||
|
||||
|
||||
# ============================ Aktivierung / Deaktivierung / Heartbeat =====
|
||||
# Ein Protokoll, zwei Transportwege: online automatisch per HTTPS-API,
|
||||
# offline exakt dasselbe Anfrage/Antwort-Paar als von Hand kopierbarer Code
|
||||
# (encode_code/decode_code) -- der Master ist dadurch in BEIDEN Fällen die
|
||||
# einzige Quelle der Wahrheit dafür, an welches System eine Lizenz gerade
|
||||
# gebunden ist, siehe Plan-Abschnitt "Warum das die Doppelnutzung wirksam
|
||||
# verhindert".
|
||||
|
||||
def build_client_request(action, license_file, nonce=None) -> dict:
|
||||
"""Vom CLIENT aufgerufen: erzeugt eine signierte Anfrage (action:
|
||||
"activate"/"deactivate"/"heartbeat"). Das Ergebnis ist unverändert für
|
||||
einen Online-API-Aufruf nutzbar; für den Offline-Fall wird es
|
||||
zusätzlich mit encode_code() in einen kopierbaren Code umgewandelt."""
|
||||
if action not in ("activate", "deactivate", "heartbeat"):
|
||||
raise ValueError(f"Unbekannte Aktion: {action!r}")
|
||||
payload = {
|
||||
"license_id": license_file["license_id"],
|
||||
"fingerprint": system_fingerprint(),
|
||||
"action": action,
|
||||
"nonce": nonce or uuid.uuid4().hex,
|
||||
"timestamp": _iso(time.time()),
|
||||
}
|
||||
signature = sign_payload(payload, license_file["license_privkey"])
|
||||
return {**payload, "signature": signature}
|
||||
|
||||
|
||||
def verify_client_request(request: dict, license_public_key_b64: str) -> bool:
|
||||
"""Vom MASTER aufgerufen: prüft eine Client-Anfrage gegen den bei
|
||||
Ausstellung dieser Lizenz in der Master-DB gespeicherten Public-Key."""
|
||||
payload = {k: v for k, v in request.items() if k != "signature"}
|
||||
return verify_payload(payload, request.get("signature", ""), license_public_key_b64)
|
||||
|
||||
|
||||
def build_master_response(action, license_id, fingerprint, master_private_key_b64,
|
||||
status="ok", license_update=None, now=None) -> dict:
|
||||
"""Vom MASTER aufgerufen: erzeugt eine signierte Antwort/Bestätigung
|
||||
(z.B. "activated", "deactivated", oder das Ergebnis eines Heartbeats).
|
||||
license_update: optional eine komplette, neu signierte Lizenzdatei
|
||||
(z.B. nach nachträglicher Modul-Änderung durch den Admin) -- der Client
|
||||
übernimmt sie nur nach eigener, erfolgreicher Signaturprüfung."""
|
||||
payload = {
|
||||
"license_id": license_id,
|
||||
"fingerprint": fingerprint,
|
||||
"action": action,
|
||||
"status": status,
|
||||
"timestamp": _iso(now if now is not None else time.time()),
|
||||
}
|
||||
if license_update is not None:
|
||||
payload["license_update"] = license_update
|
||||
signature = sign_payload(payload, master_private_key_b64)
|
||||
return {**payload, "signature": signature}
|
||||
|
||||
|
||||
def verify_master_response(response: dict, master_public_key_b64: str) -> bool:
|
||||
"""Vom CLIENT aufgerufen: prüft eine Master-Antwort komplett OFFLINE
|
||||
gegen den in der eigenen Lizenzdatei eingebetteten master_pubkey."""
|
||||
payload = {k: v for k, v in response.items() if k != "signature"}
|
||||
return verify_payload(payload, response.get("signature", ""), master_public_key_b64)
|
||||
|
||||
|
||||
# ==================================================== Codes für Offline ==
|
||||
|
||||
def encode_code(data: dict) -> str:
|
||||
"""Kodiert ein Anfrage-/Antwort-dict als kompakten, per Copy-Paste
|
||||
übertragbaren Code (Base64 einer kanonischen JSON-Darstellung, keine
|
||||
Zeilenumbrüche/Sonderzeichen, damit Kopieren aus/in ein Textfeld nichts
|
||||
kaputt macht)."""
|
||||
return base64.urlsafe_b64encode(_canonical_bytes(data)).decode("ascii")
|
||||
|
||||
|
||||
def decode_code(code: str) -> dict:
|
||||
return json.loads(base64.urlsafe_b64decode(code.strip().encode("ascii")).decode("utf-8"))
|
||||
@@ -574,6 +574,22 @@ button { font-family: inherit; }
|
||||
70% { box-shadow: 0 0 0 6px rgba(47,208,122,0); }
|
||||
100% { box-shadow: 0 0 0 0 rgba(47,208,122,0); }
|
||||
}
|
||||
/* Lizenz-Topbar-Pill: pulse-dot ist fest auf Grün (Erfolg) verdrahtet --
|
||||
eigene Varianten für die rot/orange blinkenden Lizenz-Zustände, sonst
|
||||
würde die Halo-Animation weiter grün pulsieren, egal welche
|
||||
Hintergrundfarbe der Punkt selbst per Inline-Style bekommt. */
|
||||
.timer-pill .dot.dot--blink-danger { animation: pulse-dot-danger 1.4s infinite; }
|
||||
.timer-pill .dot.dot--blink-warning { animation: pulse-dot-warning 1.4s infinite; }
|
||||
@keyframes pulse-dot-danger {
|
||||
0% { box-shadow: 0 0 0 0 rgba(240,71,92,0.5); }
|
||||
70% { box-shadow: 0 0 0 6px rgba(240,71,92,0); }
|
||||
100% { box-shadow: 0 0 0 0 rgba(240,71,92,0); }
|
||||
}
|
||||
@keyframes pulse-dot-warning {
|
||||
0% { box-shadow: 0 0 0 0 rgba(245,166,35,0.5); }
|
||||
70% { box-shadow: 0 0 0 6px rgba(245,166,35,0); }
|
||||
100% { box-shadow: 0 0 0 0 rgba(245,166,35,0); }
|
||||
}
|
||||
|
||||
.timer-pill-refresh {
|
||||
display: inline-flex; align-items: center; justify-content: center;
|
||||
|
||||
@@ -129,6 +129,12 @@
|
||||
</button>
|
||||
{% endif %}
|
||||
</span>
|
||||
{% if license_topbar %}
|
||||
<a href="{{ url_for('settings_license') }}" class="timer-pill" title="{{ license_topbar.text }}" style="text-decoration:none;">
|
||||
<span class="dot {% if license_topbar.blink %}dot--blink-{{ license_topbar.level }}{% endif %}"
|
||||
style="{% if not license_topbar.blink %}animation:none; box-shadow:none;{% endif %} background:{{ 'var(--danger)' if license_topbar.level == 'danger' else 'var(--warning)' }};"></span>{{ license_topbar.text }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if dhcp_topbar_active is not none %}
|
||||
<span class="timer-pill" title="DHCP-Dienst: {{ 'aktiv' if dhcp_topbar_active else 'inaktiv' }}">
|
||||
<span class="dot" style="animation:none; background:{{ 'var(--success)' if dhcp_topbar_active else 'var(--danger)' }}; box-shadow:none;"></span>DHCP
|
||||
|
||||
@@ -17,6 +17,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if not license_active() %}
|
||||
<div class="notice-banner notice-banner--warning" style="margin-bottom:14px;">
|
||||
Wiederherstellen und endgültiges Löschen sind nur mit gültiger Lizenz verfügbar — siehe
|
||||
<a href="{{ url_for('settings_license') }}">Lizenz</a>. Ansehen ist weiterhin uneingeschränkt möglich.
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div style="display:flex; flex-direction:column; gap:16px;">
|
||||
|
||||
<div class="card card-pad">
|
||||
@@ -44,7 +51,7 @@
|
||||
<td class="mono">{{ d['ip'] }}</td>
|
||||
<td class="text-faint" style="font-size:12px;">{{ d['deleted_at'] }}</td>
|
||||
<td>
|
||||
{% if current_user.has_permission('papierkorb.edit') %}
|
||||
{% if current_user.has_permission('papierkorb.edit') and license_active() %}
|
||||
<div class="row-actions">
|
||||
<form method="post" action="{{ url_for('restore_device', mac=d['mac']) }}">
|
||||
<button type="submit" class="btn btn-sm btn-secondary">Wiederherstellen</button>
|
||||
@@ -92,7 +99,7 @@
|
||||
<td class="mono">{{ s['ip'] }}</td>
|
||||
<td class="text-faint" style="font-size:12px;">{{ s['deleted_at'] }}</td>
|
||||
<td>
|
||||
{% if current_user.has_permission('papierkorb.edit') %}
|
||||
{% if current_user.has_permission('papierkorb.edit') and license_active() %}
|
||||
<div class="row-actions">
|
||||
<form method="post" action="{{ url_for('restore_switch', hostname=s['hostname']) }}">
|
||||
<button type="submit" class="btn btn-sm btn-secondary">Wiederherstellen</button>
|
||||
@@ -140,7 +147,7 @@
|
||||
<td class="mono">{{ c['username'] }}</td>
|
||||
<td class="text-faint" style="font-size:12px;">{{ c['deleted_at'] }}</td>
|
||||
<td>
|
||||
{% if current_user.has_permission('papierkorb.edit') %}
|
||||
{% if current_user.has_permission('papierkorb.edit') and license_active() %}
|
||||
<div class="row-actions">
|
||||
<form method="post" action="{{ url_for('restore_credential', cred_id=c['id']) }}">
|
||||
<button type="submit" class="btn btn-sm btn-secondary">Wiederherstellen</button>
|
||||
@@ -189,7 +196,7 @@
|
||||
<td class="text-dim">{{ full_name or '—' }}</td>
|
||||
<td class="text-faint" style="font-size:12px;">{{ u['deleted_at'] }}</td>
|
||||
<td>
|
||||
{% if current_user.has_permission('papierkorb.edit') %}
|
||||
{% if current_user.has_permission('papierkorb.edit') and license_active() %}
|
||||
<div class="row-actions">
|
||||
<form method="post" action="{{ url_for('restore_user', user_id=u['id']) }}">
|
||||
<button type="submit" class="btn btn-sm btn-secondary">Wiederherstellen</button>
|
||||
@@ -235,7 +242,7 @@
|
||||
<td class="cell-name">{{ g['name'] }}</td>
|
||||
<td class="text-faint" style="font-size:12px;">{{ g['deleted_at'] }}</td>
|
||||
<td>
|
||||
{% if current_user.has_permission('papierkorb.edit') %}
|
||||
{% if current_user.has_permission('papierkorb.edit') and license_active() %}
|
||||
<div class="row-actions">
|
||||
<form method="post" action="{{ url_for('restore_group', group_id=g['id']) }}">
|
||||
<button type="submit" class="btn btn-sm btn-secondary">Wiederherstellen</button>
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
<div class="hint">Name und Zeitzone dieses Hosts.</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if current_user.has_permission('settings_system.edit') %}
|
||||
{% set can_edit_host = current_user.has_permission('settings_system.edit') %}
|
||||
{% if can_edit_host %}
|
||||
<form method="post">
|
||||
<div class="field">
|
||||
<label for="hostname">Hostname</label>
|
||||
@@ -40,7 +41,18 @@
|
||||
Zeitzone setzen
|
||||
</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<div class="field">
|
||||
<label>Hostname</label>
|
||||
<input type="text" value="{{ current_hostname or '' }}" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Zeitzone</label>
|
||||
<input type="text" value="{{ current_timezone or '' }}" disabled>
|
||||
</div>
|
||||
{% endif %}
|
||||
<hr style="border:none; border-top:1px solid var(--border-soft); margin:18px 0;">
|
||||
{% if can_edit_host and license_active() %}
|
||||
<form method="post">
|
||||
<div class="field">
|
||||
<label for="interval">Prüfintervall (Minuten) {{ hi.hint_icon("Wie oft Geräte auf Erreichbarkeit geprüft werden. Der Hintergrund-Dienst (tesm-check.service) wird nach dem Speichern automatisch neu gestartet.", "Prüfintervall (Minuten)") }}</label>
|
||||
@@ -52,18 +64,16 @@
|
||||
</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<div class="field">
|
||||
<label>Hostname</label>
|
||||
<input type="text" value="{{ current_hostname or '' }}" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Zeitzone</label>
|
||||
<input type="text" value="{{ current_timezone or '' }}" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Prüfintervall (Minuten)</label>
|
||||
<input type="number" value="{{ interval }}" disabled>
|
||||
<div class="field-hint">Nur Lesezugriff — für Änderungen fehlt das Recht „Systemeinstellungen ändern“.</div>
|
||||
<div class="field-hint">
|
||||
{% if not can_edit_host %}
|
||||
Nur Lesezugriff — für Änderungen fehlt das Recht „Systemeinstellungen ändern“.
|
||||
{% else %}
|
||||
Nur mit gültiger Lizenz änderbar — siehe <a href="{{ url_for('settings_license') }}">Lizenz</a>.
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
data-confirm="Ausgewählte Kategorien wirklich importieren? Bestehende Einträge mit gleichem Namen/Hostname/MAC/Benutzernamen werden überschrieben.">
|
||||
<input type="hidden" name="import_token" value="{{ import_preview.token }}">
|
||||
<div class="field">
|
||||
<label>Was importieren? {{ hi.hint_icon("AD/LDAP-Benutzerkonten sind hiervon unberührt — sie werden über Active Directory/Windows verwaltet, nicht über diese App, und beim nächsten Login automatisch neu angelegt.", "Was importieren?") }}</label>
|
||||
<label>Was importieren?</label>
|
||||
<div class="check-list">
|
||||
{% for s in import_preview.sections %}
|
||||
<label class="check-row">
|
||||
@@ -35,7 +35,7 @@
|
||||
{% if s.key not in admin_only_sections or current_user.is_admin %}checked{% endif %}
|
||||
{% if s.admin_only and not current_user.is_admin %}disabled{% endif %}>
|
||||
{{ s.label }} <span class="text-faint">({{ s.count }})</span>
|
||||
{% if s.admin_only %}<span class="pill user" style="font-size:10px; padding:2px 7px;">Nur Admin</span>{% endif %}
|
||||
{% if export_section_hints and s.key in export_section_hints %}{{ hi.hint_icon(export_section_hints[s.key], s.label) }}{% endif %}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@@ -71,10 +71,10 @@
|
||||
<div class="hint">Ausgewählte Kategorien verschlüsselt sichern.</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if current_user.has_permission('settings_importexport.export') %}
|
||||
{% if current_user.has_permission('settings_importexport.export') and license_export_allowed() %}
|
||||
<form method="post" action="{{ url_for('export_data') }}">
|
||||
<div class="field">
|
||||
<label>Was exportieren? {{ hi.hint_icon("AD/LDAP-Benutzerkonten werden nie mitexportiert — sie werden über Active Directory/Windows verwaltet (nicht über diese App) und legen sich beim nächsten Login automatisch wieder an. Beim LDAP-Export wird lediglich das Bind-Konto (verschlüsselt) sowie die Gruppenzuordnungen gesichert.", "Was exportieren?") }}</label>
|
||||
<label>Was exportieren?</label>
|
||||
<div class="check-list">
|
||||
{% for key, label in export_sections %}
|
||||
<label class="check-row">
|
||||
@@ -82,7 +82,7 @@
|
||||
{% if key not in admin_only_sections or current_user.is_admin %}checked{% endif %}
|
||||
{% if key in admin_only_sections and not current_user.is_admin %}disabled{% endif %}>
|
||||
{{ label }}
|
||||
{% if key in admin_only_sections %}<span class="pill user" style="font-size:10px; padding:2px 7px;">Nur Admin</span>{% endif %}
|
||||
{% if export_section_hints and key in export_section_hints %}{{ hi.hint_icon(export_section_hints[key], label) }}{% endif %}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@@ -96,6 +96,8 @@
|
||||
Export herunterladen
|
||||
</button>
|
||||
</form>
|
||||
{% elif current_user.has_permission('settings_importexport.export') %}
|
||||
<p class="text-faint" style="font-size:12.5px;">Für den Export ist keine gültige Lizenz vorhanden — siehe <a href="{{ url_for('settings_license') }}">Lizenz</a>.</p>
|
||||
{% else %}
|
||||
<p class="text-faint" style="font-size:12.5px;">Für den Export fehlt das Recht „Daten exportieren“.</p>
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
{% set active_page = "settings_ldap" %}
|
||||
{% set can_edit = current_user.has_permission('settings_ldap.edit') %}
|
||||
{% set can_edit = current_user.has_permission('settings_ldap.edit') and license_active() %}
|
||||
{% block page_title %}LDAP / Active Directory{% endblock %}
|
||||
{% block page_sub %}<div class="topbar-sub">Anmeldung mit dem Domänen-Passwort, zusätzlich zu lokalen Konten</div>{% endblock %}
|
||||
|
||||
@@ -96,7 +96,13 @@
|
||||
</form>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<p class="text-faint" style="font-size:12.5px;">Für Änderungen fehlt das Recht „LDAP/AD-Konfiguration speichern“.</p>
|
||||
<p class="text-faint" style="font-size:12.5px;">
|
||||
{% if current_user.has_permission('settings_ldap.edit') %}
|
||||
Nur mit Lizenz verfügbar — siehe <a href="{{ url_for('settings_license') }}">Lizenz</a>.
|
||||
{% else %}
|
||||
Für Änderungen fehlt das Recht „LDAP/AD-Konfiguration speichern“.
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
{% extends "base.html" %}
|
||||
{% set active_page = "settings_license" %}
|
||||
{% set can_edit = current_user.has_permission('settings_system.edit') %}
|
||||
{% block page_title %}Lizenz{% endblock %}
|
||||
{% block page_sub %}<div class="topbar-sub">Lizenzstatus, Module und Aktivierung dieses Systems</div>{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% import "_hint_icon.html" as hi %}
|
||||
<div class="settings-grid">
|
||||
|
||||
<div class="card card-pad">
|
||||
<div class="section-head" style="margin-bottom:16px;">
|
||||
<div>
|
||||
<h2 style="font-size:16px;">Status</h2>
|
||||
<div class="hint">Aktuell installierte Lizenz und ihr Zustand.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if license_error %}
|
||||
<div class="notice-banner notice-banner--warning" style="margin-bottom:14px;">{{ license_error }}</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not license_file %}
|
||||
<p class="text-faint" style="font-size:12.5px;">Keine Lizenzdatei vorhanden — bitte unten eine Lizenzdatei hochladen.</p>
|
||||
{% else %}
|
||||
<div class="field">
|
||||
<label>Kunde</label>
|
||||
<input type="text" value="{{ license_file.customer.name or '' }}" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Lizenztyp</label>
|
||||
<input type="text" value="{{ {'trial': 'Trial', 'standard': 'Standard', 'custom': 'Custom', 'enterprise': 'Enterprise'}.get(license_file.type, license_file.type) }}" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Module {{ hi.hint_icon("Zusätzlich zu den immer verfügbaren Standard-Funktionen freigeschaltete Vollmodule.", "Module") }}</label>
|
||||
<input type="text" value="{{ (license_file.modules or [])|join(', ') if license_file.modules else 'keine' }}" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Ausgestellt am</label>
|
||||
<input type="text" value="{{ license_file.issued_at or '' }}" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Läuft ab am</label>
|
||||
<input type="text" value="{{ license_file.expires_at or '' }}" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Aktivierungsstatus</label>
|
||||
<input type="text" value="{{ 'Aktiviert' if license_is_activated else 'Nicht aktiviert' }}" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Letzter Heartbeat</label>
|
||||
<input type="text" value="{{ license_last_heartbeat_at or 'noch nie' }}" disabled>
|
||||
</div>
|
||||
{% if license_last_error %}
|
||||
<div class="field">
|
||||
<label>Letzter Fehler</label>
|
||||
<input type="text" value="{{ license_last_error }}" disabled>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="field">
|
||||
<label>System-Fingerabdruck {{ hi.hint_icon("Eindeutiger Identifikator dieses Systems, an den die Lizenz bei der Aktivierung gebunden wird.", "System-Fingerabdruck") }}</label>
|
||||
<input type="text" class="mono" value="{{ license_fingerprint }}" disabled>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if license_file and license_valid %}
|
||||
<div class="card card-pad">
|
||||
<div class="section-head" style="margin-bottom:16px;">
|
||||
<div>
|
||||
<h2 style="font-size:16px;">Aktivierung</h2>
|
||||
<div class="hint">
|
||||
Ein Protokoll, zwei Wege: automatisch online, oder — falls kein Netzwerkzugriff auf den
|
||||
Lizenzserver besteht — per Code manuell mit dem Lizenzserver-Administrator ausgetauscht.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if not can_edit %}
|
||||
<p class="text-faint" style="font-size:12.5px;">Für Aktivierung/Deaktivierung fehlt das Recht „Systemeinstellungen ändern“.</p>
|
||||
|
||||
{% elif pending_action %}
|
||||
<p class="text-faint" style="font-size:12.5px; margin-bottom:10px;">
|
||||
Offene {{ 'Aktivierungs' if pending_action.action == 'activate' else 'Deaktivierungs' }}-Anfrage — folgenden Code
|
||||
beim Lizenzserver-Administrator eingeben:
|
||||
</p>
|
||||
<div class="field">
|
||||
<textarea class="mono" rows="4" readonly onclick="this.select()" style="width:100%; resize:vertical;">{{ pending_code }}</textarea>
|
||||
</div>
|
||||
<form method="post" action="{{ url_for('license_activate_confirm' if pending_action.action == 'activate' else 'license_deactivate_confirm') }}">
|
||||
<div class="field">
|
||||
<label for="confirmation_code">Bestätigungscode vom Lizenzserver</label>
|
||||
<textarea class="mono" name="confirmation_code" id="confirmation_code" rows="4" style="width:100%; resize:vertical;" required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-block">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>
|
||||
Code bestätigen
|
||||
</button>
|
||||
</form>
|
||||
<form method="post" action="{{ url_for('license_activate' if pending_action.action == 'activate' else 'license_deactivate') }}" style="margin-top:10px;">
|
||||
<button type="submit" class="btn btn-secondary btn-block">Erneut online versuchen</button>
|
||||
</form>
|
||||
|
||||
{% elif license_is_activated %}
|
||||
<p class="text-faint" style="font-size:12.5px; margin-bottom:10px;">
|
||||
Lizenz ist aktiviert. Bei einem Systemwechsel zuerst hier deaktivieren — danach kann der Kunde sich beim
|
||||
Anbieter selbst eine neue Lizenz für das neue System ausstellen lassen.
|
||||
</p>
|
||||
<form method="post" action="{{ url_for('license_deactivate') }}"
|
||||
data-confirm="Lizenz wirklich deaktivieren? Alle lizenzpflichtigen Module/Funktionen werden danach sofort inaktiv (Export bleibt bis zur nächsten Aktivierung möglich).">
|
||||
<button type="submit" class="btn btn-danger btn-block">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M15 9l-6 6M9 9l6 6"/></svg>
|
||||
Lizenz deaktivieren (Systemwechsel)
|
||||
</button>
|
||||
</form>
|
||||
|
||||
{% else %}
|
||||
<form method="post" action="{{ url_for('license_activate') }}">
|
||||
<button type="submit" class="btn btn-primary btn-block">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>
|
||||
Jetzt aktivieren
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="card card-pad">
|
||||
<div class="section-head" style="margin-bottom:16px;">
|
||||
<div>
|
||||
<h2 style="font-size:16px;">Lizenzdatei hochladen</h2>
|
||||
<div class="hint">Vom Anbieter erhaltene Lizenzdatei einspielen — muss danach noch aktiviert werden.</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if can_edit %}
|
||||
<form method="post" action="{{ url_for('license_upload') }}" enctype="multipart/form-data">
|
||||
<div class="field">
|
||||
<label for="license_file">Lizenzdatei</label>
|
||||
<input type="file" name="license_file" id="license_file" accept=".json,.lic" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-secondary btn-block">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><path d="M17 8l-5-5-5 5"/><path d="M12 3v12"/></svg>
|
||||
Hochladen
|
||||
</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<p class="text-faint" style="font-size:12.5px;">Für den Upload fehlt das Recht „Systemeinstellungen ändern“.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if license_file and license_file.vendor %}
|
||||
<div class="card card-pad">
|
||||
<div class="section-head" style="margin-bottom:16px;">
|
||||
<div>
|
||||
<h2 style="font-size:16px;">Anbieter</h2>
|
||||
<div class="hint">Kontakt für Rückfragen zu dieser Lizenz.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Firma</label>
|
||||
<input type="text" value="{{ license_file.vendor.name or '' }}" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Telefon</label>
|
||||
<input type="text" value="{{ license_file.vendor.phone or '' }}" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>E-Mail</label>
|
||||
<input type="text" value="{{ license_file.vendor.email or '' }}" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Anschrift</label>
|
||||
<input type="text" value="{{ license_file.vendor.address or '' }}" disabled>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
{% set active_page = "settings_nginx" %}
|
||||
{% set can_edit = current_user.has_permission('settings_nginx.edit') %}
|
||||
{% set can_edit = current_user.has_permission('settings_nginx.edit') and license_active() %}
|
||||
{% block page_title %}NGINX{% endblock %}
|
||||
{% block page_sub %}<div class="topbar-sub">Reverse-Proxy: Domain, Ports, SSL/HSTS und Zertifikat</div>{% endblock %}
|
||||
|
||||
@@ -73,7 +73,13 @@
|
||||
</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<p class="text-faint" style="font-size:12.5px;">Für Änderungen fehlt das Recht „NGINX ändern“.</p>
|
||||
<p class="text-faint" style="font-size:12.5px;">
|
||||
{% if current_user.has_permission('settings_nginx.edit') %}
|
||||
Nur mit Lizenz verfügbar — siehe <a href="{{ url_for('settings_license') }}">Lizenz</a>.
|
||||
{% else %}
|
||||
Für Änderungen fehlt das Recht „NGINX ändern“.
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -177,7 +183,13 @@
|
||||
<p class="text-faint" style="font-size:11.5px;">SSL muss zuerst deaktiviert werden, bevor das Zertifikat entfernt werden kann.</p>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<p class="text-faint" style="font-size:12.5px;">Für Anfordern/Upload/Entfernen fehlt das Recht „NGINX ändern“.</p>
|
||||
<p class="text-faint" style="font-size:12.5px;">
|
||||
{% if current_user.has_permission('settings_nginx.edit') %}
|
||||
Nur mit Lizenz verfügbar — siehe <a href="{{ url_for('settings_license') }}">Lizenz</a>.
|
||||
{% else %}
|
||||
Für Anfordern/Upload/Entfernen fehlt das Recht „NGINX ändern“.
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -34,11 +34,8 @@ REPO_NAME="${TESM_REPO_NAME:-tesm}"
|
||||
RELEASE_TAG="${TESM_RELEASE_TAG:-latest}"
|
||||
GITEA_USER="${TESM_GITEA_USER:-}"
|
||||
GITEA_TOKEN="${TESM_GITEA_TOKEN:-}"
|
||||
PACKAGE_NAME="tesm-${RELEASE_TAG}.tar.gz"
|
||||
DOWNLOAD_URL="${GITEA_BASE}/${REPO_OWNER}/${REPO_NAME}/releases/download/${RELEASE_TAG}/${PACKAGE_NAME}"
|
||||
|
||||
WORK_DIR="/tmp/tesm-update-$(date +%s)"
|
||||
PACKAGE_FILE="$WORK_DIR/${PACKAGE_NAME}"
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
@@ -50,6 +47,38 @@ if [ "$(id -u)" -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CURL_AUTH=()
|
||||
if [ -n "$GITEA_USER" ] && [ -n "$GITEA_TOKEN" ]; then
|
||||
CURL_AUTH=(-u "${GITEA_USER}:${GITEA_TOKEN}")
|
||||
fi
|
||||
|
||||
# ---- "latest" IMMER über die Gitea-API auflösen, nie als Literal in die
|
||||
# Download-URL einsetzen ----
|
||||
# Live reproduziert: /releases/download/latest/tesm-latest.tar.gz liefert
|
||||
# HTTP 200 -- aber keinen echten Release-Asset, sondern (weil kein Asset
|
||||
# exakt "tesm-latest.tar.gz" heißt) Giteas automatisch generiertes
|
||||
# Quellcode-Archiv des AKTUELLEN Default-Branch-Stands, kommentarlos und
|
||||
# ohne Fehlermeldung. Ohne diesen Auflösungsschritt würde ein einfaches
|
||||
# "sudo ./update.sh" (ohne explizites TESM_RELEASE_TAG) also lautlos einen
|
||||
# unversionierten, potenziell halbfertigen Zwischenstand installieren
|
||||
# statt des tatsächlich neuesten Releases.
|
||||
if [ "$RELEASE_TAG" == "latest" ]; then
|
||||
echo -e "${RED}→${NC} Ermittle aktuellsten Release-Tag von ${GITEA_BASE}/${REPO_OWNER}/${REPO_NAME}..."
|
||||
RESOLVED_TAG="$(curl -fsSL "${CURL_AUTH[@]}" "${GITEA_BASE}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest" \
|
||||
| python3 -c "import json,sys; print(json.load(sys.stdin).get('tag_name',''))" 2>/dev/null)"
|
||||
if [ -z "$RESOLVED_TAG" ]; then
|
||||
echo "✖ Konnte den aktuellsten Release-Tag nicht über die Gitea-API ermitteln -- Abbruch." >&2
|
||||
echo " (Alternative: TESM_RELEASE_TAG=vX.Y.Z explizit setzen.)" >&2
|
||||
exit 1
|
||||
fi
|
||||
RELEASE_TAG="$RESOLVED_TAG"
|
||||
echo -e "${GREEN}✔${NC} Aktuellster Release ist ${RELEASE_TAG}."
|
||||
fi
|
||||
|
||||
PACKAGE_NAME="tesm-${RELEASE_TAG}.tar.gz"
|
||||
DOWNLOAD_URL="${GITEA_BASE}/${REPO_OWNER}/${REPO_NAME}/releases/download/${RELEASE_TAG}/${PACKAGE_NAME}"
|
||||
PACKAGE_FILE="$WORK_DIR/${PACKAGE_NAME}"
|
||||
|
||||
echo -e "${YELLOW}============================================================================${NC}"
|
||||
echo -e "${YELLOW} TESM Update/Reinstall — Release \"${RELEASE_TAG}\"${NC}"
|
||||
echo -e "${YELLOW}============================================================================${NC}"
|
||||
@@ -68,16 +97,22 @@ fi
|
||||
|
||||
echo -e "${RED}→${NC} Lade Paket von ${DOWNLOAD_URL}..."
|
||||
mkdir -p "$WORK_DIR"
|
||||
CURL_AUTH=()
|
||||
if [ -n "$GITEA_USER" ] && [ -n "$GITEA_TOKEN" ]; then
|
||||
CURL_AUTH=(-u "${GITEA_USER}:${GITEA_TOKEN}")
|
||||
fi
|
||||
curl -fsSL "${CURL_AUTH[@]}" -o "$PACKAGE_FILE" "$DOWNLOAD_URL"
|
||||
echo -e "${GREEN}✔${NC} Paket heruntergeladen ($(du -h "$PACKAGE_FILE" | cut -f1))."
|
||||
|
||||
echo -e "${RED}→${NC} Entpacke Paket..."
|
||||
mkdir -p "$WORK_DIR/pkg"
|
||||
tar xzf "$PACKAGE_FILE" -C "$WORK_DIR/pkg" --strip-components=1
|
||||
|
||||
# Absicherung gegen genau das oben beschriebene Fallback-Verhalten: statt
|
||||
# eines späten, kryptischen "No such file or directory" beim Aufruf von
|
||||
# install.sh hier klar benennen, WENN das heruntergeladene Paket nicht das
|
||||
# erwartete ist (z.B. weil sich Giteas Verhalten wieder ändert).
|
||||
if [ ! -f "$WORK_DIR/pkg/install.sh" ]; then
|
||||
echo "✖ Entpacktes Paket enthält kein install.sh -- vermutlich wurde nicht das" >&2
|
||||
echo " erwartete Release-Asset heruntergeladen (siehe ${DOWNLOAD_URL})." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo -e "${GREEN}✔${NC} Paket entpackt."
|
||||
|
||||
echo -e "${RED}→${NC} Starte install.sh aus dem Paket..."
|
||||
|
||||
@@ -80,6 +80,7 @@ EOF
|
||||
function check_device() {
|
||||
local rpi_ip=$1 dev_name=$2 switch_ip=$3 switch_ssh_port=$4
|
||||
local switch_hostname=$5 switch_port=$6 switch_user=$7 switch_pass=$8
|
||||
local license_active=$9
|
||||
|
||||
if ping -c 1 -W 2 "$rpi_ip" &> /dev/null; then
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') $dev_name ist erreichbar!" >> "$LOGFILE"
|
||||
@@ -92,6 +93,15 @@ function check_device() {
|
||||
return
|
||||
fi
|
||||
|
||||
# Automatischer PoE-Neustart bei Ausfall ist ein lizenzpflichtiges
|
||||
# Feature (siehe Lizenzsystem) -- der manuelle Neustart-Button im
|
||||
# Dashboard (manual_restart() weiter unten) ruft disable_poe/enable_poe
|
||||
# dagegen IMMER direkt auf und bleibt davon bewusst unberührt.
|
||||
if [ "$license_active" != "1" ]; then
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') $dev_name: automatischer PoE-Neustart übersprungen -- keine gültige Lizenz." >> "$LOGFILE"
|
||||
return
|
||||
fi
|
||||
|
||||
if ! disable_poe "$switch_ip" "$switch_port" "$switch_user" "$switch_pass" "$switch_ssh_port"; then
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') $dev_name: Switch $switch_hostname nicht erreichbar oder Kommando abgelehnt — PoE-Deaktivierung fehlgeschlagen, kein Neustart durchgeführt." >> "$LOGFILE"
|
||||
return
|
||||
@@ -146,8 +156,19 @@ fi
|
||||
while true; do
|
||||
echo "--------------------------------------------------------------------" >> "$LOGFILE"
|
||||
|
||||
# Einmal pro Schleifendurchlauf gelesen (wie SLEEP oben beim Skriptstart),
|
||||
# nicht pro Gerät -- reicht als Shell-Variable an check_device() durch.
|
||||
LICENSE_ACTIVE=$(python3 - <<'END'
|
||||
import sys
|
||||
sys.path.insert(0, "/srv/tesm")
|
||||
from app import license_active
|
||||
print("1" if license_active() else "0")
|
||||
END
|
||||
)
|
||||
LICENSE_ACTIVE=${LICENSE_ACTIVE:-0}
|
||||
|
||||
while IFS='|' read -r rpi_ip dev_name switch_ip switch_ssh_port switch_hostname switch_port switch_user switch_pass mac; do
|
||||
check_device "$rpi_ip" "$dev_name" "$switch_ip" "$switch_ssh_port" "$switch_hostname" "$switch_port" "$switch_user" "$switch_pass" &
|
||||
check_device "$rpi_ip" "$dev_name" "$switch_ip" "$switch_ssh_port" "$switch_hostname" "$switch_port" "$switch_user" "$switch_pass" "$LICENSE_ACTIVE" &
|
||||
done < <(python3 /srv/tesm/generate_ips.py)
|
||||
|
||||
wait
|
||||
|
||||
Reference in New Issue
Block a user