diff --git a/apache/lib/common b/apache/lib/common index 398061b9..9c329e47 100644 --- a/apache/lib/common +++ b/apache/lib/common @@ -452,7 +452,7 @@ $SERVICE_NAME: } apache_data_dirs() { - local cfg="$1" data_dirs dst data dirs + local cfg="$1" data_dirs dst data fdir to_create data_dirs=$(e "$cfg" | cfg-get-value data-dirs 2>/dev/null | shyaml get-values 2>/dev/null) || true if [ -z "$data_dirs" ]; then return 0 @@ -463,7 +463,7 @@ apache_data_dirs() { data=() while IFS="," read -ra addr; do for dir in "${addr[@]}"; do - data+=($dir) + data+=("$dir") done done <<< "$data_dirs" @@ -473,21 +473,26 @@ apache_data_dirs() { } info "www-data gid from ${DARKYELLOW}$TARGET_SERVICE_NAME${NORMAL} is '$www_data_gid'" - dirs=() + to_create=() + volumes="" for d in "${data[@]}"; do - dirs+=("$dst/$d") + fdir="$dst/$d" + volumes+=" - $HOST_DATASTORE${dst##$DATASTORE}/$d:$local_path/$d"$'\n' + if ! [ -d "$fdir" ]; then + to_create+=("$fdir") + fi done - mkdir -p "${dirs[@]}" || return 1 + if [ "${#to_create[@]}" -gt 0 ]; then + mkdir -p "${to_create[@]}" || return 1 + chgrp -v "${www_data_gid}" "${to_create[@]}" || return 1 + chmod g+rwx "${to_create[@]}" || return 1 + fi init-config-add " $SERVICE_NAME: volumes: -$( - for d in "${data[@]}"; do - echo " - $HOST_DATASTORE${dst##$DATASTORE}/$d:$local_path/$d" - done -)" +$volumes" }