Files
server/scripts/run.ps1

78 lines
1.8 KiB
PowerShell
Raw Normal View History

2017-08-23 16:15:42 -04:00
param (
[string]$outputDir = "../.",
[string]$dockerDir = "",
[switch] $start,
[switch] $restart,
[switch] $stop,
2017-08-26 22:36:25 -04:00
[switch] $pull,
2017-08-23 16:15:42 -04:00
[switch] $updatedb
)
# Setup
2017-10-06 09:57:17 -04:00
[string]$tag = "1.12.1"
2017-10-03 23:20:09 -04:00
2017-08-23 16:15:42 -04:00
$dir = Split-Path -Parent $MyInvocation.MyCommand.Path
if($dockerDir -eq "") {
$dockerDir="${dir}\..\docker"
}
# Functions
function Docker-Compose-Up {
2017-10-02 14:49:42 -04:00
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.linwin.yml up -d
2017-08-23 16:15:42 -04:00
}
function Docker-Compose-Down {
2017-10-02 14:49:42 -04:00
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.linwin.yml down
2017-08-23 16:15:42 -04:00
}
2017-08-26 22:36:25 -04:00
function Docker-Compose-Pull {
2017-10-02 14:49:42 -04:00
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.linwin.yml pull
2017-08-26 22:36:25 -04:00
}
2017-08-23 16:15:42 -04:00
function Docker-Prune {
docker image prune -f
}
function Update-Lets-Encrypt {
2017-08-23 16:29:55 -04:00
if(Test-Path -Path "${outputDir}\letsencrypt\live") {
2017-08-26 22:54:10 -04:00
docker pull certbot/certbot
2017-08-23 16:15:42 -04: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-03 23:20:09 -04:00
docker pull bitwarden/setup:$tag
docker run -it --rm --name setup --network container:mssql -v ${outputDir}:/bitwarden bitwarden/setup:$tag `
2017-08-23 16:15:42 -04:00
dotnet Setup.dll -update 1 -db 1
echo "Database update complete"
}
2017-08-24 11:16:01 -04:00
function Print-Environment {
2017-10-03 23:20:09 -04:00
docker pull bitwarden/setup:$tag
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$tag `
2017-08-24 11:16:01 -04:00
dotnet Setup.dll -printenv 1 -env win
}
2017-08-23 16:15:42 -04:00
# Commands
if($start -Or $restart) {
Docker-Compose-Down
2017-08-26 22:36:25 -04:00
Docker-Compose-Pull
2017-08-23 16:15:42 -04:00
Update-Lets-Encrypt
Docker-Compose-Up
Docker-Prune
2017-08-24 11:16:01 -04:00
Print-Environment
2017-08-23 16:15:42 -04:00
}
2017-08-26 22:36:25 -04:00
elseif($pull) {
Docker-Compose-Pull
}
2017-08-23 16:15:42 -04:00
elseif($stop) {
Docker-Compose-Down
}
elseif($updatedb) {
Update-Database
}