Skip to content

Tell find to follow symlinks #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions drupal_fix_permissions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,20 @@ function fix_ownership() {
case $simulate in
0)
# Real action.
find "$1" $detected_vendor_path \( ! -user $drupal_user -o ! -group $httpd_group \) \( -type f -o -type d \) -print0 | xargs -r -0 -L20 chown $drupal_user:$httpd_group
find -L "$1" $detected_vendor_path \( ! -user $drupal_user -o ! -group $httpd_group \) \( -type f -o -type d \) -print0 | xargs -r -0 -L20 chown $drupal_user:$httpd_group
;;

1)
# Simulate.
printf "\n Items with wrong ownership: "
find "$1" $detected_vendor_path \( ! -user $drupal_user -o ! -group $httpd_group \) \( -type f -o -type d \) -print | wc -l
find -L "$1" $detected_vendor_path \( ! -user $drupal_user -o ! -group $httpd_group \) \( -type f -o -type d \) -print | wc -l
;;

2)
# Simulate verbosely.
printf "\n Files and directories that would have their ownership fixed: "
# Use a variable to indent output.
items=$(find "$1" $detected_vendor_path \( ! -user $drupal_user -o ! -group $httpd_group \) \( -type f -o -type d \) -print)
items=$(find -L "$1" $detected_vendor_path \( ! -user $drupal_user -o ! -group $httpd_group \) \( -type f -o -type d \) -print)
items=${items:-None}
printf "\n ${items//$'\n'/$'\n' }\n"
;;
Expand All @@ -196,20 +196,20 @@ function fix_code_permission_helper() {
case $simulate in
0)
# Real action.
find "$1" \( -path "$1"/sites/\*/$file_folder_name -prune \) -o \( -path "$1"/sites/\*/$private_folder_name -prune \) -o \( -type $2 ! -perm $3 -print0 \) | xargs -r -0 -L4 chmod $3
find -L "$1" \( -path "$1"/sites/\*/$file_folder_name -prune \) -o \( -path "$1"/sites/\*/$private_folder_name -prune \) -o \( -type $2 ! -perm $3 -print0 \) | xargs -r -0 -L4 chmod $3
;;

1)
# Simulate.
num=$(find "$1" \( -path "$1"/sites/\*/$file_folder_name -prune \) -o \( -path "$1"/sites/\*/$private_folder_name -prune \) -o \( -type $2 ! -perm $3 -print \) | wc -l)
num=$(find -L "$1" \( -path "$1"/sites/\*/$file_folder_name -prune \) -o \( -path "$1"/sites/\*/$private_folder_name -prune \) -o \( -type $2 ! -perm $3 -print \) | wc -l)
printf "\n Code items with wrong permissions: $num"
;;

2)
# Simulate verbosely.
printf "\n Code files and directories that would have their permissions fixed: "
# Use a variable to indent output.
items=$(find "$1" \( -path "$1"/sites/\*/$file_folder_name -prune \) -o \( -path "$1"/sites/\*/$private_folder_name -prune \) -o \( -type $2 ! -perm $3 -print \))
items=$(find -L "$1" \( -path "$1"/sites/\*/$file_folder_name -prune \) -o \( -path "$1"/sites/\*/$private_folder_name -prune \) -o \( -type $2 ! -perm $3 -print \))
items=${items:-None}
printf "\n ${items//$'\n'/$'\n' }\n"
;;
Expand All @@ -229,20 +229,20 @@ function fix_content_permission_helper() {
case $simulate in
0)
# Real action.
find "$1" -type $2 ! -perm $3 -print0 | xargs -r -0 -L20 chmod $3
find -L "$1" -type $2 ! -perm $3 -print0 | xargs -r -0 -L20 chmod $3
;;

1)
# Simulate.
num=$(find "$1" -type $2 ! -perm $3 -print | wc -l)
num=$(find -L "$1" -type $2 ! -perm $3 -print | wc -l)
printf "\n Content items with wrong permissions: $num"
;;

2)
# Simulate verbosely.
printf "\n Content files and directories that would have their permissions fixed: "
# Use a variable to indent output.
items=$(find "$1" -type $2 ! -perm $3 -print)
items=$(find -L "$1" -type $2 ! -perm $3 -print)
items=${items:-None}
printf "\n ${items//$'\n'/$'\n' }\n"
;;
Expand Down Expand Up @@ -467,7 +467,7 @@ fix_code_permissions "$complete_drupal_path"

# Third, fix permissions on content.
printf "\nFixing permissions on content files and directories under 'sites' folder"
find "$complete_drupal_path/sites/" -maxdepth 1 -mindepth 1 -type d| while read site_folder
find -L "$complete_drupal_path/sites/" -maxdepth 1 -mindepth 1 -type d| while read site_folder
do
printf "\n Checking folder "
printf $(basename "$site_folder")
Expand Down