// server.js — Server & Wartung (v3): Dienste, OS-Updates, Reboot, Live-Konsole. // Selbsterklärende Aktionszeilen + heikle Aktionen mit Klartext-Bestätigung. import { api, getToken } from "../core/api.js"; import { $, toast, icon, confirmModal, promptModal } from "../core/ui.js"; import { track } from "./jobs.js"; function refreshSoon() { document.dispatchEvent(new Event("mc:refresh")); } function row(id, ic, tone, title, desc) { return ``; } function mount() { $("#wartung").outerHTML = `
apt update & upgrade aus. Das kann ein paar Minuten dauern; der Fortschritt erscheint in der Aktivität." })) return;
const pwd = await promptModal({ title: "sudo-Passwort", body: "Für die System-Updates wird einmalig dein sudo-Passwort gebraucht.", placeholder: "sudo-Passwort", password: true, confirmLabel: "Installieren" });
if (!pwd) return;
try { const r = await api("/api/os-update", { method: "POST", body: JSON.stringify({ password: pwd }) }); toast("OS-Update gestartet."); track(r.job_id); }
catch (e) { toast(e.message, true); }
}
async function rebootServer() {
if (!await confirmModal({ title: "Server wirklich neu starten?", body: "Der ganze Bosgame startet physisch neu. Alles ist für ~1 Minute offline — auch dieses Dashboard.", confirmLabel: "Reboot", danger: true })) return;
const pwd = await promptModal({ title: "sudo-Passwort", body: "Für den Reboot wird einmalig dein sudo-Passwort gebraucht.", placeholder: "sudo-Passwort", password: true, confirmLabel: "Jetzt neustarten", danger: true });
if (!pwd) return;
try { await api("/api/reboot", { method: "POST", body: JSON.stringify({ password: pwd }) }); toast("Reboot ausgelöst — bis gleich."); }
catch (e) { toast(e.message, true); }
}
export default { id: "server", mount };