diff --git a/POC/bwsh/Commands/BackupCommand.cs b/POC/bwsh/Commands/BackupCommand.cs index 71c580b..c4c95f6 100644 --- a/POC/bwsh/Commands/BackupCommand.cs +++ b/POC/bwsh/Commands/BackupCommand.cs @@ -28,7 +28,7 @@ public static class BackupCommand cmd.SetAction(async (parseResult, ct) => { - var kind = Cli.ResolveKind(parseResult.GetValue(deployment), null); + var kind = Cli.ResolveInstalledKind(parseResult.GetValue(deployment), parseResult.GetValue(root)!); var dep = DeploymentFactory.Create(kind); var rootDir = parseResult.GetValue(root)!; diff --git a/POC/bwsh/Commands/Cli.cs b/POC/bwsh/Commands/Cli.cs index 4b9a62d..b6bcf79 100644 --- a/POC/bwsh/Commands/Cli.cs +++ b/POC/bwsh/Commands/Cli.cs @@ -71,6 +71,28 @@ public static class Cli : manifest is not null ? DeploymentFactory.Parse(manifest.Deployment) : DeploymentKind.Standard; + /// + /// Detect which deployment is installed under by probing each + /// deployment's marker file (standard: config.yml, lite: settings.env). Returns null when + /// neither is present (nothing installed yet). + /// + public static DeploymentKind? DetectInstalledKind(string root) + { + foreach (var kind in Enum.GetValues()) + if (File.Exists(Path.Combine(root, DeploymentFactory.Create(kind).InstalledMarker))) + return kind; + return null; + } + + /// + /// Resolve the deployment to act on for an EXISTING install (status/logs/update/etc.): + /// explicit --deployment wins, else auto-detect from on-disk markers, else fall back to + /// standard so the usual "not found" message still surfaces for an empty directory. + /// + public static DeploymentKind ResolveInstalledKind(string? deploymentFlag, string root) => + deploymentFlag is not null ? DeploymentFactory.Parse(deploymentFlag) + : DetectInstalledKind(root) ?? DeploymentKind.Standard; + public static void ApplyManifestValue(InstallManifest m, string key, string value) { switch (key) diff --git a/POC/bwsh/Commands/ConfigCommand.cs b/POC/bwsh/Commands/ConfigCommand.cs index 44cdd28..dd4b364 100644 --- a/POC/bwsh/Commands/ConfigCommand.cs +++ b/POC/bwsh/Commands/ConfigCommand.cs @@ -21,7 +21,7 @@ public static class ConfigCommand cmd.SetAction(parseResult => { - var kind = Cli.ResolveKind(parseResult.GetValue(deployment), null); + var kind = Cli.ResolveInstalledKind(parseResult.GetValue(deployment), parseResult.GetValue(root)!); var dep = DeploymentFactory.Create(kind); var rootDir = parseResult.GetValue(root)!; var arg = parseResult.GetValue(assignment); diff --git a/POC/bwsh/Commands/LogsCommand.cs b/POC/bwsh/Commands/LogsCommand.cs index bcde3d3..98bbe76 100644 --- a/POC/bwsh/Commands/LogsCommand.cs +++ b/POC/bwsh/Commands/LogsCommand.cs @@ -41,7 +41,7 @@ public static class LogsCommand cmd.SetAction(async (parseResult, ct) => { - var kind = Cli.ResolveKind(parseResult.GetValue(deployment), null); + var kind = Cli.ResolveInstalledKind(parseResult.GetValue(deployment), parseResult.GetValue(root)!); var dep = DeploymentFactory.Create(kind); var svc = parseResult.GetValue(service); var lines = parseResult.GetValue(all) ? 0 : parseResult.GetValue(tail); // 0 => full log diff --git a/POC/bwsh/Commands/MigrateCommand.cs b/POC/bwsh/Commands/MigrateCommand.cs index 944e1db..48aadb4 100644 --- a/POC/bwsh/Commands/MigrateCommand.cs +++ b/POC/bwsh/Commands/MigrateCommand.cs @@ -26,7 +26,7 @@ public static class MigrateCommand cmd.SetAction(async (parseResult, ct) => { - var kind = Cli.ResolveKind(parseResult.GetValue(deployment), null); + var kind = Cli.ResolveInstalledKind(parseResult.GetValue(deployment), parseResult.GetValue(root)!); var dep = DeploymentFactory.Create(kind); var rootDir = parseResult.GetValue(root)!; diff --git a/POC/bwsh/Commands/RenewCertCommand.cs b/POC/bwsh/Commands/RenewCertCommand.cs index c3a656c..8aff192 100644 --- a/POC/bwsh/Commands/RenewCertCommand.cs +++ b/POC/bwsh/Commands/RenewCertCommand.cs @@ -23,7 +23,7 @@ public static class RenewCertCommand cmd.SetAction(async (parseResult, ct) => { - var kind = Cli.ResolveKind(parseResult.GetValue(deployment), null); + var kind = Cli.ResolveInstalledKind(parseResult.GetValue(deployment), parseResult.GetValue(root)!); if (kind != DeploymentKind.Standard) { Cli.Error("renewcert is for standard deployments; lite manages TLS in-container."); diff --git a/POC/bwsh/Commands/RestoreCommand.cs b/POC/bwsh/Commands/RestoreCommand.cs index aaa493e..d79e057 100644 --- a/POC/bwsh/Commands/RestoreCommand.cs +++ b/POC/bwsh/Commands/RestoreCommand.cs @@ -28,7 +28,7 @@ public static class RestoreCommand cmd.SetAction(async (parseResult, ct) => { var archivePath = parseResult.GetValue(archive)!; - var kind = Cli.ResolveKind(parseResult.GetValue(deployment), null); + var kind = Cli.ResolveInstalledKind(parseResult.GetValue(deployment), parseResult.GetValue(root)!); var dep = DeploymentFactory.Create(kind); var rootDir = parseResult.GetValue(root)!; diff --git a/POC/bwsh/Commands/StatusCommand.cs b/POC/bwsh/Commands/StatusCommand.cs index 0662fb7..69fbf0c 100644 --- a/POC/bwsh/Commands/StatusCommand.cs +++ b/POC/bwsh/Commands/StatusCommand.cs @@ -20,7 +20,7 @@ public static class StatusCommand cmd.SetAction(async (parseResult, ct) => { - var kind = Cli.ResolveKind(parseResult.GetValue(deployment), null); + var kind = Cli.ResolveInstalledKind(parseResult.GetValue(deployment), parseResult.GetValue(root)!); var dep = DeploymentFactory.Create(kind); var rootDir = parseResult.GetValue(root)!; diff --git a/POC/bwsh/Commands/UninstallCommand.cs b/POC/bwsh/Commands/UninstallCommand.cs index 61c46eb..f79359a 100644 --- a/POC/bwsh/Commands/UninstallCommand.cs +++ b/POC/bwsh/Commands/UninstallCommand.cs @@ -25,7 +25,7 @@ public static class UninstallCommand cmd.SetAction(async (parseResult, ct) => { - var kind = Cli.ResolveKind(parseResult.GetValue(deployment), null); + var kind = Cli.ResolveInstalledKind(parseResult.GetValue(deployment), parseResult.GetValue(root)!); var dep = DeploymentFactory.Create(kind); var rootDir = parseResult.GetValue(root)!; var doPurge = parseResult.GetValue(purge); diff --git a/POC/bwsh/Commands/UpdateCommand.cs b/POC/bwsh/Commands/UpdateCommand.cs index 7faac52..9730765 100644 --- a/POC/bwsh/Commands/UpdateCommand.cs +++ b/POC/bwsh/Commands/UpdateCommand.cs @@ -34,7 +34,7 @@ public static class UpdateCommand cmd.SetAction(async (parseResult, ct) => { - var kind = Cli.ResolveKind(parseResult.GetValue(deployment), null); + var kind = Cli.ResolveInstalledKind(parseResult.GetValue(deployment), parseResult.GetValue(root)!); var dep = DeploymentFactory.Create(kind); var rootDir = parseResult.GetValue(root)!; diff --git a/POC/bwsh/bitwarden-lite.yaml b/POC/bwsh/bitwarden-lite.yaml new file mode 100644 index 0000000..5c53614 --- /dev/null +++ b/POC/bwsh/bitwarden-lite.yaml @@ -0,0 +1,13 @@ +deployment: lite +domain: localhost +db-provider: sqlite +db-file: /etc/bitwarden/vault.db +installation-id: 94389b62-6b3f-413e-8bbb-6c9e4ed83cb3 +installation-key: bwsh-demo +config: + globalSettings__mail__smtp__host: host.docker.internal + globalSettings__mail__smtp__port: "1025" + globalSettings__mail__smtp__ssl: "false" + globalSettings__mail__smtp__startTls: "false" + globalSettings__mail__smtp__username: "" + globalSettings__mail__smtp__password: ""