From e314e9bfafaba5a0d9ba696edc8ebf6f5ebafe57 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Fri, 23 Oct 2020 10:49:40 +0200 Subject: [PATCH] new: [apache] re-introduced setting ownership for data dirs This was removed for macosx compatibility reasons. Did not have the chance to test this, but hopefully, ``chown`` an ``chmod`` might have better chances of being compatible that previous ``setacl``. Signed-off-by: Valentin Lab --- apache/lib/common | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) 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" }