1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 13:08:17 -05:00

print environment after start

This commit is contained in:
Kyle Spearrin 2017-08-24 11:16:01 -04:00
parent 17777dac78
commit e7351753c7
4 changed files with 39 additions and 5 deletions

View File

@ -41,6 +41,11 @@ function Update-Database {
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
if($start -Or $restart) {
@ -48,6 +53,7 @@ if($start -Or $restart) {
Update-Lets-Encrypt
Docker-Compose-Up
Docker-Prune
Print-Environment
}
elseif($stop) {
Docker-Compose-Down

View File

@ -51,6 +51,11 @@ function updateDatabase() {
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
if [ "$1" == "start" -o "$1" == "restart" ]
@ -59,6 +64,7 @@ then
updateLetsEncrypt
dockerComposeUp
dockerPrune
printEnvironment
elif [ "$1" == "stop" ]
then
dockerComposeDown

View File

@ -108,17 +108,17 @@ namespace Setup
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;
}
var lines = File.ReadAllLines("/bitwarden/env/mssql.override.env");
var lines = File.ReadAllLines($"/bitwarden/env/{envFile}.override.env");
foreach(var line in lines)
{
if(line.StartsWith("SA_PASSWORD="))
if(line.StartsWith($"{key}="))
{
return line.Split(new char[] { '=' }, 2)[1];
}

View File

@ -38,6 +38,10 @@ namespace Setup
{
Update();
}
else if(_parameters.ContainsKey("printenv"))
{
PrintEnvironment();
}
else
{
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()
{
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 vaultConnectionString = Helpers.MakeSqlConnectionString("mssql", "vault", "sa", dbPass ?? string.Empty);