Add directory creation to mailcow-compose script

This commit is contained in:
Roy Lenferink 2023-01-16 19:19:00 +01:00
parent 34b2e1270a
commit e58e8fc85a
1 changed files with 22 additions and 1 deletions

View File

@ -20,7 +20,8 @@ function validate_input()
source mailcow.conf source mailcow.conf
} }
detect_docker_compose_command(){ function detect_docker_compose_command()
{
if ! [[ "${DOCKER_COMPOSE_VERSION}" == "native" ]] && ! [[ "${DOCKER_COMPOSE_VERSION}" == "standalone" ]]; then if ! [[ "${DOCKER_COMPOSE_VERSION}" == "native" ]] && ! [[ "${DOCKER_COMPOSE_VERSION}" == "standalone" ]]; then
if command -v docker compose > /dev/null 2>&1; then if command -v docker compose > /dev/null 2>&1; then
version=$(docker compose version --short) version=$(docker compose version --short)
@ -65,6 +66,25 @@ detect_docker_compose_command(){
fi fi
} }
function ensure_storage_directories_exist()
{
# In case the user specified MAILCOW_STORAGE_DIR, create the required subdirectories.
if [[ -n "${MAILCOW_STORAGE_DIR}" ]]; then
mkdir -p "${MAILCOW_STORAGE_DIR}/clamd-db"
mkdir -p "${MAILCOW_STORAGE_DIR}/crypt"
mkdir -p "${MAILCOW_STORAGE_DIR}/mysql"
mkdir -p "${MAILCOW_STORAGE_DIR}/mysql-socket"
mkdir -p "${MAILCOW_STORAGE_DIR}/postfix"
mkdir -p "${MAILCOW_STORAGE_DIR}/redis"
mkdir -p "${MAILCOW_STORAGE_DIR}/rspamd"
mkdir -p "${MAILCOW_STORAGE_DIR}/sogo-userdata-backup"
mkdir -p "${MAILCOW_STORAGE_DIR}/sogo-web"
mkdir -p "${MAILCOW_STORAGE_DIR}/solr"
mkdir -p "${MAILCOW_STORAGE_DIR}/vmail"
mkdir -p "${MAILCOW_STORAGE_DIR}/vmail-index"
fi
}
function run_compose() function run_compose()
{ {
if [[ -n "${DOCKER_COMPOSE_EXTRA_OVERRIDES}" ]]; then if [[ -n "${DOCKER_COMPOSE_EXTRA_OVERRIDES}" ]]; then
@ -86,4 +106,5 @@ function run_compose()
#--------------------------------------- #---------------------------------------
validate_input $@ validate_input $@
detect_docker_compose_command detect_docker_compose_command
ensure_storage_directories_exist
run_compose $@ run_compose $@