mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
condense scripts into run script
This commit is contained in:
57
scripts/run.ps1
Normal file
57
scripts/run.ps1
Normal file
@ -0,0 +1,57 @@
|
||||
param (
|
||||
[string]$outputDir = "../.",
|
||||
[string]$dockerDir = "",
|
||||
[switch] $start,
|
||||
[switch] $restart,
|
||||
[switch] $stop,
|
||||
[switch] $updatedb
|
||||
)
|
||||
|
||||
# Setup
|
||||
|
||||
$dir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
if($dockerDir -eq "") {
|
||||
$dockerDir="${dir}\..\docker"
|
||||
}
|
||||
|
||||
# Functions
|
||||
|
||||
function Docker-Compose-Up {
|
||||
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.macwin.yml up -d
|
||||
}
|
||||
|
||||
function Docker-Compose-Down {
|
||||
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.macwin.yml down
|
||||
}
|
||||
|
||||
function Docker-Prune {
|
||||
docker image prune -f
|
||||
}
|
||||
|
||||
function Update-Lets-Encrypt {
|
||||
if(Test-Path -Path "${outputDir}/letsencrypt") {
|
||||
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 {
|
||||
docker run -it --rm --name setup --network container:mssql -v ${outputDir}:/bitwarden bitwarden/setup `
|
||||
dotnet Setup.dll -update 1 -db 1
|
||||
echo "Database update complete"
|
||||
}
|
||||
|
||||
# Commands
|
||||
|
||||
if($start -Or $restart) {
|
||||
Docker-Compose-Down
|
||||
Update-Lets-Encrypt
|
||||
Docker-Compose-Up
|
||||
Docker-Prune
|
||||
}
|
||||
elseif($stop) {
|
||||
Docker-Compose-Down
|
||||
}
|
||||
elseif($updatedb) {
|
||||
Update-Database
|
||||
}
|
Reference in New Issue
Block a user