From 636eea988276c646fb5cd7a4f30348591aafed35 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 23 Dec 2023 21:32:49 +0100 Subject: [PATCH] feat: Set directory attributes (#253) --- src/disk.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/disk.sh b/src/disk.sh index 983560e..ed53bc3 100644 --- a/src/disk.sh +++ b/src/disk.sh @@ -277,16 +277,21 @@ checkFS () { fi fi - if [ -f "$DISK_FILE" ] ; then - FA=$(lsattr "$DISK_FILE") - [[ "$FA" == *"C"* ]] && FA=$(lsattr -d "$DIR") - else + local FA="" + [ -f "$DISK_FILE" ] && FA=$(lsattr "$DISK_FILE") + + if [[ "$FA" == "" || "$FA" == *"C"* ]]; then FA=$(lsattr -d "$DIR") + if [[ "$FA" != *"C"* ]]; then + { chattr -R +C "$DIR"; } || : + FA=$(lsattr -d "$DIR") + fi fi if [[ "$FA" != *"C"* ]]; then info "Warning: the filesystem of $DIR is ${FS^^}, and COW (copy on write) is not disabled for that folder!" - info "This will negatively affect performance, please empty the folder and disable COW (chattr +C )." + info "This will negatively affect performance, please empty the folder and add the LINUX_IMMUTABLE flag" + info "to the 'cap_add' section of your compose file, or disable COW manually by executing: chattr +C " fi fi