* refactoring use cat {} in subcommand with xargs
+ tmp dir for restore-perms script
This commit is contained in:
@ -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"
|
||||
|
2
quick/tmp/.gitignore
vendored
Normal file
2
quick/tmp/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
Reference in New Issue
Block a user