1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-26 17:37:36 +01:00

Feature/add key-connector version to self-hosted scripts (#1784)

* Added Key Connector version

* Fix updatebw() for Key Connector

Co-authored-by: Vince Grassia <593223+vgrassia@users.noreply.github.com>
This commit is contained in:
Micaiah Martin 2021-12-29 09:07:16 -07:00 committed by GitHub
parent 355bf2127b
commit 735f58dd6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 50 additions and 26 deletions

View File

@ -28,6 +28,7 @@ $githubBaseUrl = "https://raw.githubusercontent.com/bitwarden/server/master"
# Please do not create pull requests modifying the version numbers. # Please do not create pull requests modifying the version numbers.
$coreVersion = "1.45.2" $coreVersion = "1.45.2"
$webVersion = "2.25.0" $webVersion = "2.25.0"
$keyConnectorVersion = "1.0.0"
# Functions # Functions
@ -115,36 +116,36 @@ if ($install) {
Test-Output-Dir-Not-Exists Test-Output-Dir-Not-Exists
New-Item -ItemType directory -Path $output -ErrorAction Ignore | Out-Null New-Item -ItemType directory -Path $output -ErrorAction Ignore | Out-Null
Get-Run-File Get-Run-File
Invoke-Expression "& `"$scriptsDir\run.ps1`" -install -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion" Invoke-Expression "& `"$scriptsDir\run.ps1`" -install -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion -keyConnectorVersion $keyConnectorVersion"
} }
elseif ($start -Or $restart) { elseif ($start -Or $restart) {
Test-Output-Dir-Exists Test-Output-Dir-Exists
Invoke-Expression "& `"$scriptsDir\run.ps1`" -restart -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion" Invoke-Expression "& `"$scriptsDir\run.ps1`" -restart -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion -keyConnectorVersion $keyConnectorVersion"
} }
elseif ($update) { elseif ($update) {
Test-Output-Dir-Exists Test-Output-Dir-Exists
Get-Run-File Get-Run-File
Invoke-Expression "& `"$scriptsDir\run.ps1`" -update -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion" Invoke-Expression "& `"$scriptsDir\run.ps1`" -update -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion -keyConnectorVersion $keyConnectorVersion"
} }
elseif ($rebuild) { elseif ($rebuild) {
Test-Output-Dir-Exists Test-Output-Dir-Exists
Invoke-Expression "& `"$scriptsDir\run.ps1`" -rebuild -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion" Invoke-Expression "& `"$scriptsDir\run.ps1`" -rebuild -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion -keyConnectorVersion $keyConnectorVersion"
} }
elseif ($updateconf) { elseif ($updateconf) {
Test-Output-Dir-Exists Test-Output-Dir-Exists
Invoke-Expression "& `"$scriptsDir\run.ps1`" -updateconf -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion" Invoke-Expression "& `"$scriptsDir\run.ps1`" -updateconf -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion -keyConnectorVersion $keyConnectorVersion"
} }
elseif ($updatedb) { elseif ($updatedb) {
Test-Output-Dir-Exists Test-Output-Dir-Exists
Invoke-Expression "& `"$scriptsDir\run.ps1`" -updatedb -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion" Invoke-Expression "& `"$scriptsDir\run.ps1`" -updatedb -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion -keyConnectorVersion $keyConnectorVersion"
} }
elseif ($stop) { elseif ($stop) {
Test-Output-Dir-Exists Test-Output-Dir-Exists
Invoke-Expression "& `"$scriptsDir\run.ps1`" -stop -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion" Invoke-Expression "& `"$scriptsDir\run.ps1`" -stop -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion -keyConnectorVersion $keyConnectorVersion"
} }
elseif ($renewcert) { elseif ($renewcert) {
Test-Output-Dir-Exists Test-Output-Dir-Exists
Invoke-Expression "& `"$scriptsDir\run.ps1`" -renewcert -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion" Invoke-Expression "& `"$scriptsDir\run.ps1`" -renewcert -outputDir `"$output`" -coreVersion $coreVersion -webVersion $webVersion -keyConnectorVersion $keyConnectorVersion"
} }
elseif ($updaterun) { elseif ($updaterun) {
Test-Output-Dir-Exists Test-Output-Dir-Exists

View File

@ -36,6 +36,7 @@ GITHUB_BASE_URL="https://raw.githubusercontent.com/bitwarden/server/master"
# Please do not create pull requests modifying the version numbers. # Please do not create pull requests modifying the version numbers.
COREVERSION="1.45.2" COREVERSION="1.45.2"
WEBVERSION="2.25.0" WEBVERSION="2.25.0"
KEYCONNECTORVERSION="1.0.0"
echo "bitwarden.sh version $COREVERSION" echo "bitwarden.sh version $COREVERSION"
docker --version docker --version
@ -110,36 +111,36 @@ case $1 in
checkOutputDirNotExists checkOutputDirNotExists
mkdir -p $OUTPUT mkdir -p $OUTPUT
downloadRunFile downloadRunFile
$SCRIPTS_DIR/run.sh install $OUTPUT $COREVERSION $WEBVERSION $SCRIPTS_DIR/run.sh install $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
;; ;;
"start" | "restart") "start" | "restart")
checkOutputDirExists checkOutputDirExists
$SCRIPTS_DIR/run.sh restart $OUTPUT $COREVERSION $WEBVERSION $SCRIPTS_DIR/run.sh restart $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
;; ;;
"update") "update")
checkOutputDirExists checkOutputDirExists
downloadRunFile downloadRunFile
$SCRIPTS_DIR/run.sh update $OUTPUT $COREVERSION $WEBVERSION $SCRIPTS_DIR/run.sh update $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
;; ;;
"rebuild") "rebuild")
checkOutputDirExists checkOutputDirExists
$SCRIPTS_DIR/run.sh rebuild $OUTPUT $COREVERSION $WEBVERSION $SCRIPTS_DIR/run.sh rebuild $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
;; ;;
"updateconf") "updateconf")
checkOutputDirExists checkOutputDirExists
$SCRIPTS_DIR/run.sh updateconf $OUTPUT $COREVERSION $WEBVERSION $SCRIPTS_DIR/run.sh updateconf $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
;; ;;
"updatedb") "updatedb")
checkOutputDirExists checkOutputDirExists
$SCRIPTS_DIR/run.sh updatedb $OUTPUT $COREVERSION $WEBVERSION $SCRIPTS_DIR/run.sh updatedb $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
;; ;;
"stop") "stop")
checkOutputDirExists checkOutputDirExists
$SCRIPTS_DIR/run.sh stop $OUTPUT $COREVERSION $WEBVERSION $SCRIPTS_DIR/run.sh stop $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
;; ;;
"renewcert") "renewcert")
checkOutputDirExists checkOutputDirExists
$SCRIPTS_DIR/run.sh renewcert $OUTPUT $COREVERSION $WEBVERSION $SCRIPTS_DIR/run.sh renewcert $OUTPUT $COREVERSION $WEBVERSION $KEYCONNECTORVERSION
;; ;;
"updaterun") "updaterun")
checkOutputDirExists checkOutputDirExists

View File

@ -2,6 +2,7 @@ param (
[string]$outputDir = "../.", [string]$outputDir = "../.",
[string]$coreVersion = "latest", [string]$coreVersion = "latest",
[string]$webVersion = "latest", [string]$webVersion = "latest",
[string]$keyConnectorVersion = "latest",
[switch] $install, [switch] $install,
[switch] $start, [switch] $start,
[switch] $restart, [switch] $restart,
@ -80,7 +81,7 @@ function Install() {
Pull-Setup Pull-Setup
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion ` docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -install 1 -domain ${domain} -letsencrypt ${letsEncrypt} ` dotnet Setup.dll -install 1 -domain ${domain} -letsencrypt ${letsEncrypt} `
-os win -corev $coreVersion -webv $webVersion -q $setupQuiet -dbname "$database" -os win -corev $coreVersion -webv $webVersion -keyconnectorv $keyConnectorVersion -q $setupQuiet -dbname "$database"
} }
function Docker-Compose-Up { function Docker-Compose-Up {
@ -168,7 +169,8 @@ function Update-Database {
$mssqlId = docker-compose ps -q mssql $mssqlId = docker-compose ps -q mssql
docker run -it --rm --name setup --network container:$mssqlId ` docker run -it --rm --name setup --network container:$mssqlId `
-v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion ` -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -update 1 -db 1 -os win -corev $coreVersion -webv $webVersion -q $setupQuiet dotnet Setup.dll -update 1 -db 1 -os win -corev $coreVersion -webv $webVersion `
-keyconnectorv $keyConnectorVersion -q $setupQuiet
Write-Line "Database update complete" Write-Line "Database update complete"
} }
@ -177,13 +179,15 @@ function Update([switch] $withpull) {
Pull-Setup Pull-Setup
} }
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion ` docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -update 1 -os win -corev $coreVersion -webv $webVersion -q $setupQuiet dotnet Setup.dll -update 1 -os win -corev $coreVersion -webv $webVersion `
-keyconnectorv $keyConnectorVersion -q $setupQuiet
} }
function Print-Environment { function Print-Environment {
Pull-Setup Pull-Setup
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion ` docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -printenv 1 -os win -corev $coreVersion -webv $webVersion -q $setupQuiet dotnet Setup.dll -printenv 1 -os win -corev $coreVersion -webv $webVersion `
-keyconnectorv $keyConnectorVersion -q $setupQuiet
} }
function Restart { function Restart {

View File

@ -26,6 +26,12 @@ then
WEBVERSION=$4 WEBVERSION=$4
fi fi
KEYCONNECTORVERSION="latest"
if [ $# -gt 4 ]
then
KEYCONNECTORVERSION=$5
fi
OS="lin" OS="lin"
[ "$(uname)" == "Darwin" ] && OS="mac" [ "$(uname)" == "Darwin" ] && OS="mac"
ENV_DIR="$OUTPUT_DIR/env" ENV_DIR="$OUTPUT_DIR/env"
@ -89,7 +95,7 @@ function install() {
docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden \ docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden \
--env-file $ENV_DIR/uid.env bitwarden/setup:$COREVERSION \ --env-file $ENV_DIR/uid.env bitwarden/setup:$COREVERSION \
dotnet Setup.dll -install 1 -domain $DOMAIN -letsencrypt $LETS_ENCRYPT -os $OS \ dotnet Setup.dll -install 1 -domain $DOMAIN -letsencrypt $LETS_ENCRYPT -os $OS \
-corev $COREVERSION -webv $WEBVERSION -dbname "$DATABASE" -corev $COREVERSION -webv $WEBVERSION -dbname "$DATABASE" -keyconnectorv $KEYCONNECTORVERSION
} }
function dockerComposeUp() { function dockerComposeUp() {
@ -177,15 +183,17 @@ function updateDatabase() {
MSSQL_ID=$(docker-compose ps -q mssql) MSSQL_ID=$(docker-compose ps -q mssql)
docker run -i --rm --name setup --network container:$MSSQL_ID \ docker run -i --rm --name setup --network container:$MSSQL_ID \
-v $OUTPUT_DIR:/bitwarden --env-file $ENV_DIR/uid.env bitwarden/setup:$COREVERSION \ -v $OUTPUT_DIR:/bitwarden --env-file $ENV_DIR/uid.env bitwarden/setup:$COREVERSION \
dotnet Setup.dll -update 1 -db 1 -os $OS -corev $COREVERSION -webv $WEBVERSION dotnet Setup.dll -update 1 -db 1 -os $OS -corev $COREVERSION -webv $WEBVERSION -keyconnectorv $KEYCONNECTORVERSION
echo "Database update complete" echo "Database update complete"
} }
function updatebw() { function updatebw() {
CORE_ID=$(docker-compose ps -q admin) CORE_ID=$(docker-compose ps -q admin)
WEB_ID=$(docker-compose ps -q web) WEB_ID=$(docker-compose ps -q web)
KEYCONNECTOR_ID=$(docker-compose ps -q key-connector)
if docker inspect --format='{{.Config.Image}}:' $CORE_ID | grep -F ":$COREVERSION:" | grep -q ":[0-9.]*:$" && if docker inspect --format='{{.Config.Image}}:' $CORE_ID | grep -F ":$COREVERSION:" | grep -q ":[0-9.]*:$" &&
docker inspect --format='{{.Config.Image}}:' $WEB_ID | grep -F ":$WEBVERSION:" | grep -q ":[0-9.]*:$" docker inspect --format='{{.Config.Image}}:' $WEB_ID | grep -F ":$WEBVERSION:" | grep -q ":[0-9.]*:$" &&
docker inspect --format='{{.Config.Image}}:' $KEYCONNECTOR_ID | grep -F ":$KEYCONNECTORVERSION:" | grep -q ":[0-9.]*:$"
then then
echo "Update not needed" echo "Update not needed"
exit exit
@ -205,14 +213,14 @@ function update() {
fi fi
docker run -i --rm --name setup -v $OUTPUT_DIR:/bitwarden \ docker run -i --rm --name setup -v $OUTPUT_DIR:/bitwarden \
--env-file $ENV_DIR/uid.env bitwarden/setup:$COREVERSION \ --env-file $ENV_DIR/uid.env bitwarden/setup:$COREVERSION \
dotnet Setup.dll -update 1 -os $OS -corev $COREVERSION -webv $WEBVERSION dotnet Setup.dll -update 1 -os $OS -corev $COREVERSION -webv $WEBVERSION -keyconnectorv $KEYCONNECTORVERSION
} }
function printEnvironment() { function printEnvironment() {
pullSetup pullSetup
docker run -i --rm --name setup -v $OUTPUT_DIR:/bitwarden \ docker run -i --rm --name setup -v $OUTPUT_DIR:/bitwarden \
--env-file $ENV_DIR/uid.env bitwarden/setup:$COREVERSION \ --env-file $ENV_DIR/uid.env bitwarden/setup:$COREVERSION \
dotnet Setup.dll -printenv 1 -os $OS -corev $COREVERSION -webv $WEBVERSION dotnet Setup.dll -printenv 1 -os $OS -corev $COREVERSION -webv $WEBVERSION -keyconnectorv $KEYCONNECTORVERSION
} }
function restart() { function restart() {

View File

@ -18,6 +18,7 @@ namespace Bit.Setup
public string HostOS { get; set; } = "win"; public string HostOS { get; set; } = "win";
public string CoreVersion { get; set; } = "latest"; public string CoreVersion { get; set; } = "latest";
public string WebVersion { get; set; } = "latest"; public string WebVersion { get; set; } = "latest";
public string KeyConnectorVersion { get; set; } = "latest";
public Installation Install { get; set; } = new Installation(); public Installation Install { get; set; } = new Installation();
public Configuration Config { get; set; } = new Configuration(); public Configuration Config { get; set; } = new Configuration();

View File

@ -61,6 +61,10 @@ namespace Bit.Setup
{ {
WebVersion = context.WebVersion; WebVersion = context.WebVersion;
} }
if (!string.IsNullOrWhiteSpace(context.KeyConnectorVersion))
{
KeyConnectorVersion = context.KeyConnectorVersion;
}
} }
public string ComposeVersion { get; set; } = "3"; public string ComposeVersion { get; set; } = "3";
@ -71,6 +75,7 @@ namespace Bit.Setup
public bool HasPort => !string.IsNullOrWhiteSpace(HttpPort) || !string.IsNullOrWhiteSpace(HttpsPort); public bool HasPort => !string.IsNullOrWhiteSpace(HttpPort) || !string.IsNullOrWhiteSpace(HttpsPort);
public string CoreVersion { get; set; } = "latest"; public string CoreVersion { get; set; } = "latest";
public string WebVersion { get; set; } = "latest"; public string WebVersion { get; set; } = "latest";
public string KeyConnectorVersion { get; set; } = "latest";
} }
} }
} }

View File

@ -38,6 +38,10 @@ namespace Bit.Setup
{ {
_context.WebVersion = _context.Parameters["webv"]; _context.WebVersion = _context.Parameters["webv"];
} }
if (_context.Parameters.ContainsKey("keyconnectorv"))
{
_context.KeyConnectorVersion = _context.Parameters["keyconnectorv"];
}
if (_context.Parameters.ContainsKey("stub")) if (_context.Parameters.ContainsKey("stub"))
{ {
_context.Stub = _context.Parameters["stub"] == "true" || _context.Stub = _context.Parameters["stub"] == "true" ||

View File

@ -197,7 +197,7 @@ services:
{{#if EnableKeyConnector}} {{#if EnableKeyConnector}}
key-connector: key-connector:
image: bitwarden/key-connector:latest image: bitwarden/key-connector:{{{KeyConnectorVersion}}}
container_name: bitwarden-key-connector container_name: bitwarden-key-connector
restart: always restart: always
volumes: volumes: