From 706c30775a7c81adfb79c2d02d18274099d7fe1e Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sun, 8 Oct 2023 18:11:00 +0100 Subject: [PATCH] Fix xargs, and increase log verbosity xargs would fail when no files were found, -r resolves this by continuing. moved repair to function to reduce duplicated code --- docker_launcher.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/docker_launcher.sh b/docker_launcher.sh index 3d516970..00892ed1 100644 --- a/docker_launcher.sh +++ b/docker_launcher.sh @@ -1,5 +1,14 @@ #!/bin/sh +repair_permissions () { + echo -e "\033[36mWrapper | \033[35m📋 (1/3) Ensuring root group ownership..." + find . ! -group root -print0 | xargs -0 -r chgrp root + echo -e "\033[36mWrapper | \033[35m📋 (2/3) Ensuring group read-write is present on files..." + find . ! -perm g+rw -print0 | xargs -0 -r chmod g+rw + echo -e "\033[36mWrapper | \033[35m📋 (3/3) Ensuring sticky bit is present on directories..." + find . -type d ! -perm g+s -print0 | xargs -0 -r chmod g+s +} + # Check if config exists taking one from image if needed. if [ ! "$(ls -A --ignore=.gitkeep ./app/config)" ]; then echo -e "\033[36mWrapper | \033[33m🏗️ Config not found, pulling defaults..." @@ -12,9 +21,9 @@ if [ ! "$(ls -A --ignore=.gitkeep ./app/config)" ]; then # This will do the full /crafty dir, so will take a miniute. echo -e "\033[36mWrapper | \033[35m📋 Looking for problem bind mount permissions globally..." - find . ! -group root -print0 | xargs -0 chgrp root - find . ! -perm g+rw -print0 | xargs -0 chmod g+rw - find . -type d ! -perm g+s -print0 | xargs -0 chmod g+s + repair_permissions + + echo -e "\033[36mWrapper | \033[32m✅ Initialization complete!" fi else # Keep version file up to date with image @@ -31,9 +40,7 @@ if [ $(id -u) -eq 0 ]; then echo -e "\033[36mWrapper | \033[35m📋 Files present in import directory, checking/fixing permissions..." echo -e "\033[36mWrapper | \033[33m⏳ Please be patient for larger servers..." - find . ! -group root -print0 | xargs -0 chgrp root - find . ! -perm g+rw -print0 | xargs -0 chmod g+rw - find . -type d ! -perm g+s -print0 | xargs -0 chmod g+s + repair_permissions echo -e "\033[36mWrapper | \033[32m✅ Permissions Fixed! (This will happen every boot until /import is empty!)" fi