1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00

silent and custom LE ports

This commit is contained in:
Kyle Spearrin 2019-03-25 16:46:32 -04:00
parent 085c13f508
commit 96b4387ce6
2 changed files with 78 additions and 43 deletions

View File

@ -10,29 +10,6 @@ param (
[string] $output = ""
)
$year = (Get-Date).year
Write-Host @'
_ _ _ _
| |__ (_) |___ ____ _ _ __ __| | ___ _ __
| '_ \| | __\ \ /\ / / _` | '__/ _` |/ _ \ '_ \
| |_) | | |_ \ V V / (_| | | | (_| | __/ | | |
|_.__/|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_|
'@
Write-Host "
Open source password management solutions
Copyright 2015-${year}, 8bit Solutions LLC
https://bitwarden.com, https://github.com/bitwarden
===================================================
"
docker --version
docker-compose --version
echo ""
# Setup
$scriptPath = $MyInvocation.MyCommand.Path
@ -71,6 +48,39 @@ function Check-Output-Dir-Not-Exists {
}
}
function Write-Line($str) {
if($env:BITWARDEN_QUIET -ne "true") {
Write-Host $str
}
}
# Intro
$year = (Get-Date).year
Write-Line @'
_ _ _ _
| |__ (_) |___ ____ _ _ __ __| | ___ _ __
| '_ \| | __\ \ /\ / / _` | '__/ _` |/ _ \ '_ \
| |_) | | |_ \ V V / (_| | | | (_| | __/ | | |
|_.__/|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_|
'@
Write-Line "
Open source password management solutions
Copyright 2015-${year}, 8bit Solutions LLC
https://bitwarden.com, https://github.com/bitwarden
===================================================
"
if($env:BITWARDEN_QUIET -ne "true") {
docker --version
docker-compose --version
}
Write-Line ""
# Commands
if ($install) {
@ -102,8 +112,8 @@ elseif ($stop) {
}
elseif ($updateself) {
Download-Self
echo "Updated self."
Write-Line "Updated self."
}
else {
echo "No command found."
Write-Line "No command found."
}

View File

@ -14,6 +14,22 @@ param (
# Setup
$dockerDir = "${outputDir}\docker"
$setupQuiet = 0
$qFlag = ""
$quietPullFlag = ""
$certbotHttpPort = "80"
$certbotHttpsPort = "443"
if($env:BITWARDEN_QUIET -eq "true") {
$setupQuiet = 1
$qFlag = " -q"
$quietPullFlag = " --quiet-pull"
}
if("${env:BITWARDEN_CERTBOT_HTTP_PORT}" -ne "") {
$certbotHttpPort = $env:BITWARDEN_CERTBOT_HTTP_PORT
}
if("${env:BITWARDEN_CERTBOT_HTTPS_PORT}" -ne "") {
$certbotHttpsPort = $env:BITWARDEN_CERTBOT_HTTPS_PORT
}
# Functions
@ -42,32 +58,34 @@ function Install() {
if (!(Test-Path -Path $letsEncryptPath )) {
New-Item -ItemType directory -Path $letsEncryptPath | Out-Null
}
docker pull certbot/certbot
docker run -it --rm --name certbot -p 80:80 -v $outputDir/letsencrypt:/etc/letsencrypt/ certbot/certbot `
certonly --standalone --noninteractive --agree-tos --preferred-challenges http `
--email $email -d $domain --logs-dir /etc/letsencrypt/logs
Invoke-Expression ("docker pull{0} certbot/certbot" -f "") #TODO: qFlag
$certbotExp = "docker run -it --rm --name certbot -p ${certbotHttpsPort}:443 -p ${certbotHttpPort}:80 " +`
"-v ${outputDir}/letsencrypt:/etc/letsencrypt/ certbot/certbot " +`
"certonly{0} --standalone --noninteractive --agree-tos --preferred-challenges http " +`
"--email ${email} -d ${domain} --logs-dir /etc/letsencrypt/logs" -f $qFlag
Invoke-Expression $certbotExp
}
}
Pull-Setup
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -install 1 -domain ${domain} -letsencrypt ${letsEncrypt} `
-os win -corev $coreVersion -webv $webVersion
-os win -corev $coreVersion -webv $webVersion -q $setupQuiet
}
function Docker-Compose-Up {
Docker-Compose-Files
docker-compose up -d
Invoke-Expression ("docker-compose up -d{0}" -f $quietPullFlag)
}
function Docker-Compose-Down {
Docker-Compose-Files
docker-compose down
Invoke-Expression ("docker-compose down{0}" -f "") #TODO: qFlag
}
function Docker-Compose-Pull {
Docker-Compose-Files
docker-compose pull
Invoke-Expression ("docker-compose pull{0}" -f $qFlag)
}
function Docker-Compose-Files {
@ -87,10 +105,11 @@ function Docker-Prune {
function Update-Lets-Encrypt {
if (Test-Path -Path "${outputDir}\letsencrypt\live") {
docker pull certbot/certbot
docker run -it --rm --name certbot -p 443:443 -p 80:80 `
-v $outputDir/letsencrypt:/etc/letsencrypt/ certbot/certbot `
renew --logs-dir /etc/letsencrypt/logs
Invoke-Expression ("docker pull{0} certbot/certbot" -f "") #TODO: qFlag
$certbotExp = "docker run -it --rm --name certbot -p ${certbotHttpsPort}:443 -p ${certbotHttpPort}:80 " +`
"-v ${outputDir}/letsencrypt:/etc/letsencrypt/ certbot/certbot " +`
"renew{0} --logs-dir /etc/letsencrypt/logs" -f $qFlag
Invoke-Expression $certbotExp
}
}
@ -98,8 +117,8 @@ function Update-Database {
Pull-Setup
docker run -it --rm --name setup --network container:bitwarden-mssql `
-v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -update 1 -db 1 -os win -corev $coreVersion -webv $webVersion
echo "Database update complete"
dotnet Setup.dll -update 1 -db 1 -os win -corev $coreVersion -webv $webVersion -q $setupQuiet
Write-Line "Database update complete"
}
function Update([switch] $withpull) {
@ -107,13 +126,13 @@ function Update([switch] $withpull) {
Pull-Setup
}
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -update 1 -os win -corev $coreVersion -webv $webVersion
dotnet Setup.dll -update 1 -os win -corev $coreVersion -webv $webVersion -q $setupQuiet
}
function Print-Environment {
Pull-Setup
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -printenv 1 -os win -corev $coreVersion -webv $webVersion
dotnet Setup.dll -printenv 1 -os win -corev $coreVersion -webv $webVersion -q $setupQuiet
}
function Restart {
@ -126,7 +145,13 @@ function Restart {
}
function Pull-Setup {
docker pull bitwarden/setup:$coreVersion
Invoke-Expression ("docker pull{0} bitwarden/setup:${coreVersion}" -f "") #TODO: qFlag
}
function Write-Line($str) {
if($env:BITWARDEN_QUIET -ne "true") {
Write-Host $str
}
}
# Commands
@ -150,7 +175,7 @@ elseif ($update) {
Docker-Compose-Down
Update -withpull
Restart
echo "Pausing 60 seconds for database to come online. Please wait..."
Write-Line "Pausing 60 seconds for database to come online. Please wait..."
Start-Sleep -s 60
Update-Database
}