1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 15:42:48 -05:00

mssql image setup script, db up migrations with upgrade from setup

This commit is contained in:
Kyle Spearrin
2017-08-18 18:22:25 -04:00
parent 1fd7f5dd03
commit d4809686db
9 changed files with 141 additions and 10 deletions

View File

@ -1,6 +1,8 @@
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Setup
{
@ -87,5 +89,31 @@ namespace Setup
return characters;
}
public static string MakeSqlConnectionString(string server, string database, string username, string password)
{
return $"Server=tcp:{server},1433;Initial Catalog={database};Persist Security Info=False;User ID={username};" +
$"Password={password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;" +
"Connection Timeout=30;";
}
public static string GetDatabasePasswordFronEnvFile()
{
if(!File.Exists("/bitwarden/docker/mssql.override.env"))
{
return null;
}
var lines = File.ReadAllLines("/bitwarden/docker/mssql.override.env");
foreach(var line in lines)
{
if(line.StartsWith("SA_PASSWORD="))
{
return line.Split(new char[] { '=' }, 2)[1];
}
}
return null;
}
}
}