From ce4a480b3ec6d7ccf01647c114adbfed52674499 Mon Sep 17 00:00:00 2001 From: Adrian Dvergsdal Date: Sun, 8 Oct 2017 18:44:15 +0200 Subject: [PATCH] Only change permission on newly created dirs --- entrypoint | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/entrypoint b/entrypoint index 7288e47..c1cd24e 100755 --- a/entrypoint +++ b/entrypoint @@ -91,14 +91,18 @@ function createUser() { chmod 600 /home/$user/.ssh/authorized_keys fi - # Make sure dirs exists and has correct permissions + # Make sure dirs exists if [ -n "$dir" ]; then - IFS=',' read -a dirParam <<< $dir - for dirPath in ${dirParam[@]}; do - dirPath=/home/$user/$dirPath - echo "Creating and/or setting permissions on $dirPath" - mkdir -p $dirPath - chown -R $uid:users $dirPath + IFS=',' read -a dirArgs <<< $dir + for dirPath in ${dirArgs[@]}; do + dirPath="/home/$user/$dirPath" + if [ ! -d "$dirPath" ]; then + log "Creating directory: $dirPath" + mkdir -p $dirPath + chown -R $uid:users $dirPath + else + log "Directory already exists: $dirPath" + fi done fi }