1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-22 12:15:36 +01:00
bitwarden-server/scripts/run.ps1

95 lines
2.1 KiB
PowerShell
Raw Normal View History

2017-08-23 22:15:42 +02:00
param (
[string]$outputDir = "../.",
2017-11-09 04:24:23 +01:00
[string]$coreVersion = "latest",
[string]$webVersion = "latest",
2017-08-23 22:15:42 +02:00
[switch] $start,
[switch] $restart,
[switch] $stop,
2017-08-27 04:36:25 +02:00
[switch] $pull,
2017-10-25 23:21:35 +02:00
[switch] $updatedb,
[switch] $update
2017-08-23 22:15:42 +02:00
)
# Setup
2017-11-09 04:24:23 +01:00
$dockerDir="${outputDir}\docker"
2017-08-23 22:15:42 +02:00
# Functions
function Docker-Compose-Up {
2017-11-09 04:24:23 +01:00
docker-compose -f ${dockerDir}\docker-compose.yml up -d
2017-08-23 22:15:42 +02:00
}
function Docker-Compose-Down {
2017-11-09 04:24:23 +01:00
docker-compose -f ${dockerDir}\docker-compose.yml down
2017-08-23 22:15:42 +02:00
}
2017-08-27 04:36:25 +02:00
function Docker-Compose-Pull {
2017-11-09 04:24:23 +01:00
docker-compose -f ${dockerDir}\docker-compose.yml pull
2017-08-27 04:36:25 +02:00
}
2017-08-23 22:15:42 +02:00
function Docker-Prune {
docker image prune -f
}
function Update-Lets-Encrypt {
2017-08-23 22:29:55 +02:00
if(Test-Path -Path "${outputDir}\letsencrypt\live") {
2017-08-27 04:54:10 +02:00
docker pull certbot/certbot
2017-08-23 22:15:42 +02:00
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
}
}
function Update-Database {
2017-10-25 23:21:35 +02:00
Pull-Setup
2017-12-21 05:38:27 +01:00
docker run -it --rm --name setup --network container:mssql -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
2017-11-09 04:24:23 +01:00
dotnet Setup.dll -update 1 -db 1 -os win -corev $coreVersion -webv $webVersion
2017-08-23 22:15:42 +02:00
echo "Database update complete"
}
2017-10-25 23:21:35 +02:00
function Update {
Pull-Setup
2017-11-09 04:24:23 +01:00
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -update 1 -os win -corev $coreVersion -webv $webVersion
2017-10-25 23:21:35 +02:00
}
2017-08-24 17:16:01 +02:00
function Print-Environment {
2017-10-25 23:21:35 +02:00
Pull-Setup
2017-11-09 04:24:23 +01:00
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -printenv 1 -os win -corev $coreVersion -webv $webVersion
2017-08-24 17:16:01 +02:00
}
2017-10-25 23:21:35 +02:00
function Restart {
2017-08-23 22:15:42 +02:00
Docker-Compose-Down
2017-08-27 04:36:25 +02:00
Docker-Compose-Pull
2017-08-23 22:15:42 +02:00
Update-Lets-Encrypt
Docker-Compose-Up
Docker-Prune
2017-08-24 17:16:01 +02:00
Print-Environment
2017-08-23 22:15:42 +02:00
}
2017-10-25 23:21:35 +02:00
function Pull-Setup {
2017-11-09 04:24:23 +01:00
docker pull bitwarden/setup:$coreVersion
2017-10-25 23:21:35 +02:00
}
# Commands
if($start -Or $restart) {
Restart
}
2017-08-27 04:36:25 +02:00
elseif($pull) {
Docker-Compose-Pull
}
2017-08-23 22:15:42 +02:00
elseif($stop) {
Docker-Compose-Down
}
elseif($updatedb) {
Update-Database
}
2017-10-25 23:21:35 +02:00
elseif($update) {
Docker-Compose-Down
Update
Restart
Update-Database
}