mirror of
https://github.com/bitwarden/server.git
synced 2025-02-18 02:11:22 +01:00
silent and custom LE ports
This commit is contained in:
parent
085c13f508
commit
96b4387ce6
@ -10,29 +10,6 @@ param (
|
|||||||
[string] $output = ""
|
[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
|
# Setup
|
||||||
|
|
||||||
$scriptPath = $MyInvocation.MyCommand.Path
|
$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
|
# Commands
|
||||||
|
|
||||||
if ($install) {
|
if ($install) {
|
||||||
@ -102,8 +112,8 @@ elseif ($stop) {
|
|||||||
}
|
}
|
||||||
elseif ($updateself) {
|
elseif ($updateself) {
|
||||||
Download-Self
|
Download-Self
|
||||||
echo "Updated self."
|
Write-Line "Updated self."
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo "No command found."
|
Write-Line "No command found."
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,22 @@ param (
|
|||||||
# Setup
|
# Setup
|
||||||
|
|
||||||
$dockerDir = "${outputDir}\docker"
|
$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
|
# Functions
|
||||||
|
|
||||||
@ -42,32 +58,34 @@ function Install() {
|
|||||||
if (!(Test-Path -Path $letsEncryptPath )) {
|
if (!(Test-Path -Path $letsEncryptPath )) {
|
||||||
New-Item -ItemType directory -Path $letsEncryptPath | Out-Null
|
New-Item -ItemType directory -Path $letsEncryptPath | Out-Null
|
||||||
}
|
}
|
||||||
docker pull certbot/certbot
|
Invoke-Expression ("docker pull{0} certbot/certbot" -f "") #TODO: qFlag
|
||||||
docker run -it --rm --name certbot -p 80:80 -v $outputDir/letsencrypt:/etc/letsencrypt/ certbot/certbot `
|
$certbotExp = "docker run -it --rm --name certbot -p ${certbotHttpsPort}:443 -p ${certbotHttpPort}:80 " +`
|
||||||
certonly --standalone --noninteractive --agree-tos --preferred-challenges http `
|
"-v ${outputDir}/letsencrypt:/etc/letsencrypt/ certbot/certbot " +`
|
||||||
--email $email -d $domain --logs-dir /etc/letsencrypt/logs
|
"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
|
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
|
-os win -corev $coreVersion -webv $webVersion -q $setupQuiet
|
||||||
}
|
}
|
||||||
|
|
||||||
function Docker-Compose-Up {
|
function Docker-Compose-Up {
|
||||||
Docker-Compose-Files
|
Docker-Compose-Files
|
||||||
docker-compose up -d
|
Invoke-Expression ("docker-compose up -d{0}" -f $quietPullFlag)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Docker-Compose-Down {
|
function Docker-Compose-Down {
|
||||||
Docker-Compose-Files
|
Docker-Compose-Files
|
||||||
docker-compose down
|
Invoke-Expression ("docker-compose down{0}" -f "") #TODO: qFlag
|
||||||
}
|
}
|
||||||
|
|
||||||
function Docker-Compose-Pull {
|
function Docker-Compose-Pull {
|
||||||
Docker-Compose-Files
|
Docker-Compose-Files
|
||||||
docker-compose pull
|
Invoke-Expression ("docker-compose pull{0}" -f $qFlag)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Docker-Compose-Files {
|
function Docker-Compose-Files {
|
||||||
@ -87,10 +105,11 @@ function Docker-Prune {
|
|||||||
|
|
||||||
function Update-Lets-Encrypt {
|
function Update-Lets-Encrypt {
|
||||||
if (Test-Path -Path "${outputDir}\letsencrypt\live") {
|
if (Test-Path -Path "${outputDir}\letsencrypt\live") {
|
||||||
docker pull certbot/certbot
|
Invoke-Expression ("docker pull{0} certbot/certbot" -f "") #TODO: qFlag
|
||||||
docker run -it --rm --name certbot -p 443:443 -p 80:80 `
|
$certbotExp = "docker run -it --rm --name certbot -p ${certbotHttpsPort}:443 -p ${certbotHttpPort}:80 " +`
|
||||||
-v $outputDir/letsencrypt:/etc/letsencrypt/ certbot/certbot `
|
"-v ${outputDir}/letsencrypt:/etc/letsencrypt/ certbot/certbot " +`
|
||||||
renew --logs-dir /etc/letsencrypt/logs
|
"renew{0} --logs-dir /etc/letsencrypt/logs" -f $qFlag
|
||||||
|
Invoke-Expression $certbotExp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,8 +117,8 @@ function Update-Database {
|
|||||||
Pull-Setup
|
Pull-Setup
|
||||||
docker run -it --rm --name setup --network container:bitwarden-mssql `
|
docker run -it --rm --name setup --network container:bitwarden-mssql `
|
||||||
-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
|
dotnet Setup.dll -update 1 -db 1 -os win -corev $coreVersion -webv $webVersion -q $setupQuiet
|
||||||
echo "Database update complete"
|
Write-Line "Database update complete"
|
||||||
}
|
}
|
||||||
|
|
||||||
function Update([switch] $withpull) {
|
function Update([switch] $withpull) {
|
||||||
@ -107,13 +126,13 @@ 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
|
dotnet Setup.dll -update 1 -os win -corev $coreVersion -webv $webVersion -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
|
dotnet Setup.dll -printenv 1 -os win -corev $coreVersion -webv $webVersion -q $setupQuiet
|
||||||
}
|
}
|
||||||
|
|
||||||
function Restart {
|
function Restart {
|
||||||
@ -126,7 +145,13 @@ function Restart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Pull-Setup {
|
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
|
# Commands
|
||||||
@ -150,7 +175,7 @@ elseif ($update) {
|
|||||||
Docker-Compose-Down
|
Docker-Compose-Down
|
||||||
Update -withpull
|
Update -withpull
|
||||||
Restart
|
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
|
Start-Sleep -s 60
|
||||||
Update-Database
|
Update-Database
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user