mirror of
https://github.com/bitwarden/self-host.git
synced 2026-06-28 14:25:45 +00:00
Resolve Installed kind, so that commands work by default and auto detect the deployed type.
- Add bitwarden-lite.yaml test manifest
This commit is contained in:
@@ -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)!;
|
||||
|
||||
|
||||
@@ -71,6 +71,28 @@ public static class Cli
|
||||
: manifest is not null ? DeploymentFactory.Parse(manifest.Deployment)
|
||||
: DeploymentKind.Standard;
|
||||
|
||||
/// <summary>
|
||||
/// Detect which deployment is installed under <paramref name="root"/> by probing each
|
||||
/// deployment's marker file (standard: config.yml, lite: settings.env). Returns null when
|
||||
/// neither is present (nothing installed yet).
|
||||
/// </summary>
|
||||
public static DeploymentKind? DetectInstalledKind(string root)
|
||||
{
|
||||
foreach (var kind in Enum.GetValues<DeploymentKind>())
|
||||
if (File.Exists(Path.Combine(root, DeploymentFactory.Create(kind).InstalledMarker)))
|
||||
return kind;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)!;
|
||||
|
||||
|
||||
@@ -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.");
|
||||
|
||||
@@ -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)!;
|
||||
|
||||
|
||||
@@ -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)!;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)!;
|
||||
|
||||
|
||||
13
POC/bwsh/bitwarden-lite.yaml
Normal file
13
POC/bwsh/bitwarden-lite.yaml
Normal file
@@ -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: ""
|
||||
Reference in New Issue
Block a user