Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. /sites/default/files/.htaccess: Option FollowSymLinks not allowed here
  2.  
  3. #Options None
  4. #Options +FollowSymLinks
  5.  
  6. # RewriteBase /
  7. to
  8. RewriteBase /
  9.  
  10. #!/bin/bash
  11.  
  12. # Help menu
  13. print_help() {
  14. cat <<-HELP
  15. This script is used to fix permissions of a Drupal installation
  16. you need to provide the following arguments:
  17.  
  18. 1) Path to your Drupal installation.
  19. 2) Username of the user that you want to give files/directories ownership.
  20. 3) HTTPD group name (defaults to www-data for Apache).
  21.  
  22. Usage: (sudo) bash ${0##*/} --drupal_path=PATH --drupal_user=USER --httpd_group=GROUP
  23. Example: (sudo) bash ${0##*/} --drupal_path=/usr/local/apache2/htdocs --drupal_user=john --httpd_group=www-data
  24. HELP
  25. exit 0
  26. }
  27.  
  28. if [ $(id -u) != 0 ]; then
  29. printf "**************************************n"
  30. printf "* Error: You must run this with sudo or root*n"
  31. printf "**************************************n"
  32. print_help
  33. exit 1
  34. fi
  35.  
  36. drupal_path=${1%/}
  37. drupal_user=${2}
  38. httpd_group="${3:-www-data}"
  39.  
  40. # Parse Command Line Arguments
  41. while [ "$#" -gt 0 ]; do
  42. case "$1" in
  43. --drupal_path=*)
  44. drupal_path="${1#*=}"
  45. ;;
  46. --drupal_user=*)
  47. drupal_user="${1#*=}"
  48. ;;
  49. --httpd_group=*)
  50. httpd_group="${1#*=}"
  51. ;;
  52. --help) print_help;;
  53. *)
  54. printf "***********************************************************n"
  55. printf "* Error: Invalid argument, run --help for valid arguments. *n"
  56. printf "***********************************************************n"
  57. exit 1
  58. esac
  59. shift
  60. done
  61.  
  62. if [ -z "${drupal_path}" ] || [ ! -d "${drupal_path}/sites" ] || [ ! -f "${drupal_path}/core/modules/system/system.module" ] && [ ! -f "${drupal_path}/modules/system/system.module" ]; then
  63. printf "*********************************************n"
  64. printf "* Error: Please provide a valid Drupal path. *n"
  65. printf "*********************************************n"
  66. print_help
  67. exit 1
  68. fi
  69.  
  70. if [ -z "${drupal_user}" ] || [[ $(id -un "${drupal_user}" 2> /dev/null) != "${drupal_user}" ]]; then
  71. printf "*************************************n"
  72. printf "* Error: Please provide a valid user. *n"
  73. printf "*************************************n"
  74. print_help
  75. exit 1
  76. fi
  77.  
  78. cd $drupal_path
  79. printf "Changing ownership of all contents of "${drupal_path}":n user => "${drupal_user}" t group => "${httpd_group}"n"
  80. chown -R ${drupal_user}:${httpd_group} .
  81.  
  82. printf "Changing permissions of all directories inside "${drupal_path}" to "rwxr-x---"...n"
  83. find . -type d -exec chmod u=rwx,g=rx,o= '{}' ;
  84.  
  85. printf "Changing permissions of all files inside "${drupal_path}" to "rw-r-----"...n"
  86. find . -type f -exec chmod u=rw,g=r,o= '{}' ;
  87.  
  88. printf "Changing permissions of "files" directories in "${drupal_path}/sites" to "rwxrwx---"...n"
  89. cd sites
  90. find . -type d -name files -exec chmod ug=rwx,o= '{}' ;
  91.  
  92. printf "Changing permissions of all files inside all "files" directories in "${drupal_path}/sites" to "rw-rw----"...n"
  93. printf "Changing permissions of all directories inside all "files" directories in "${drupal_path}/sites" to "rwxrwx---"...n"
  94. for x in ./*/files; do
  95. find ${x} -type d -exec chmod ug=rwx,o= '{}' ;
  96. find ${x} -type f -exec chmod ug=rw,o= '{}' ;
  97. done
  98. echo "Done setting proper permissions on files and directories"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement