Add setup wizard and smoke tests for SE-LTD installation
- Implemented SetupSmokeTests.cs to validate installation prerequisites and configurations. - Created SetupWizard.cs for user interaction during the setup process, including folder selection and variable input. - Added build.ps1 script to automate the build process and run smoke tests. - Introduced compose.override.template.yml for Docker configuration management. - Defined setup.config.json to manage repository settings, prerequisites, and installation variables.
This commit is contained in:
1 parent
f6f3c402cc
commit
c19c77334f
7 files changed
+1139
No files matched your search
@@ -0,0 +1,19 @@
|
|||||||
|
# SE-LTD Setup für Windows
|
||||||
|
|
||||||
|
1. Die ZIP vollständig entpacken und `SE-LTD-Setup.exe` starten. Windows kann bei der unsignierten EXE eine Warnung anzeigen.
|
||||||
|
2. Visual Studio Code, WSL, Docker Desktop und Git für Windows installieren, sofern sie noch fehlen. Für BACnet in Docker Desktop unter **Settings → Resources → Network** das Host Networking aktivieren.
|
||||||
|
3. Installationsordner wählen. Der Assistent klont das Projekt, oder aktualisiert einen vorhandenen Checkout mit `git pull --ff-only`. Falls Git eine Anmeldung öffnet, dort den Git-Zugang verwenden.
|
||||||
|
4. Die Fragen zur Konfiguration beantworten. Bei Passwörtern kannst du den sicher erzeugten Vorschlag übernehmen. Für vorhandene Controller aktiviert „Bestandsanlage“ den bisherigen Datenbankzugang `wago` mit Passwort `3112` und gibt den MariaDB-Port im Netzwerk frei.
|
||||||
|
5. Docker Desktop bei Bedarf fertig einrichten. Der Assistent baut und startet die Dienste und prüft Web, API und Collector. Danach kannst du SE-LTD über den Link im Assistenten auf Port 81 öffnen.
|
||||||
|
|
||||||
|
Die Option „Nur dieser Rechner“ beschränkt Web, API, Collector und Hilfsoberflächen auf die lokale IPv4-Adresse. „Zugriff aus dem Netzwerk“ öffnet Web, API und Collector und setzt `CORS_ORIGIN=*`. Der Assistent ändert keine Windows-Firewallregeln. Verwende den Netzzugriff nur im vertrauenswürdigen Netz.
|
||||||
|
|
||||||
|
Eine bestehende `.env` bleibt unverändert. „Bestandsanlage“ bezieht sich auf den Controller-Zugang für eine neu aufgesetzte Datenbank. Vorhandene Datenbank-Volumes ändern ihr Passwort nicht durch eine neue `.env`. Es wird kein Backup oder Datenimport durchgeführt und es werden keine bestehenden Docker-Volumes gelöscht.
|
||||||
|
|
||||||
|
## Setup anpassen
|
||||||
|
|
||||||
|
`setup.config.json` und `compose.override.template.yml` müssen neben der EXE liegen. In der JSON-Datei kannst du Git-Ziel, Installationsordner, Voraussetzungen, Fragen und die Reihenfolge der Aktionen anpassen. `prepare` und `install` akzeptieren auch Schritte vom Typ `command`, die ein geprüftes Werkzeug über seine ID mit einem Argument-Array aufrufen. `http` prüft eine URL nach dem Start. `timeout` ist in Sekunden. Änderungen gelten beim nächsten Start des Assistenten ohne Neukompilierung.
|
||||||
|
|
||||||
|
Die YAML-Vorlage bestimmt die Portfreigaben für neue Installationen (Docker Compose ab 2.24.4 für `!override`). Der Assistent schreibt sie als lokales `compose.override.yaml` und bereinigt eine Kopie der MariaDB-Initialisierungsskripte in `.seltd-setup`, damit keine alten SQL-Vorgaben die gewählten Passwörter ersetzen. Das Git-Original bleibt unverändert. Pfade und aufrufbare Programme in der Setup-Konfiguration sind vertrauenswürdig zu behandeln.
|
||||||
|
|
||||||
|
Zum Neubauen der EXE nach Änderungen am C#-Code unter PowerShell `installer\build.ps1` ausführen. Mit `-Test` prüft der Build zusätzlich Klonen, Pull, erzeugte Zugangsdaten und Compose-Konfiguration an einem lokalen Test-Repository, ohne Docker-Container zu starten. `-TestDatabase` prüft auch beide Varianten in isolierten MariaDB-Testcontainern und benötigt das lokal vorhandene Image `mariadb:11.4`. EXE und ZIP liegen danach in `installer\dist`. Die EXE benötigt auf dem Zielrechner kein separat installiertes .NET-SDK.
|
||||||
@@ -0,0 +1,473 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Web.Script.Serialization;
|
||||||
|
|
||||||
|
namespace SeLtd.Setup
|
||||||
|
{
|
||||||
|
internal sealed class RepositorySettings
|
||||||
|
{
|
||||||
|
public string url { get; set; }
|
||||||
|
public string branch { get; set; }
|
||||||
|
public string folder { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class Prerequisite
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
public string label { get; set; }
|
||||||
|
public string executable { get; set; }
|
||||||
|
public string[] paths { get; set; }
|
||||||
|
public string[] probe { get; set; }
|
||||||
|
public string help { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class Variable
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public string label { get; set; }
|
||||||
|
public string type { get; set; }
|
||||||
|
public string description { get; set; }
|
||||||
|
public string source { get; set; }
|
||||||
|
public string legacyValue { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class Step
|
||||||
|
{
|
||||||
|
public string action { get; set; }
|
||||||
|
public string label { get; set; }
|
||||||
|
public string tool { get; set; }
|
||||||
|
public string[] arguments { get; set; }
|
||||||
|
public string url { get; set; }
|
||||||
|
public int timeout { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class SetupConfig
|
||||||
|
{
|
||||||
|
public RepositorySettings repository { get; set; }
|
||||||
|
public Prerequisite[] prerequisites { get; set; }
|
||||||
|
public Variable[] variables { get; set; }
|
||||||
|
public Step[] prepare { get; set; }
|
||||||
|
public Step[] install { get; set; }
|
||||||
|
public string dockerContext { get; set; }
|
||||||
|
public int webPort { get; set; }
|
||||||
|
public string composeTemplate { get; set; }
|
||||||
|
public string mariaDbInitDirectory { get; set; }
|
||||||
|
public string[] legacySqlPrefixes { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class SetupEngine
|
||||||
|
{
|
||||||
|
private const string OverrideMarker = "# Generated by SE-LTD Setup ";
|
||||||
|
private static readonly Regex EnvLine = new Regex(@"^(?<name>[A-Za-z_][A-Za-z_0-9]*)\s*=\s*(?<value>.*)$");
|
||||||
|
private static readonly Encoding Utf8 = new UTF8Encoding(false, true);
|
||||||
|
private readonly string configDir;
|
||||||
|
private readonly Dictionary<string, string> tools = new Dictionary<string, string>();
|
||||||
|
private string[] templateLines;
|
||||||
|
internal readonly Dictionary<string, string> Defaults = new Dictionary<string, string>();
|
||||||
|
internal readonly Dictionary<string, string> Values = new Dictionary<string, string>();
|
||||||
|
internal readonly SetupConfig Config;
|
||||||
|
internal string Folder { get; private set; }
|
||||||
|
internal bool ExistingEnvironment { get; private set; }
|
||||||
|
internal bool Legacy { get; set; }
|
||||||
|
internal bool Remote { get; set; }
|
||||||
|
|
||||||
|
internal SetupEngine(string configDir)
|
||||||
|
{
|
||||||
|
this.configDir = configDir;
|
||||||
|
Config = new JavaScriptSerializer().Deserialize<SetupConfig>(
|
||||||
|
File.ReadAllText(Path.Combine(configDir, "setup.config.json"), Utf8));
|
||||||
|
if (Config == null || Config.repository == null || Config.prerequisites == null ||
|
||||||
|
Config.variables == null || Config.variables.Length == 0 || Config.prepare == null || Config.install == null ||
|
||||||
|
string.IsNullOrWhiteSpace(Config.repository.folder) || string.IsNullOrWhiteSpace(Config.dockerContext) ||
|
||||||
|
Config.webPort < 1 || Config.webPort > 65535 ||
|
||||||
|
Config.variables.Select(variable => variable.name).Distinct().Count() != Config.variables.Length)
|
||||||
|
throw new InvalidDataException("Die Datei setup.config.json ist unvollständig oder enthält doppelte Variablen.");
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool Check(Prerequisite item)
|
||||||
|
{
|
||||||
|
var candidates = (item.paths ?? new string[0]).Select(Environment.ExpandEnvironmentVariables)
|
||||||
|
.Concat((Environment.GetEnvironmentVariable("PATH") ?? "").Split(';')
|
||||||
|
.Select(path => path.Trim().Trim('"'))
|
||||||
|
.Where(path => !string.IsNullOrWhiteSpace(path) && Path.IsPathRooted(path))
|
||||||
|
.Select(path => Path.Combine(path, item.executable)));
|
||||||
|
var executable = candidates.FirstOrDefault(File.Exists);
|
||||||
|
if (executable == null || (item.probe != null &&
|
||||||
|
Run(executable, item.probe, configDir, 15).Code != 0))
|
||||||
|
return false;
|
||||||
|
tools[item.id] = executable;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Prepare(string folder, Action<string> progress)
|
||||||
|
{
|
||||||
|
Folder = Path.GetFullPath(folder);
|
||||||
|
Legacy = Remote = false;
|
||||||
|
foreach (var step in Config.prepare)
|
||||||
|
{
|
||||||
|
progress(step.label);
|
||||||
|
if (step.action == "checkout") Checkout();
|
||||||
|
else if (step.action == "template") LoadTemplate();
|
||||||
|
else if (step.action == "command") RunStep(step);
|
||||||
|
else throw new InvalidDataException("Unbekannter Vorbereitungsschritt: " + step.action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Install(Action<string> progress)
|
||||||
|
{
|
||||||
|
foreach (var step in Config.install)
|
||||||
|
{
|
||||||
|
progress(step.label);
|
||||||
|
if (step.action == "dockerReady") WaitForDocker(TimeoutFor(step, 180), progress);
|
||||||
|
else if (step.action == "writeSetup") WriteSetup();
|
||||||
|
else if (step.action == "command") RunStep(step);
|
||||||
|
else if (step.action == "http") CheckHttp(Expand(step.url), TimeoutFor(step, 45));
|
||||||
|
else throw new InvalidDataException("Unbekannter Installationsschritt: " + step.action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string LocalOrigin
|
||||||
|
{
|
||||||
|
get { return "http://localhost:" + Config.webPort + ",http://127.0.0.1:" + Config.webPort; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string WebUrl { get { return "http://127.0.0.1:" + Config.webPort + "/"; } }
|
||||||
|
|
||||||
|
internal static string GenerateSecret()
|
||||||
|
{
|
||||||
|
var bytes = new byte[32];
|
||||||
|
using (var rng = RandomNumberGenerator.Create()) rng.GetBytes(bytes);
|
||||||
|
return BitConverter.ToString(bytes).Replace("-", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string Validate(Variable variable, string value, bool existingController)
|
||||||
|
{
|
||||||
|
if (variable.type == "secret" || (variable.type == "legacyPassword" && !existingController))
|
||||||
|
{
|
||||||
|
if (!Regex.IsMatch(value, @"\A[A-Za-z0-9._~-]{16,72}\z"))
|
||||||
|
return "Bitte 16 bis 72 Zeichen verwenden. Erlaubt sind A–Z, a–z, 0–9 und . _ ~ -.";
|
||||||
|
}
|
||||||
|
else if (variable.type == "email")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (new MailAddress(value).Address != value || !Regex.IsMatch(value, @"\A[A-Za-z0-9._+%\-]+@[A-Za-z0-9.\-]+\z"))
|
||||||
|
return "Bitte eine einfache E-Mail-Adresse ohne Anzeigenamen eingeben.";
|
||||||
|
}
|
||||||
|
catch (FormatException) { return "Bitte eine gültige E-Mail-Adresse eingeben."; }
|
||||||
|
catch (ArgumentException) { return "Bitte eine gültige E-Mail-Adresse eingeben."; }
|
||||||
|
}
|
||||||
|
else if (variable.type == "port")
|
||||||
|
{
|
||||||
|
int number;
|
||||||
|
if (!int.TryParse(value, NumberStyles.None, CultureInfo.InvariantCulture, out number) ||
|
||||||
|
number < 1 || number > 65535)
|
||||||
|
return "Bitte eine Portnummer zwischen 1 und 65535 eingeben.";
|
||||||
|
if (new[] { Config.webPort, 3306, 3008, 9090, 18110, 18111 }.Contains(number))
|
||||||
|
return "Dieser Port ist bereits für einen anderen SE-LTD-Dienst reserviert.";
|
||||||
|
}
|
||||||
|
else if (variable.type == "text" && !Regex.IsMatch(value, @"\A[A-Za-z0-9._+:/ -]+\z"))
|
||||||
|
return "Bitte einen Wert ohne Sonder- oder Steuerzeichen eingeben.";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Checkout()
|
||||||
|
{
|
||||||
|
var git = Tool("git");
|
||||||
|
var repo = Config.repository;
|
||||||
|
if (string.IsNullOrWhiteSpace(repo.url) || string.IsNullOrWhiteSpace(repo.branch) || repo.branch.StartsWith("-"))
|
||||||
|
throw new InvalidDataException("Repository oder Branch in setup.config.json fehlt.");
|
||||||
|
Directory.CreateDirectory(Folder);
|
||||||
|
if (!File.Exists(Path.Combine(Folder, ".git")) && !Directory.Exists(Path.Combine(Folder, ".git")))
|
||||||
|
{
|
||||||
|
if (Directory.EnumerateFileSystemEntries(Folder).Any())
|
||||||
|
throw new InvalidOperationException("Der Ordner ist nicht leer und enthält kein Git-Projekt. Bitte einen leeren Ordner auswählen.");
|
||||||
|
Require(Run(git, new[] { "clone", "--single-branch", "--branch", repo.branch, "--", repo.url, Folder }, configDir, 300),
|
||||||
|
"Git konnte das Projekt nicht herunterladen.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var root = Require(Run(git, new[] { "rev-parse", "--show-toplevel" }, Folder, 15), "Git-Ordner konnte nicht geprüft werden.");
|
||||||
|
var origin = Require(Run(git, new[] { "remote", "get-url", "origin" }, Folder, 15), "Git-Server konnte nicht geprüft werden.");
|
||||||
|
var branch = Require(Run(git, new[] { "branch", "--show-current" }, Folder, 15), "Git-Branch konnte nicht geprüft werden.");
|
||||||
|
if (!SameFolder(root, Folder) || !string.Equals(origin, repo.url, StringComparison.Ordinal) || branch != repo.branch)
|
||||||
|
throw new InvalidOperationException("Der Ordner verweist auf ein anderes Repository oder einen anderen Branch. Bitte einen anderen Ordner auswählen.");
|
||||||
|
Require(Run(git, new[] { "pull", "--ff-only", "origin", repo.branch }, Folder, 300), "Git Pull konnte nicht ausgeführt werden.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadTemplate()
|
||||||
|
{
|
||||||
|
var path = Path.Combine(Folder, ".env");
|
||||||
|
if (Require(Run(Tool("git"), new[] { "ls-files", "--", ".env" }, Folder, 15),
|
||||||
|
"Git konnte die .env nicht prüfen.").Length != 0)
|
||||||
|
throw new InvalidOperationException("Die Datei .env wird von Git verwaltet. Aus Sicherheitsgründen bitte zuerst aus dem Repository entfernen.");
|
||||||
|
ExistingEnvironment = File.Exists(path);
|
||||||
|
Defaults.Clear();
|
||||||
|
Values.Clear();
|
||||||
|
templateLines = File.ReadAllLines(ExistingEnvironment ? path : Path.Combine(Folder, ".env.example"), Utf8);
|
||||||
|
foreach (string line in templateLines)
|
||||||
|
{
|
||||||
|
var match = EnvLine.Match(line);
|
||||||
|
if (match.Success) Defaults[match.Groups["name"].Value] = match.Groups["value"].Value.Trim();
|
||||||
|
}
|
||||||
|
if (ExistingEnvironment)
|
||||||
|
{
|
||||||
|
foreach (var pair in Defaults) Values[pair.Key] = pair.Value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var names = new HashSet<string>(Config.variables.Select(variable => variable.name));
|
||||||
|
var unknown = Defaults.Keys.Where(name => !names.Contains(name)).ToArray();
|
||||||
|
if (unknown.Length != 0)
|
||||||
|
throw new InvalidDataException("Die .env-Vorlage enthält neue Variablen. Bitte setup.config.json ergänzen: " + string.Join(", ", unknown));
|
||||||
|
foreach (var variable in Config.variables)
|
||||||
|
{
|
||||||
|
if (variable.type == "secret" || variable.type == "legacyPassword")
|
||||||
|
Values[variable.name] = GenerateSecret();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string value;
|
||||||
|
if (!Defaults.TryGetValue(variable.name, out value))
|
||||||
|
throw new InvalidDataException("Die Variable " + variable.name + " fehlt in .env.example.");
|
||||||
|
Values[variable.name] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WriteSetup()
|
||||||
|
{
|
||||||
|
var path = Path.Combine(Folder, ".env");
|
||||||
|
var overridePath = Path.Combine(Folder, "compose.override.yaml");
|
||||||
|
if (ExistingEnvironment) return;
|
||||||
|
|
||||||
|
var otherOverrides = new[] { "compose.override.yml", "docker-compose.override.yml", "docker-compose.override.yaml" };
|
||||||
|
if (otherOverrides.Any(name => File.Exists(Path.Combine(Folder, name))))
|
||||||
|
throw new InvalidOperationException("Ein anderer lokaler Compose-Override ist vorhanden. Der Assistent kann die Port- und Datenbank-Konfiguration nicht sicher zuordnen.");
|
||||||
|
|
||||||
|
if (File.Exists(overridePath) && !(File.ReadLines(overridePath, Utf8).FirstOrDefault() ?? "").StartsWith(OverrideMarker, StringComparison.Ordinal))
|
||||||
|
throw new InvalidOperationException("compose.override.yaml wurde nicht von diesem Assistenten erstellt. Die Datei wurde nicht verändert.");
|
||||||
|
if (File.Exists(path))
|
||||||
|
throw new InvalidOperationException(".env wurde inzwischen angelegt und wird nicht überschrieben. Bitte den Assistenten neu starten.");
|
||||||
|
foreach (var variable in Config.variables)
|
||||||
|
{
|
||||||
|
if (variable.type == "sameAs") Values[variable.name] = Values[variable.source];
|
||||||
|
else if (variable.type == "remoteAccess") Values[variable.name] = Remote ? "*" : LocalOrigin;
|
||||||
|
else if (variable.type == "legacyPassword" && Legacy) Values[variable.name] = variable.legacyValue;
|
||||||
|
var error = Validate(variable, Values[variable.name], Legacy);
|
||||||
|
if (error != null) throw new InvalidDataException(variable.name + ": " + error);
|
||||||
|
}
|
||||||
|
|
||||||
|
var overrideText = Expand(File.ReadAllText(Path.Combine(configDir, Config.composeTemplate), Utf8));
|
||||||
|
if (!overrideText.StartsWith(OverrideMarker, StringComparison.Ordinal))
|
||||||
|
throw new InvalidDataException("Die Markierung am Anfang der Compose-Vorlage fehlt.");
|
||||||
|
var upstream = Path.Combine(Folder, Config.mariaDbInitDirectory);
|
||||||
|
var init = Path.Combine(Folder, ".seltd-setup", "mariadb-init");
|
||||||
|
Directory.CreateDirectory(init);
|
||||||
|
foreach (string file in Directory.GetFiles(upstream))
|
||||||
|
{
|
||||||
|
var destination = Path.Combine(init, Path.GetFileName(file));
|
||||||
|
if (Path.GetExtension(file).Equals(".sql", StringComparison.OrdinalIgnoreCase))
|
||||||
|
File.WriteAllLines(destination, File.ReadAllLines(file, Utf8).Where(line =>
|
||||||
|
!(Config.legacySqlPrefixes ?? new string[0]).Any(prefix =>
|
||||||
|
line.TrimStart().StartsWith(prefix, StringComparison.OrdinalIgnoreCase))), Utf8);
|
||||||
|
else File.Copy(file, destination, true);
|
||||||
|
}
|
||||||
|
var excludePath = Require(Run(Tool("git"), new[] { "rev-parse", "--git-path", "info/exclude" }, Folder, 15),
|
||||||
|
"Lokale Git-Einstellungen konnten nicht gelesen werden.");
|
||||||
|
excludePath = Path.Combine(Folder, excludePath);
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(excludePath));
|
||||||
|
File.AppendAllText(excludePath, "\n/.env\n/.env.*.tmp\n/compose.override.yaml\n/.seltd-setup/\n", Utf8);
|
||||||
|
File.WriteAllText(overridePath, overrideText, Utf8);
|
||||||
|
var envValues = templateLines.Select(line =>
|
||||||
|
{
|
||||||
|
var match = EnvLine.Match(line);
|
||||||
|
return match.Success ? match.Groups["name"].Value + "=" + Values[match.Groups["name"].Value] : line;
|
||||||
|
});
|
||||||
|
var tempPath = Path.Combine(Folder, ".env." + Guid.NewGuid().ToString("N") + ".tmp");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.WriteAllLines(tempPath, envValues, Utf8);
|
||||||
|
File.Move(tempPath, path);
|
||||||
|
ExistingEnvironment = true;
|
||||||
|
}
|
||||||
|
finally { if (File.Exists(tempPath)) File.Delete(tempPath); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WaitForDocker(int seconds, Action<string> progress)
|
||||||
|
{
|
||||||
|
var deadline = DateTime.UtcNow.AddSeconds(seconds);
|
||||||
|
var launched = false;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
var result = Docker(new[] { "info", "--format", "{{.OSType}}" }, 12);
|
||||||
|
if (result.Code == 0 && result.Output.Trim() == "linux")
|
||||||
|
{
|
||||||
|
var installed = Require(Docker(new[] { "ps", "-a", "--filter", "name=^/seltd-",
|
||||||
|
"--format", "{{.Names}}|{{.Label \"com.docker.compose.project.working_dir\"}}" }, 15),
|
||||||
|
"Docker konnte laufende Installationen nicht prüfen.");
|
||||||
|
foreach (var line in installed.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
var parts = line.Split(new[] { '|' }, 2);
|
||||||
|
if (parts.Length != 2 || string.IsNullOrEmpty(parts[1]) || !SameFolder(parts[1], Folder))
|
||||||
|
throw new InvalidOperationException("Docker enthält bereits eine SE-LTD-Installation (" + parts[0] +
|
||||||
|
"). Bitte den ursprünglichen Projektordner wählen. Bestehende Container bleiben unverändert.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!launched)
|
||||||
|
{
|
||||||
|
launched = true;
|
||||||
|
progress("Docker Desktop wird geöffnet. Bitte ggf. dessen Ersteinrichtung bestätigen.");
|
||||||
|
using (Process.Start(new ProcessStartInfo(Tool("desktop")) { UseShellExecute = true })) { }
|
||||||
|
}
|
||||||
|
Thread.Sleep(3000);
|
||||||
|
} while (DateTime.UtcNow < deadline);
|
||||||
|
throw new InvalidOperationException("Docker Desktop ist noch nicht für Linux-Container bereit. Bitte Docker Desktop öffnen, die Einrichtung abschließen und es noch einmal versuchen.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RunStep(Step step)
|
||||||
|
{
|
||||||
|
var arguments = (step.arguments ?? new string[0]).Select(Expand).ToArray();
|
||||||
|
var timeout = TimeoutFor(step, 60);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = step.tool == "docker" ? Docker(arguments, timeout) : Run(Tool(step.tool), arguments, Folder, timeout);
|
||||||
|
Require(result, step.label + " fehlgeschlagen.");
|
||||||
|
}
|
||||||
|
catch (Exception error)
|
||||||
|
{
|
||||||
|
string message = error.Message;
|
||||||
|
foreach (var secret in Config.variables.Where(item => item.type == "secret" ||
|
||||||
|
item.type == "legacyPassword" || item.type == "sameAs"))
|
||||||
|
{
|
||||||
|
string value;
|
||||||
|
if (Values.TryGetValue(secret.name, out value) && value.Length >= 4)
|
||||||
|
message = message.Replace(value, "********");
|
||||||
|
}
|
||||||
|
throw new InvalidOperationException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CheckHttp(string url, int seconds)
|
||||||
|
{
|
||||||
|
var deadline = DateTime.UtcNow.AddSeconds(seconds);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var request = (HttpWebRequest)WebRequest.Create(url);
|
||||||
|
request.Proxy = null;
|
||||||
|
request.Timeout = 3000;
|
||||||
|
using (var response = (HttpWebResponse)request.GetResponse())
|
||||||
|
if ((int)response.StatusCode < 400) return;
|
||||||
|
}
|
||||||
|
catch (WebException) { }
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
} while (DateTime.UtcNow < deadline);
|
||||||
|
throw new InvalidOperationException("Die Prüfung von " + url + " war nicht erfolgreich. Details stehen in Docker Desktop bei den SE-LTD-Containern.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private string Expand(string input)
|
||||||
|
{
|
||||||
|
return input.Replace("{{WEB_PORT}}", Config.webPort.ToString(CultureInfo.InvariantCulture))
|
||||||
|
.Replace("{{API_PORT}}", ApiPort())
|
||||||
|
.Replace("{{WEB_BIND}}", Remote ? "0.0.0.0" : "127.0.0.1")
|
||||||
|
.Replace("{{DB_BIND}}", Legacy ? "0.0.0.0" : "127.0.0.1");
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ApiPort()
|
||||||
|
{
|
||||||
|
string value;
|
||||||
|
if (Values.TryGetValue("VITE_API_PORT", out value))
|
||||||
|
{
|
||||||
|
var match = Regex.Match(value, "^['\"]?([0-9]{1,5})['\"]?(?:\\s+#.*)?$");
|
||||||
|
if (match.Success) return match.Groups[1].Value;
|
||||||
|
}
|
||||||
|
return "18080";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string Tool(string id)
|
||||||
|
{
|
||||||
|
string path;
|
||||||
|
if (!tools.TryGetValue(id, out path)) throw new InvalidOperationException("Voraussetzung fehlt: " + id);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Result Docker(string[] args, int seconds)
|
||||||
|
{
|
||||||
|
return Run(Tool("docker"), new[] { "--context", Config.dockerContext }.Concat(args), Folder, seconds,
|
||||||
|
Defaults.Keys.Concat(Values.Keys).Concat(new[] { "COMPOSE_FILE", "COMPOSE_ENV_FILES", "COMPOSE_PROJECT_NAME" }));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool SameFolder(string left, string right)
|
||||||
|
{
|
||||||
|
return string.Equals(Path.GetFullPath(left).TrimEnd('\\', '/'), Path.GetFullPath(right).TrimEnd('\\', '/'),
|
||||||
|
StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int TimeoutFor(Step step, int fallback) { return step.timeout > 0 ? step.timeout : fallback; }
|
||||||
|
|
||||||
|
private sealed class Result
|
||||||
|
{
|
||||||
|
internal int Code;
|
||||||
|
internal string Output;
|
||||||
|
internal string Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string Require(Result result, string message)
|
||||||
|
{
|
||||||
|
if (result.Code == 0) return result.Output.Trim();
|
||||||
|
var details = string.IsNullOrWhiteSpace(result.Error) ? result.Output : result.Error;
|
||||||
|
if (details.Length > 1600) details = details.Substring(details.Length - 1600);
|
||||||
|
throw new InvalidOperationException(message + "\n\n" + details.Trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Result Run(string executable, IEnumerable<string> arguments, string cwd, int seconds,
|
||||||
|
IEnumerable<string> clearEnvironment = null)
|
||||||
|
{
|
||||||
|
var start = new ProcessStartInfo(executable, string.Join(" ", arguments.Select(Quote)))
|
||||||
|
{
|
||||||
|
WorkingDirectory = cwd,
|
||||||
|
UseShellExecute = false,
|
||||||
|
CreateNoWindow = true,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
RedirectStandardError = true,
|
||||||
|
StandardOutputEncoding = Encoding.UTF8,
|
||||||
|
StandardErrorEncoding = Encoding.UTF8
|
||||||
|
};
|
||||||
|
if (clearEnvironment != null)
|
||||||
|
foreach (string variable in clearEnvironment) start.EnvironmentVariables.Remove(variable);
|
||||||
|
using (var process = Process.Start(start))
|
||||||
|
{
|
||||||
|
var output = process.StandardOutput.ReadToEndAsync();
|
||||||
|
var error = process.StandardError.ReadToEndAsync();
|
||||||
|
if (!process.WaitForExit(seconds * 1000))
|
||||||
|
{
|
||||||
|
try { process.Kill(); }
|
||||||
|
catch (InvalidOperationException) { }
|
||||||
|
return new Result { Code = -1, Output = "", Error = "Zeitlimit erreicht." };
|
||||||
|
}
|
||||||
|
if (!System.Threading.Tasks.Task.WaitAll(new System.Threading.Tasks.Task[] { output, error }, 5000))
|
||||||
|
return new Result { Code = -1, Output = "", Error = "Programmausgabe wurde nicht abgeschlossen." };
|
||||||
|
return new Result { Code = process.ExitCode, Output = output.Result.Replace("\0", ""), Error = error.Result.Replace("\0", "") };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string Quote(string arg)
|
||||||
|
{
|
||||||
|
// WSL parses its switches from the raw command line and rejects quoted flags.
|
||||||
|
if (arg.Length > 0 && !arg.Any(character => char.IsWhiteSpace(character) || character == '"'))
|
||||||
|
return arg;
|
||||||
|
return "\"" + Regex.Replace(arg, "(\\\\*)(\"|$)", match =>
|
||||||
|
match.Groups[1].Value + match.Groups[1].Value + (match.Groups[2].Value == "\"" ? "\\\"" : "")) + "\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Web.Script.Serialization;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SeLtd.Setup
|
||||||
|
{
|
||||||
|
internal static class SetupSmokeTests
|
||||||
|
{
|
||||||
|
[STAThread]
|
||||||
|
private static void Main(string[] args)
|
||||||
|
{
|
||||||
|
string source = Path.GetFullPath(args[0]);
|
||||||
|
string root = Path.Combine(source, "dist", "smoke-" + Guid.NewGuid().ToString("N"));
|
||||||
|
var repo = Directory.CreateDirectory(Path.Combine(root, "fixture repository")).FullName;
|
||||||
|
var config = Directory.CreateDirectory(Path.Combine(root, "config")).FullName;
|
||||||
|
foreach (string file in new[] { ".env.example", "docker-compose.yml" })
|
||||||
|
File.Copy(Path.Combine(source, "..", file), Path.Combine(repo, file));
|
||||||
|
var init = Directory.CreateDirectory(Path.Combine(repo, "docker", "mariadb", "init")).FullName;
|
||||||
|
File.Copy(Path.Combine(source, "..", "docker", "mariadb", "init", "01-init.sql"), Path.Combine(init, "01-init.sql"));
|
||||||
|
Git(repo, "init -b main");
|
||||||
|
Git(repo, "add .");
|
||||||
|
Git(repo, "-c user.name=Smoke -c user.email=smoke@example.com -c commit.gpgsign=false commit -m fixture");
|
||||||
|
File.Copy(Path.Combine(source, "setup.config.json"), Path.Combine(config, "setup.config.json"));
|
||||||
|
File.Copy(Path.Combine(source, "compose.override.template.yml"), Path.Combine(config, "compose.override.template.yml"));
|
||||||
|
|
||||||
|
var setup = new SetupEngine(config);
|
||||||
|
setup.Config.repository.url = new Uri(repo).AbsoluteUri;
|
||||||
|
setup.Config.install = setup.Config.install.Where(step =>
|
||||||
|
step.action == "writeSetup" || (step.action == "command" && step.arguments.Contains("config"))).ToArray();
|
||||||
|
foreach (var prerequisite in setup.Config.prerequisites.Where(item => item.id == "git" || item.id == "docker"))
|
||||||
|
Assert(setup.Check(prerequisite), prerequisite.id + " prerequisite");
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
using (var wizard = new SetupWizard(setup)) Assert(wizard.Text == "SE-LTD Setup", "wizard initialization");
|
||||||
|
|
||||||
|
foreach (bool legacy in new[] { false, true })
|
||||||
|
{
|
||||||
|
string target = Path.Combine(root, legacy ? "legacy install" : "new install");
|
||||||
|
setup.Prepare(target, Console.WriteLine);
|
||||||
|
Assert(!setup.ExistingEnvironment && !File.Exists(Path.Combine(target, ".env")), "no env before confirmation");
|
||||||
|
Assert(setup.Values["ADMIN_USERNAME"] == "admin", "default admin");
|
||||||
|
Assert(setup.Values["ADMIN_PASSWORD"].Length == 64, "secure password length");
|
||||||
|
Assert(setup.Values["ADMIN_PASSWORD"] != setup.Values["REDIS_PASSWORD"], "independent secrets");
|
||||||
|
setup.Legacy = setup.Remote = legacy;
|
||||||
|
setup.Values["VITE_API_PORT"] = "18081";
|
||||||
|
setup.Install(Console.WriteLine);
|
||||||
|
string env = File.ReadAllText(Path.Combine(target, ".env"));
|
||||||
|
Assert((setup.Values["MARIADB_PASSWORD"] == "3112") == legacy, "legacy database password");
|
||||||
|
Assert(setup.Values["MARIADB_ROOT_PASSWORD"] == setup.Values["DB_PASSWORD_FALLBACK"], "safe fallback");
|
||||||
|
Assert(setup.Values["CORS_ORIGIN"] == (legacy ? "*" : setup.LocalOrigin), "CORS policy");
|
||||||
|
Assert(!env.Contains("replace-with-a-"), "no insecure placeholders");
|
||||||
|
Assert(!File.ReadAllText(Path.Combine(target, ".seltd-setup", "mariadb-init", "01-init.sql")).Contains("IDENTIFIED BY"), "remove fixed SQL credentials");
|
||||||
|
Assert(File.ReadAllText(Path.Combine(target, "docker", "mariadb", "init", "01-init.sql")).Contains("IDENTIFIED BY"), "do not edit upstream SQL");
|
||||||
|
Assert(Git(target, "status --porcelain").Trim() == "", "generated credentials and overrides are ignored by Git");
|
||||||
|
|
||||||
|
var model = new JavaScriptSerializer().DeserializeObject(Run(target, "docker.exe", "compose config --format json"));
|
||||||
|
var services = Field(model, "services");
|
||||||
|
string ip = legacy ? "0.0.0.0" : "127.0.0.1";
|
||||||
|
CheckPort(services, "web", ip, "81");
|
||||||
|
CheckPort(services, "api", ip, "18081");
|
||||||
|
CheckPort(services, "collector", ip, "18110");
|
||||||
|
CheckPort(services, "mariadb", ip, "3306");
|
||||||
|
CheckPort(services, "dockhand", "127.0.0.1", "3008");
|
||||||
|
var db = Field(services, "mariadb");
|
||||||
|
Assert((string)Field(Field(db, "environment"), "MARIADB_ROOT_HOST") == "%", "database root accessible in Compose network");
|
||||||
|
var initMount = ((IEnumerable)Field(db, "volumes")).Cast<object>()
|
||||||
|
.Single(mount => (string)Field(mount, "target") == "/docker-entrypoint-initdb.d");
|
||||||
|
Assert(((string)Field(initMount, "source")).Contains(".seltd-setup"), "mount sanitized SQL");
|
||||||
|
if (args.Contains("--database")) VerifyDatabase(setup, target);
|
||||||
|
|
||||||
|
string marker = legacy ? "legacy-update.txt" : "fresh-update.txt";
|
||||||
|
File.WriteAllText(Path.Combine(repo, marker), marker);
|
||||||
|
Git(repo, "add " + marker);
|
||||||
|
Git(repo, "-c user.name=Smoke -c user.email=smoke@example.com -c commit.gpgsign=false commit -m update");
|
||||||
|
setup.Prepare(target, Console.WriteLine);
|
||||||
|
Assert(setup.ExistingEnvironment && File.Exists(Path.Combine(target, marker)), "fast-forward pull");
|
||||||
|
setup.Install(Console.WriteLine);
|
||||||
|
Assert(env == File.ReadAllText(Path.Combine(target, ".env")), "existing env remains untouched");
|
||||||
|
}
|
||||||
|
string absoluteDist = Path.GetFullPath(Path.Combine(source, "dist")) + Path.DirectorySeparatorChar;
|
||||||
|
if (Path.GetFullPath(root).StartsWith(absoluteDist, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
foreach (string file in Directory.GetFiles(root, "*", SearchOption.AllDirectories))
|
||||||
|
{
|
||||||
|
var attributes = File.GetAttributes(file);
|
||||||
|
if ((attributes & FileAttributes.ReadOnly) != 0)
|
||||||
|
File.SetAttributes(file, attributes & ~FileAttributes.ReadOnly);
|
||||||
|
}
|
||||||
|
Directory.Delete(root, true);
|
||||||
|
}
|
||||||
|
Console.WriteLine("SE-LTD setup smoke tests passed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void VerifyDatabase(SetupEngine setup, string cwd)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Testing MariaDB initialization without network or published ports.");
|
||||||
|
string container = "seltd-installer-test-" + Guid.NewGuid().ToString("N");
|
||||||
|
string root = setup.Values["MARIADB_ROOT_PASSWORD"];
|
||||||
|
string writer = setup.Values["MARIADB_PASSWORD"];
|
||||||
|
string sql = Path.Combine(cwd, ".seltd-setup", "mariadb-init");
|
||||||
|
Func<string, string> docker = command => Run(cwd, "docker.exe", "--context " + setup.Config.dockerContext + " " + command);
|
||||||
|
docker("run --pull never --rm -d --network none --name " + container +
|
||||||
|
" --env MARIADB_ROOT_HOST=% --env MARIADB_DATABASE=wago --env MARIADB_USER=wago" +
|
||||||
|
" --env MARIADB_ROOT_PASSWORD=" + root + " --env MARIADB_PASSWORD=" + writer +
|
||||||
|
" --mount \"type=bind,source=" + sql + ",target=/docker-entrypoint-initdb.d,readonly\" mariadb:11.4");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var deadline = DateTime.UtcNow.AddSeconds(60);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string result = docker("exec --env MYSQL_PWD=" + writer + " " + container +
|
||||||
|
" mariadb --protocol=tcp -h127.0.0.1 -uwago -N -e \"SHOW TABLES FROM wago\"");
|
||||||
|
Assert(result.Contains("app_users"), "schema and writer password");
|
||||||
|
result = docker("exec --env MYSQL_PWD=" + root + " " + container +
|
||||||
|
" mariadb --protocol=tcp -h127.0.0.1 -uroot -N -e \"SELECT 1\"");
|
||||||
|
Assert(result.Trim() == "1", "configured root password");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException) { Thread.Sleep(1500); }
|
||||||
|
} while (DateTime.UtcNow < deadline);
|
||||||
|
throw new InvalidOperationException("MariaDB did not accept the configured smoke-test credentials.");
|
||||||
|
}
|
||||||
|
finally { docker("stop " + container); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CheckPort(object services, string service, string ip, string port)
|
||||||
|
{
|
||||||
|
var entry = ((IEnumerable)Field(Field(services, service), "ports")).Cast<object>().Single();
|
||||||
|
Assert((string)Field(entry, "host_ip") == ip && Convert.ToString(Field(entry, "published")) == port, service + " port binding");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static object Field(object obj, string key) { return ((Dictionary<string, object>)obj)[key]; }
|
||||||
|
|
||||||
|
private static void Assert(bool valid, string feature)
|
||||||
|
{
|
||||||
|
if (!valid) throw new InvalidOperationException("Smoke test failed: " + feature);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string Git(string cwd, string args) { return Run(cwd, "git.exe", args); }
|
||||||
|
|
||||||
|
private static string Run(string cwd, string file, string args)
|
||||||
|
{
|
||||||
|
using (var process = Process.Start(new ProcessStartInfo(file, args)
|
||||||
|
{
|
||||||
|
WorkingDirectory = cwd, UseShellExecute = false, CreateNoWindow = true,
|
||||||
|
RedirectStandardOutput = true, RedirectStandardError = true,
|
||||||
|
StandardOutputEncoding = Encoding.UTF8
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
var output = process.StandardOutput.ReadToEndAsync();
|
||||||
|
var error = process.StandardError.ReadToEndAsync();
|
||||||
|
process.WaitForExit();
|
||||||
|
if (process.ExitCode != 0) throw new InvalidOperationException(file + " failed: " + error.Result);
|
||||||
|
return output.Result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,359 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SeLtd.Setup
|
||||||
|
{
|
||||||
|
internal sealed class SetupWizard : Form
|
||||||
|
{
|
||||||
|
private readonly SetupEngine setup;
|
||||||
|
private readonly Label section = new Label();
|
||||||
|
private readonly Label headline = new Label();
|
||||||
|
private readonly FlowLayoutPanel body = new FlowLayoutPanel();
|
||||||
|
private readonly Button back = new Button { Text = "Zurück", AutoSize = true };
|
||||||
|
private readonly Button next = new Button { Text = "Weiter", AutoSize = true };
|
||||||
|
private TextBox input;
|
||||||
|
private TextBox log;
|
||||||
|
private CheckBox choice;
|
||||||
|
private Label validation;
|
||||||
|
private string folder;
|
||||||
|
private bool busy;
|
||||||
|
private int page;
|
||||||
|
private int variableIndex;
|
||||||
|
|
||||||
|
[STAThread]
|
||||||
|
private static void Main()
|
||||||
|
{
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
try { Application.Run(new SetupWizard(new SetupEngine(AppDomain.CurrentDomain.BaseDirectory))); }
|
||||||
|
catch (Exception error)
|
||||||
|
{
|
||||||
|
MessageBox.Show("SE-LTD Setup konnte nicht gestartet werden. Bitte die ZIP vollständig entpacken und die Konfiguration prüfen.\n\n" +
|
||||||
|
error.Message, "SE-LTD Setup", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal SetupWizard(SetupEngine setup)
|
||||||
|
{
|
||||||
|
this.setup = setup;
|
||||||
|
folder = Environment.ExpandEnvironmentVariables(setup.Config.repository.folder);
|
||||||
|
Text = "SE-LTD Setup";
|
||||||
|
Font = new Font("Segoe UI", 10f);
|
||||||
|
AutoScaleMode = AutoScaleMode.Dpi;
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
|
ClientSize = new Size(690, 530);
|
||||||
|
MinimumSize = new Size(580, 460);
|
||||||
|
BackColor = SystemColors.Window;
|
||||||
|
var layout = new TableLayoutPanel { Dock = DockStyle.Fill, ColumnCount = 1, RowCount = 4, Padding = new Padding(24, 17, 24, 14) };
|
||||||
|
layout.RowStyles.Add(new RowStyle(SizeType.Absolute, 24));
|
||||||
|
layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
|
||||||
|
layout.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
|
||||||
|
layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
|
||||||
|
section.Dock = DockStyle.Fill;
|
||||||
|
section.ForeColor = Color.FromArgb(163, 27, 45);
|
||||||
|
headline.Dock = DockStyle.Top;
|
||||||
|
headline.AutoSize = true;
|
||||||
|
headline.Font = new Font(Font.FontFamily, 17f, FontStyle.Bold);
|
||||||
|
headline.Margin = new Padding(0, 3, 0, 12);
|
||||||
|
body.Dock = DockStyle.Fill;
|
||||||
|
body.AutoScroll = true;
|
||||||
|
body.FlowDirection = FlowDirection.TopDown;
|
||||||
|
body.WrapContents = false;
|
||||||
|
body.Margin = new Padding(0);
|
||||||
|
body.ClientSizeChanged += delegate { FitBody(); };
|
||||||
|
var buttons = new FlowLayoutPanel { Dock = DockStyle.Fill, AutoSize = true, FlowDirection = FlowDirection.RightToLeft };
|
||||||
|
buttons.Controls.AddRange(new Control[] { next, back });
|
||||||
|
layout.Controls.Add(section, 0, 0);
|
||||||
|
layout.Controls.Add(headline, 0, 1);
|
||||||
|
layout.Controls.Add(body, 0, 2);
|
||||||
|
layout.Controls.Add(buttons, 0, 3);
|
||||||
|
Controls.Add(layout);
|
||||||
|
AcceptButton = next;
|
||||||
|
back.Click += OnBack;
|
||||||
|
next.Click += OnNext;
|
||||||
|
FormClosing += delegate(object sender, FormClosingEventArgs e) { if (busy) e.Cancel = true; };
|
||||||
|
ShowChecks();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Screen(string step, string title, string nextText, bool canGoBack)
|
||||||
|
{
|
||||||
|
body.SuspendLayout();
|
||||||
|
while (body.Controls.Count > 0) body.Controls[0].Dispose();
|
||||||
|
section.Text = step;
|
||||||
|
headline.Text = title;
|
||||||
|
next.Text = nextText;
|
||||||
|
back.Visible = canGoBack;
|
||||||
|
next.Enabled = true;
|
||||||
|
validation = null;
|
||||||
|
input = null;
|
||||||
|
choice = null;
|
||||||
|
body.ResumeLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Add(Control item)
|
||||||
|
{
|
||||||
|
item.Margin = new Padding(0, 0, 0, 8);
|
||||||
|
body.Controls.Add(item);
|
||||||
|
Fit(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FitBody()
|
||||||
|
{
|
||||||
|
foreach (Control item in body.Controls) Fit(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Fit(Control item)
|
||||||
|
{
|
||||||
|
int width = Math.Max(200, body.ClientSize.Width - SystemInformation.VerticalScrollBarWidth - 5);
|
||||||
|
if (item is Label || item is CheckBox) item.MaximumSize = new Size(width, 0);
|
||||||
|
else if (item is TextBox) item.Width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Label Note(string text)
|
||||||
|
{
|
||||||
|
var label = new Label { Text = text, AutoSize = true };
|
||||||
|
Add(label);
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Link(string label, string target)
|
||||||
|
{
|
||||||
|
var link = new LinkLabel { Text = label, AutoSize = true };
|
||||||
|
link.LinkClicked += delegate
|
||||||
|
{
|
||||||
|
try { using (Process.Start(new ProcessStartInfo(target) { UseShellExecute = true })) { } }
|
||||||
|
catch (Exception error) { ShowError(error); }
|
||||||
|
};
|
||||||
|
Add(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowChecks()
|
||||||
|
{
|
||||||
|
page = 0;
|
||||||
|
Screen("SE-LTD SETUP / 01", "Voraussetzungen prüfen", "Jetzt prüfen", false);
|
||||||
|
Note("Installiere zuerst Visual Studio Code, WSL, Docker Desktop und Git für Windows. Der Assistent prüft alle Voraussetzungen und macht erst weiter, wenn sie verfügbar sind.");
|
||||||
|
foreach (var item in setup.Config.prerequisites)
|
||||||
|
if (!string.IsNullOrWhiteSpace(item.help) && item.id != "docker") Link(item.label + " installieren", item.help);
|
||||||
|
Note("Für BACnet in Docker Desktop unter Settings → Resources → Network das Host Networking aktivieren.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowFolder()
|
||||||
|
{
|
||||||
|
page = 1;
|
||||||
|
Screen("SE-LTD SETUP / 02", "Installationsordner wählen", "Projekt holen", true);
|
||||||
|
Note("Bei einer Neuinstallation kannst du den vorgeschlagenen Ordner übernehmen. Für ein Update wählst du den vorhandenen SE-LTD-Projektordner.");
|
||||||
|
input = new TextBox { Text = folder, AccessibleName = "Installationsordner" };
|
||||||
|
Add(input);
|
||||||
|
var browse = new Button { Text = "Ordner auswählen …", AutoSize = true };
|
||||||
|
browse.Click += delegate
|
||||||
|
{
|
||||||
|
using (var dialog = new FolderBrowserDialog { Description = "Leeren Ordner oder vorhandenes SE-LTD-Repository auswählen" })
|
||||||
|
{
|
||||||
|
if (Directory.Exists(input.Text)) dialog.SelectedPath = input.Text;
|
||||||
|
if (dialog.ShowDialog(this) == DialogResult.OK) input.Text = dialog.SelectedPath;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Add(browse);
|
||||||
|
Note("Quelle: " + setup.Config.repository.url + " (" + setup.Config.repository.branch + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowVariable()
|
||||||
|
{
|
||||||
|
page = 2;
|
||||||
|
var item = setup.Config.variables[variableIndex];
|
||||||
|
Screen("EINRICHTUNG / " + (variableIndex + 1) + " VON " + setup.Config.variables.Length,
|
||||||
|
item.label, variableIndex == setup.Config.variables.Length - 1 ? "SE-LTD installieren" : "Weiter", true);
|
||||||
|
Note(item.description);
|
||||||
|
Note(item.name).ForeColor = SystemColors.GrayText;
|
||||||
|
if (item.type == "legacyPassword" || item.type == "remoteAccess")
|
||||||
|
{
|
||||||
|
choice = new CheckBox
|
||||||
|
{
|
||||||
|
Text = item.type == "legacyPassword" ? "Ja, vorhandene Controller übernehmen" : "Ja, Zugriff aus dem Netzwerk erlauben",
|
||||||
|
AutoSize = true,
|
||||||
|
Checked = item.type == "legacyPassword" ? setup.Legacy : setup.Remote
|
||||||
|
};
|
||||||
|
Add(choice);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool secret = item.type == "secret" || item.type == "legacyPassword" || item.type == "sameAs";
|
||||||
|
input = new TextBox
|
||||||
|
{
|
||||||
|
Text = item.type == "sameAs" ? setup.Values[item.source] : setup.Values[item.name],
|
||||||
|
ReadOnly = item.type == "template" || item.type == "sameAs" || item.type == "remoteAccess",
|
||||||
|
UseSystemPasswordChar = secret,
|
||||||
|
AccessibleName = item.label
|
||||||
|
};
|
||||||
|
Add(input);
|
||||||
|
|
||||||
|
Button generate = null;
|
||||||
|
if (secret)
|
||||||
|
{
|
||||||
|
var tools = new FlowLayoutPanel { AutoSize = true };
|
||||||
|
if (item.type != "sameAs")
|
||||||
|
{
|
||||||
|
generate = new Button { Text = "Sicher erzeugen", AutoSize = true };
|
||||||
|
generate.Click += delegate { input.Text = SetupEngine.GenerateSecret(); };
|
||||||
|
tools.Controls.Add(generate);
|
||||||
|
}
|
||||||
|
var reveal = new CheckBox { Text = "Passwort anzeigen", AutoSize = true, Margin = new Padding(6, 7, 0, 0) };
|
||||||
|
reveal.CheckedChanged += delegate { input.UseSystemPasswordChar = !reveal.Checked; };
|
||||||
|
tools.Controls.Add(reveal);
|
||||||
|
Add(tools);
|
||||||
|
}
|
||||||
|
if (item.type == "legacyPassword")
|
||||||
|
{
|
||||||
|
Action update = () =>
|
||||||
|
{
|
||||||
|
if (choice.Checked) input.Text = item.legacyValue;
|
||||||
|
else if (input.Text == item.legacyValue) input.Text = SetupEngine.GenerateSecret();
|
||||||
|
input.ReadOnly = choice.Checked;
|
||||||
|
generate.Enabled = !choice.Checked;
|
||||||
|
};
|
||||||
|
choice.CheckedChanged += delegate { update(); };
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
if (item.type == "remoteAccess")
|
||||||
|
{
|
||||||
|
Action update = () => { input.Text = choice.Checked ? "*" : setup.LocalOrigin; };
|
||||||
|
choice.CheckedChanged += delegate { update(); };
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
validation = Note("");
|
||||||
|
validation.ForeColor = Color.Firebrick;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowExisting()
|
||||||
|
{
|
||||||
|
page = 3;
|
||||||
|
Screen("SE-LTD SETUP / 03", "Vorhandene Installation gefunden", "SE-LTD aktualisieren", true);
|
||||||
|
Note("Die vorhandene .env wird unverändert übernommen. Datenbankdaten und Passwörter bleiben erhalten. Der Assistent baut und startet die Dienste mit der bestehenden Konfiguration.");
|
||||||
|
Note(setup.Folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowProgress(string title)
|
||||||
|
{
|
||||||
|
page = 4;
|
||||||
|
Screen("SE-LTD SETUP / LÄUFT", title, "Erneut versuchen", false);
|
||||||
|
log = new TextBox { ReadOnly = true, Multiline = true, ScrollBars = ScrollBars.Vertical, Height = 200, AccessibleName = "Installationsfortschritt" };
|
||||||
|
Add(log);
|
||||||
|
SetBusy(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetBusy(bool value)
|
||||||
|
{
|
||||||
|
busy = value;
|
||||||
|
back.Enabled = !value;
|
||||||
|
next.Enabled = !value;
|
||||||
|
UseWaitCursor = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Progress(string line)
|
||||||
|
{
|
||||||
|
BeginInvoke(new Action(() => log.AppendText(line + Environment.NewLine)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowSuccess()
|
||||||
|
{
|
||||||
|
page = 5;
|
||||||
|
Screen("SE-LTD SETUP / FERTIG", "SE-LTD ist bereit", "Schließen", false);
|
||||||
|
Note("Weboberfläche, API und Collector haben erfolgreich geantwortet.");
|
||||||
|
Link("SE-LTD im Browser öffnen", setup.WebUrl);
|
||||||
|
Link("Installationsordner öffnen", setup.Folder);
|
||||||
|
Note("Die Zugangsdaten stehen in der .env im Installationsordner. Gib diese Datei nicht weiter.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnNext(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (busy) return;
|
||||||
|
if (page == 0)
|
||||||
|
{
|
||||||
|
SetBusy(true);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var results = await Task.Run(() => Array.FindAll(setup.Config.prerequisites, item =>
|
||||||
|
{
|
||||||
|
try { return !setup.Check(item); }
|
||||||
|
catch (Exception) { return true; }
|
||||||
|
}));
|
||||||
|
if (results.Length == 0) ShowFolder();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowChecks();
|
||||||
|
foreach (var item in results) Note("Fehlt oder antwortet nicht: " + item.label).ForeColor = Color.Firebrick;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally { SetBusy(false); }
|
||||||
|
}
|
||||||
|
else if (page == 1)
|
||||||
|
{
|
||||||
|
var target = input.Text.Trim().Trim('"');
|
||||||
|
bool unc = target.StartsWith(@"\\");
|
||||||
|
bool absoluteDrive = target.Length >= 3 && char.IsLetter(target[0]) && target[1] == ':' &&
|
||||||
|
(target[2] == '\\' || target[2] == '/');
|
||||||
|
if (!unc && !absoluteDrive)
|
||||||
|
{
|
||||||
|
ShowError(new ArgumentException("Bitte einen vollständigen Installationspfad auswählen."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
folder = target;
|
||||||
|
ShowProgress("Projekt wird vorbereitet");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await Task.Run(() => setup.Prepare(folder, Progress));
|
||||||
|
if (setup.ExistingEnvironment) ShowExisting();
|
||||||
|
else { variableIndex = 0; ShowVariable(); }
|
||||||
|
}
|
||||||
|
catch (Exception error) { ShowError(error); ShowFolder(); }
|
||||||
|
finally { SetBusy(false); }
|
||||||
|
}
|
||||||
|
else if (page == 2)
|
||||||
|
{
|
||||||
|
var item = setup.Config.variables[variableIndex];
|
||||||
|
var value = input.Text.Trim();
|
||||||
|
var error = setup.Validate(item, value, item.type == "legacyPassword" && choice.Checked);
|
||||||
|
if (error != null) { validation.Text = error; return; }
|
||||||
|
if (item.type == "legacyPassword") setup.Legacy = choice.Checked;
|
||||||
|
if (item.type == "remoteAccess") setup.Remote = choice.Checked;
|
||||||
|
setup.Values[item.name] = value;
|
||||||
|
if (variableIndex + 1 < setup.Config.variables.Length) { ++variableIndex; ShowVariable(); }
|
||||||
|
else await Install();
|
||||||
|
}
|
||||||
|
else if (page == 3 || page == 4) await Install();
|
||||||
|
else if (page == 5) Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Install()
|
||||||
|
{
|
||||||
|
ShowProgress("SE-LTD wird installiert");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await Task.Run(() => setup.Install(Progress));
|
||||||
|
ShowSuccess();
|
||||||
|
}
|
||||||
|
catch (Exception error)
|
||||||
|
{
|
||||||
|
log.AppendText(Environment.NewLine + error.Message);
|
||||||
|
ShowError(error);
|
||||||
|
}
|
||||||
|
finally { SetBusy(false); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnBack(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (busy) return;
|
||||||
|
if (page == 1) ShowChecks();
|
||||||
|
else if (page == 3 || (page == 2 && variableIndex == 0)) ShowFolder();
|
||||||
|
else if (page == 2) { --variableIndex; ShowVariable(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowError(Exception error)
|
||||||
|
{
|
||||||
|
MessageBox.Show(this, error.Message, "SE-LTD Setup", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
param([switch] $Test, [switch] $TestDatabase)
|
||||||
|
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$source = $PSScriptRoot
|
||||||
|
$dist = Join-Path $source 'dist'
|
||||||
|
$package = Join-Path $dist 'SE-LTD-Setup'
|
||||||
|
$archive = Join-Path $dist 'SE-LTD-Setup.zip'
|
||||||
|
$framework = Join-Path $env:WINDIR 'Microsoft.NET'
|
||||||
|
$csc = @('Framework64', 'Framework') |
|
||||||
|
ForEach-Object { Join-Path $framework "$_\v4.0.30319\csc.exe" } |
|
||||||
|
Where-Object { Test-Path -LiteralPath $_ } |
|
||||||
|
Select-Object -First 1
|
||||||
|
if (-not $csc) { throw 'Der .NET-Framework-C#-Compiler fehlt.' }
|
||||||
|
|
||||||
|
New-Item -ItemType Directory -Force -Path $package | Out-Null
|
||||||
|
$exe = Join-Path $package 'SE-LTD-Setup.exe'
|
||||||
|
$arguments = @(
|
||||||
|
'/nologo', '/target:winexe', '/platform:anycpu', '/optimize+', '/codepage:65001', "/out:$exe",
|
||||||
|
'/reference:System.Windows.Forms.dll', '/reference:System.Drawing.dll', '/reference:System.Web.Extensions.dll',
|
||||||
|
(Join-Path $source 'SetupEngine.cs'), (Join-Path $source 'SetupWizard.cs')
|
||||||
|
)
|
||||||
|
& $csc @arguments
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw 'SE-LTD Setup konnte nicht kompiliert werden.' }
|
||||||
|
|
||||||
|
if ($Test -or $TestDatabase) {
|
||||||
|
$testExe = Join-Path $dist 'SE-LTD-Setup-SmokeTests.exe'
|
||||||
|
$testArguments = @(
|
||||||
|
'/nologo', '/target:exe', '/codepage:65001', '/main:SeLtd.Setup.SetupSmokeTests', "/out:$testExe",
|
||||||
|
'/reference:System.Windows.Forms.dll', '/reference:System.Drawing.dll', '/reference:System.Web.Extensions.dll',
|
||||||
|
(Join-Path $source 'SetupEngine.cs'), (Join-Path $source 'SetupWizard.cs'), (Join-Path $source 'SetupSmokeTests.cs')
|
||||||
|
)
|
||||||
|
& $csc @testArguments
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw 'Der Setup-Test konnte nicht kompiliert werden.' }
|
||||||
|
if ($TestDatabase) { & $testExe $source --database }
|
||||||
|
else { & $testExe $source }
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw 'Der Setup-Test ist fehlgeschlagen.' }
|
||||||
|
}
|
||||||
|
|
||||||
|
$files = 'setup.config.json', 'compose.override.template.yml', 'README.md' |
|
||||||
|
ForEach-Object {
|
||||||
|
Copy-Item -LiteralPath (Join-Path $source $_) -Destination $package -Force
|
||||||
|
Join-Path $package $_
|
||||||
|
}
|
||||||
|
Compress-Archive -Path (@($exe) + $files) -DestinationPath $archive -Force
|
||||||
|
Get-Item -LiteralPath $exe, $archive
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Generated by SE-LTD Setup from compose.override.template.yml.
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
ports: !override
|
||||||
|
- "{{WEB_BIND}}:{{WEB_PORT}}:5173"
|
||||||
|
api:
|
||||||
|
ports: !override
|
||||||
|
- "{{WEB_BIND}}:{{API_PORT}}:8080"
|
||||||
|
collector:
|
||||||
|
ports: !override
|
||||||
|
- "{{WEB_BIND}}:18110:18110"
|
||||||
|
mariadb:
|
||||||
|
environment:
|
||||||
|
MARIADB_ROOT_HOST: "%"
|
||||||
|
ports: !override
|
||||||
|
- "{{DB_BIND}}:3306:3306"
|
||||||
|
volumes:
|
||||||
|
- ./.seltd-setup/mariadb-init:/docker-entrypoint-initdb.d:ro
|
||||||
|
dockhand:
|
||||||
|
ports: !override
|
||||||
|
- "127.0.0.1:3008:3000"
|
||||||
|
cadvisor:
|
||||||
|
ports: !override
|
||||||
|
- "127.0.0.1:9090:8080"
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"repository": {
|
||||||
|
"url": "https://git.portal.se-cloud.de/Hannes/SE-LTD.git",
|
||||||
|
"branch": "main",
|
||||||
|
"folder": "%LOCALAPPDATA%\\SE-LTD"
|
||||||
|
},
|
||||||
|
"prerequisites": [
|
||||||
|
{ "id": "code", "label": "Visual Studio Code", "executable": "Code.exe", "paths": ["%LOCALAPPDATA%\\Programs\\Microsoft VS Code\\Code.exe", "%ProgramFiles%\\Microsoft VS Code\\Code.exe", "%ProgramFiles(x86)%\\Microsoft VS Code\\Code.exe"], "help": "https://code.visualstudio.com/download" },
|
||||||
|
{ "id": "wsl", "label": "Windows-Subsystem für Linux (WSL)", "executable": "wsl.exe", "probe": ["--version"], "help": "https://learn.microsoft.com/windows/wsl/install" },
|
||||||
|
{ "id": "desktop", "label": "Docker Desktop", "executable": "Docker Desktop.exe", "paths": ["%ProgramFiles%\\Docker\\Docker\\Docker Desktop.exe", "%LOCALAPPDATA%\\Programs\\DockerDesktop\\Docker Desktop.exe"], "help": "https://docs.docker.com/desktop/setup/install/windows-install/" },
|
||||||
|
{ "id": "docker", "label": "Docker Compose (Teil von Docker Desktop)", "executable": "docker.exe", "paths": ["%ProgramFiles%\\Docker\\Docker\\resources\\bin\\docker.exe", "%LOCALAPPDATA%\\Programs\\DockerDesktop\\resources\\bin\\docker.exe"], "probe": ["compose", "version"], "help": "https://docs.docker.com/desktop/setup/install/windows-install/" },
|
||||||
|
{ "id": "git", "label": "Git für Windows", "executable": "git.exe", "paths": ["%ProgramFiles%\\Git\\cmd\\git.exe", "%LOCALAPPDATA%\\Programs\\Git\\cmd\\git.exe"], "probe": ["--version"], "help": "https://git-scm.com/install/windows" }
|
||||||
|
],
|
||||||
|
"variables": [
|
||||||
|
{ "name": "JWT_SECRET", "label": "Schlüssel für Anmeldesitzungen", "type": "secret", "description": "Dieser Schlüssel schützt die Anmeldung. Der Assistent erzeugt ihn für dich." },
|
||||||
|
{ "name": "ADMIN_USERNAME", "label": "Benutzername für die Anmeldung", "type": "template", "description": "Der Standard aus der Vorlage wird beibehalten." },
|
||||||
|
{ "name": "ADMIN_EMAIL", "label": "E-Mail-Adresse des Administrators", "type": "email", "description": "Optional. Wenn du keine eigene Adresse eintragen möchtest, lass den Standard stehen." },
|
||||||
|
{ "name": "ADMIN_PASSWORD", "label": "Passwort für die Weboberfläche", "type": "secret", "description": "Mit diesem Passwort meldest du dich später an. Übernimm den Vorschlag oder vergib ein eigenes Passwort." },
|
||||||
|
{ "name": "ADMIN_NAME", "label": "Anzeigename des Administrators", "type": "template", "description": "Der Standard aus der Vorlage wird beibehalten." },
|
||||||
|
{ "name": "MARIADB_ROOT_PASSWORD", "label": "Internes Datenbankpasswort", "type": "secret", "description": "SE-LTD verwendet dieses Passwort für den Zugriff auf die Datenbank. Übernimm im Normalfall den erzeugten Vorschlag." },
|
||||||
|
{ "name": "MARIADB_PASSWORD", "label": "Ist das eine Bestandsanlage mit vorhandenen Controllern?", "type": "legacyPassword", "legacyValue": "3112", "description": "Wähle Ja, wenn vorhandene Controller weiterhin mit ihrem bisherigen Zugang schreiben müssen. Der Datenbank-Port wird dann im Netzwerk freigegeben. Bei einer neuen Anlage bleibt er lokal." },
|
||||||
|
{ "name": "DB_PASSWORD_FALLBACK", "label": "Ersatzpasswort der Datenbank", "type": "sameAs", "source": "MARIADB_ROOT_PASSWORD", "description": "Der Assistent übernimmt automatisch das interne Datenbankpasswort, damit kein schwaches Ersatzpasswort stehen bleibt." },
|
||||||
|
{ "name": "REDIS_PASSWORD", "label": "Passwort für den internen Zwischenspeicher", "type": "secret", "description": "Das Passwort wird nur von SE-LTD verwendet. Übernimm im Normalfall den erzeugten Vorschlag." },
|
||||||
|
{ "name": "LEGACY_TREND_TIME_ZONE", "label": "Zeitzone der Bestands-Trenddaten", "type": "text", "description": "Für Anlagen in Deutschland lass Europe/Berlin stehen. Andernfalls trage die passende IANA-Zeitzone ein, z. B. Europe/Vienna." },
|
||||||
|
{ "name": "VITE_API_PORT", "label": "Port der API", "type": "port", "description": "Lass den Port auf 18080, sofern er nicht von einem anderen Programm belegt ist." },
|
||||||
|
{ "name": "CORS_ORIGIN", "label": "Soll SE-LTD von einem anderen Rechner erreichbar sein?", "type": "remoteAccess", "description": "Nein beschränkt die Weboberfläche und ihre APIs auf diesen Rechner. Ja veröffentlicht sie im Netzwerk und erlaubt Browserzugriffe aus allen Origins. Nutze das nur in einem vertrauenswürdigen Netz." }
|
||||||
|
],
|
||||||
|
"prepare": [
|
||||||
|
{ "action": "checkout", "label": "Projekt von Git holen oder mit Git Pull aktualisieren" },
|
||||||
|
{ "action": "template", "label": "Vorlage .env.example einlesen" }
|
||||||
|
],
|
||||||
|
"install": [
|
||||||
|
{ "action": "dockerReady", "label": "Docker Desktop starten und Verbindung prüfen", "timeout": 180 },
|
||||||
|
{ "action": "writeSetup", "label": "Lokale Installationseinstellungen schreiben" },
|
||||||
|
{ "action": "command", "label": "Docker-Konfiguration prüfen", "tool": "docker", "arguments": ["compose", "--env-file", ".env", "config", "--quiet"], "timeout": 60 },
|
||||||
|
{ "action": "command", "label": "Alle SE-LTD-Dienste bauen und starten", "tool": "docker", "arguments": ["compose", "--env-file", ".env", "up", "-d", "--build", "--wait", "--wait-timeout", "240"], "timeout": 2400 },
|
||||||
|
{ "action": "http", "label": "Weboberfläche prüfen", "url": "http://127.0.0.1:{{WEB_PORT}}/", "timeout": 45 },
|
||||||
|
{ "action": "http", "label": "API prüfen", "url": "http://127.0.0.1:{{API_PORT}}/api/health", "timeout": 45 },
|
||||||
|
{ "action": "http", "label": "Collector prüfen", "url": "http://127.0.0.1:18110/health", "timeout": 45 }
|
||||||
|
],
|
||||||
|
"dockerContext": "desktop-linux",
|
||||||
|
"webPort": 81,
|
||||||
|
"composeTemplate": "compose.override.template.yml",
|
||||||
|
"mariaDbInitDirectory": "docker/mariadb/init",
|
||||||
|
"legacySqlPrefixes": [
|
||||||
|
"CREATE USER IF NOT EXISTS 'root'@'%' IDENTIFIED BY",
|
||||||
|
"GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'",
|
||||||
|
"CREATE USER IF NOT EXISTS 'wago'@'%' IDENTIFIED BY",
|
||||||
|
"GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX ON * . * TO 'wago'@'%' IDENTIFIED BY"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in new issue
Block a user