diff --git a/quick/restore-perms.sh.example b/quick/restore-perms.sh.example index 049753e..ff152c9 100644 --- a/quick/restore-perms.sh.example +++ b/quick/restore-perms.sh.example @@ -24,11 +24,22 @@ sudo whoami perms() { TARGET=$1 + chmodFromFile() { + MODE=$1 + FILE_LIST_FILE=$2 + + # shellcheck disable=SC2046 + # shellcheck disable=SC2006 + chmod "$MODE" `cat "$FILE_LIST_FILE"` + } + + export -f chmodFromFile + echo -n "Set correct ownerships for $(basename ${TARGET})... " sudo chown -R $UID:$WEB_GID "${TARGET}" if [[ -d "${TARGET}" ]]; then - echo -n "and fixing permission for this directory... " +# echo -n "and fixing permissions for these directory... " # echo "Fetching dirs without spaces" find "${TARGET}" -type d -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep -v ' ' > $TMP_DIR/dirs-without-spaces @@ -50,12 +61,12 @@ perms() { # echo "Fixing permissions for dirs" # shellcheck disable=SC2038 # shellcheck disable=SC2016 - find $TMP_DIR/ -maxdepth 1 -type f -name "dirs-without-spaces-part-*" | xargs -I {} bash -c "chmod $DIRS_MODE `cat {}`" + find $TMP_DIR/ -maxdepth 1 -type f -name "dirs-without-spaces-part-*" | xargs -I {} bash -c 'chmodFromFile $DIRS_MODE {}' # echo "Fixing permissions for files" # shellcheck disable=SC2038 # shellcheck disable=SC2016 - find $TMP_DIR/ -maxdepth 1 -type f -name "files-without-spaces-part-*" | xargs -I {} bash -c "chmod $FILES_MODE `cat {}`" + find $TMP_DIR/ -maxdepth 1 -type f -name "files-without-spaces-part-*" | xargs -I {} bash -c 'chmodFromFile $FILES_MODE {}' # echo "Fixing permissions for dirs with spaces" cat $TMP_DIR/dirs-with-spaces | xargs -I {} chmod $DIRS_MODE "{}" @@ -79,4 +90,4 @@ for DIR in "${WP_CONTENT_DIRS[@]}"; do perms "$SCRIPT_DIR/../wp-content/$DIR" done -perms "$SCRIPT_DIR/../wp-content/index.php" +#perms "$SCRIPT_DIR/../wp-content/index.php" diff --git a/quick/tmp/.gitignore b/quick/tmp/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/quick/tmp/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore