+ optimize restore perms for any project and grav perms set
This commit is contained in:
@ -21,6 +21,10 @@ echo -n "Check sudo permissions... "
|
||||
|
||||
sudo whoami
|
||||
|
||||
[ ! -d "$TMP_DIR" ] && {
|
||||
echo "no tmp dir" && exit 1
|
||||
}
|
||||
|
||||
perms() {
|
||||
TARGET=$1
|
||||
|
||||
@ -39,48 +43,48 @@ perms() {
|
||||
sudo chown -R $UID:$WEB_GID "${TARGET}"
|
||||
|
||||
if [[ -d "${TARGET}" ]]; then
|
||||
# echo -n "and fixing permissions for these directory... "
|
||||
# echo "Fetching dirs without spaces"
|
||||
# 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
|
||||
|
||||
# echo "Splitting dirs by 10000 lines"
|
||||
# echo "Splitting dirs by 10000 lines"
|
||||
split -l 10000 $TMP_DIR/dirs-without-spaces $TMP_DIR/dirs-without-spaces-part-
|
||||
|
||||
# echo "Fetching files without spaces"
|
||||
# echo "Fetching files without spaces"
|
||||
find "${TARGET}" -type f -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep -v ' ' > $TMP_DIR/files-without-spaces
|
||||
|
||||
# echo "Splitting files at 10000 lines"
|
||||
# echo "Splitting files at 10000 lines"
|
||||
split -l 10000 $TMP_DIR/files-without-spaces $TMP_DIR/files-without-spaces-part-
|
||||
|
||||
# echo "Fetching dirs with spaces"
|
||||
# echo "Fetching dirs with spaces"
|
||||
find "${TARGET}" -type d -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep ' ' > $TMP_DIR/dirs-with-spaces
|
||||
|
||||
# echo "Fetching files with spaces"
|
||||
# echo "Fetching files with spaces"
|
||||
find "${TARGET}" -type f -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep ' ' > $TMP_DIR/files-with-spaces
|
||||
|
||||
# echo "Fixing permissions for dirs"
|
||||
# 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 'chmodFromFile $DIRS_MODE {}'
|
||||
|
||||
# echo "Fixing permissions for files"
|
||||
# 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 'chmodFromFile $FILES_MODE {}'
|
||||
|
||||
# echo "Fixing permissions for dirs with spaces"
|
||||
# echo "Fixing permissions for dirs with spaces"
|
||||
cat $TMP_DIR/dirs-with-spaces | xargs -I {} chmod $DIRS_MODE "{}"
|
||||
|
||||
# echo "Fixing permissions for files with spaces"
|
||||
# echo "Fixing permissions for files with spaces"
|
||||
cat $TMP_DIR/files-with-spaces | xargs -I {} chmod $FILES_MODE "{}"
|
||||
|
||||
# echo "Removing temporary files"
|
||||
# echo "Removing temporary files"
|
||||
rm $TMP_DIR/files-*
|
||||
rm $TMP_DIR/dirs-*
|
||||
echo "ok"
|
||||
else
|
||||
echo -n "and fixing permission for this file... "
|
||||
# echo "Fixing permissions"
|
||||
# echo "Fixing permissions"
|
||||
chmod $FILES_MODE "${TARGET}"
|
||||
echo "ok"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user