mirror of
https://github.com/bitwarden/server.git
synced 2025-04-06 05:28:15 -05:00
print environment after start
This commit is contained in:
parent
17777dac78
commit
e7351753c7
@ -41,6 +41,11 @@ function Update-Database {
|
|||||||
echo "Database update complete"
|
echo "Database update complete"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Print-Environment {
|
||||||
|
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup `
|
||||||
|
dotnet Setup.dll -printenv 1 -env win
|
||||||
|
}
|
||||||
|
|
||||||
# Commands
|
# Commands
|
||||||
|
|
||||||
if($start -Or $restart) {
|
if($start -Or $restart) {
|
||||||
@ -48,6 +53,7 @@ if($start -Or $restart) {
|
|||||||
Update-Lets-Encrypt
|
Update-Lets-Encrypt
|
||||||
Docker-Compose-Up
|
Docker-Compose-Up
|
||||||
Docker-Prune
|
Docker-Prune
|
||||||
|
Print-Environment
|
||||||
}
|
}
|
||||||
elseif($stop) {
|
elseif($stop) {
|
||||||
Docker-Compose-Down
|
Docker-Compose-Down
|
||||||
|
@ -51,6 +51,11 @@ function updateDatabase() {
|
|||||||
echo "Database update complete"
|
echo "Database update complete"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function printEnvironment() {
|
||||||
|
docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden bitwarden/setup \
|
||||||
|
dotnet Setup.dll -printenv 1 -env $OS
|
||||||
|
}
|
||||||
|
|
||||||
# Commands
|
# Commands
|
||||||
|
|
||||||
if [ "$1" == "start" -o "$1" == "restart" ]
|
if [ "$1" == "start" -o "$1" == "restart" ]
|
||||||
@ -59,6 +64,7 @@ then
|
|||||||
updateLetsEncrypt
|
updateLetsEncrypt
|
||||||
dockerComposeUp
|
dockerComposeUp
|
||||||
dockerPrune
|
dockerPrune
|
||||||
|
printEnvironment
|
||||||
elif [ "$1" == "stop" ]
|
elif [ "$1" == "stop" ]
|
||||||
then
|
then
|
||||||
dockerComposeDown
|
dockerComposeDown
|
||||||
|
@ -108,17 +108,17 @@ namespace Setup
|
|||||||
return builder.ConnectionString;
|
return builder.ConnectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetDatabasePasswordFronEnvFile()
|
public static string GetValueFronEnvFile(string envFile, string key)
|
||||||
{
|
{
|
||||||
if(!File.Exists("/bitwarden/env/mssql.override.env"))
|
if(!File.Exists($"/bitwarden/env/{envFile}.override.env"))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lines = File.ReadAllLines("/bitwarden/env/mssql.override.env");
|
var lines = File.ReadAllLines($"/bitwarden/env/{envFile}.override.env");
|
||||||
foreach(var line in lines)
|
foreach(var line in lines)
|
||||||
{
|
{
|
||||||
if(line.StartsWith("SA_PASSWORD="))
|
if(line.StartsWith($"{key}="))
|
||||||
{
|
{
|
||||||
return line.Split(new char[] { '=' }, 2)[1];
|
return line.Split(new char[] { '=' }, 2)[1];
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,10 @@ namespace Setup
|
|||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
else if(_parameters.ContainsKey("printenv"))
|
||||||
|
{
|
||||||
|
PrintEnvironment();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("No top-level command detected. Exiting...");
|
Console.WriteLine("No top-level command detected. Exiting...");
|
||||||
@ -93,11 +97,29 @@ namespace Setup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PrintEnvironment()
|
||||||
|
{
|
||||||
|
var vaultUrl = Helpers.GetValueFronEnvFile("global", "globalSettings__baseServiceUri__vault");
|
||||||
|
Console.WriteLine("============================");
|
||||||
|
Console.WriteLine("bitwarden is up and running!");
|
||||||
|
Console.WriteLine("============================");
|
||||||
|
Console.WriteLine("visit {0}", vaultUrl);
|
||||||
|
Console.Write("\nto update, run ");
|
||||||
|
if(_parameters.ContainsKey("env") && _parameters["env"] == "win")
|
||||||
|
{
|
||||||
|
Console.Write(".\bitwarden.ps1 update");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write("./bitwarden.sh update");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void MigrateDatabase()
|
private static void MigrateDatabase()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Migrating database.");
|
Console.WriteLine("Migrating database.");
|
||||||
|
|
||||||
var dbPass = Helpers.GetDatabasePasswordFronEnvFile();
|
var dbPass = Helpers.GetValueFronEnvFile("mssql", "SA_PASSWORD");
|
||||||
var masterConnectionString = Helpers.MakeSqlConnectionString("mssql", "master", "sa", dbPass ?? string.Empty);
|
var masterConnectionString = Helpers.MakeSqlConnectionString("mssql", "master", "sa", dbPass ?? string.Empty);
|
||||||
var vaultConnectionString = Helpers.MakeSqlConnectionString("mssql", "vault", "sa", dbPass ?? string.Empty);
|
var vaultConnectionString = Helpers.MakeSqlConnectionString("mssql", "vault", "sa", dbPass ?? string.Empty);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user