Skip to content

Skip nfs filesystems #95

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 2 commits into
base: 6.x
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
48 changes: 32 additions & 16 deletions templates/drupal-fix-permissions.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ HELP
exit 0
}

# Function which tests if a directory or file is on an NFS mount
is_nfs_mount() {
local path=$1
if stat --file-system --format=%T "$path" | grep -q nfs; then
return 0
else
return 1
fi
}

# Tests the existance of commands on server.
# Used to check if restorecon is available.
command_exists () {
Expand Down Expand Up @@ -250,31 +260,37 @@ printf "Changing permissions of files directories in "${drupal_path}/sites" to "
cd sites

# Todo: Ask drush where the files are and set the perms there.
printf "Changing permissions of all files inside all files directories in "${drupal_path}/sites" to "rw-rw----"...\n" && \
printf "Changing permissions of all directories inside all files directories in "${drupal_path}/sites" to "rwxrwx---"...\n" && \
for x in ./*/files; do
find ${x} -type d -exec chmod ug=rwx,o= '{}' +
# Don't need to set non-directory perms as they're already set above.
if ! is_nfs_mount "$x"; then
printf "Changing permissions of all files inside '%s' to 'rw-rw----'...\n" "$x"
printf "Changing permissions of all directories inside '%s' to 'rwxrwx---'...\n" "$x"

find "$x" -type d -exec chmod ug=rwx,o= '{}' +
else
printf "Skipping NFS mount at '%s'\n" "$x"
fi
done


# Set permissions on private files path.
# Ask drush where the files directories are.
cd $drupal_path
if [ "$private_files_path" ] && [ -d "$private_files_path" ] && [[ "$private_files_path" == /var/www/* ]]; then
chown -R ${drupal_user}:${httpd_group} ${private_files_path} &
printf "Changing permissions of all files inside private files directory ${private_files_path} to rw-rw----...\n" && \
printf "Changing permissions of private files directory and all directories inside ${private_files_path} to rwxrwx---...\n" && \
chmod u=rwx,g=rwx,o= ${private_files_path}
find ${private_files_path} -type d -exec chmod u=rwx,g=rwx,o= '{}' +
find ${private_files_path} -not -type d -exec chmod u=rw,g=rw,o= '{}' +
# Restore SELinux modes for private files directory.
command_exists restorecon && \
printf "Restoring SeLinux file contexts for ${private_files_path}, please wait...\n" && \
restorecon -RF ${private_files_path} &
if ! is_nfs_mount "$private_files_path"; then
chown -R ${drupal_user}:${httpd_group} ${private_files_path} &
printf "Changing permissions of all files inside private files directory ${private_files_path} to rw-rw----...\n" && \
printf "Changing permissions of private files directory and all directories inside ${private_files_path} to rwxrwx---...\n" && \
chmod u=rwx,g=rwx,o= ${private_files_path}
find ${private_files_path} -type d -exec chmod u=rwx,g=rwx,o= '{}' +
find ${private_files_path} -not -type d -exec chmod u=rw,g=rw,o= '{}' +
# Restore SELinux modes for private files directory.
command_exists restorecon && \
printf "Restoring SeLinux file contexts for ${private_files_path}, please wait...\n" && \
restorecon -RF ${private_files_path} &
else
printf "Skipping NFS mount at '%s'\n" "$private_files_path"
fi
fi


# Check permissions for supporting directories.
if [ "$dversion" -eq 7 ] && [ -d "${drupal_path}/sites/all/vendor/bin" ]; then
printf "Changing permissions of vendor/bin directories in "${drupal_path}/sites/all/vendor/bin" to "u+x"...\n" && \
Expand Down