From d746517ff431173c7b64a6b0c55c2a0932e367f9 Mon Sep 17 00:00:00 2001 From: Matt Portune Date: Fri, 29 May 2020 18:03:55 -0400 Subject: [PATCH] Create missing container volume directories if/when docker-compose fails to --- scripts/run.ps1 | 25 +++++++++++++++++++++++++ scripts/run.sh | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/scripts/run.ps1 b/scripts/run.ps1 index 363fce14c..5113b9cf2 100644 --- a/scripts/run.ps1 +++ b/scripts/run.ps1 @@ -76,6 +76,7 @@ function Install() { function Docker-Compose-Up { Docker-Compose-Files + Docker-Compose-Volumes Invoke-Expression ("docker-compose up -d{0}" -f $quietPullFlag) } @@ -99,6 +100,30 @@ function Docker-Compose-Files { $env:COMPOSE_HTTP_TIMEOUT = "300" } +function Docker-Compose-Volumes { + Create-Dir "core" + Create-Dir "core/attachments" + Create-Dir "logs" + Create-Dir "logs/admin" + Create-Dir "logs/api" + Create-Dir "logs/events" + Create-Dir "logs/icons" + Create-Dir "logs/identity" + Create-Dir "logs/mssql" + Create-Dir "logs/nginx" + Create-Dir "logs/notifications" + Create-Dir "mssql/backups" + Create-Dir "mssql/data" +} + +function Create-Dir($str) { + $outPath = "${outputDir}/$str" + if (!(Test-Path -Path $outPath )) { + Write-Line "Creating directory $outPath" + New-Item -ItemType directory -Path $outPath | Out-Null + } +} + function Docker-Prune { docker image prune --all --force --filter="label=com.bitwarden.product=bitwarden" ` --filter="label!=com.bitwarden.project=setup" diff --git a/scripts/run.sh b/scripts/run.sh index 974ea104d..83e7e99b8 100644 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -85,6 +85,7 @@ function install() { function dockerComposeUp() { dockerComposeFiles + dockerComposeVolumes docker-compose up -d } @@ -108,6 +109,30 @@ function dockerComposeFiles() { export COMPOSE_HTTP_TIMEOUT="300" } +function dockerComposeVolumes() { + createDir "core" + createDir "core/attachments" + createDir "logs" + createDir "logs/admin" + createDir "logs/api" + createDir "logs/events" + createDir "logs/icons" + createDir "logs/identity" + createDir "logs/mssql" + createDir "logs/nginx" + createDir "logs/notifications" + createDir "mssql/backups" + createDir "mssql/data" +} + +function createDir() { + if [ ! -d "${OUTPUT_DIR}/$1" ] + then + echo "Creating directory $OUTPUT_DIR/$1" + mkdir -p $OUTPUT_DIR/$1 + fi +} + function dockerPrune() { docker image prune --all --force --filter="label=com.bitwarden.product=bitwarden" \ --filter="label!=com.bitwarden.project=setup"