Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #!/bin/bash
  2. directory=$1
  3.  
  4. if [ "$directory" == "" ]
  5. then
  6. echo -e $"${0##*/}: missing operand"
  7. exit 1;
  8. fi;
  9.  
  10. if [ $EUID != 0 ]; then
  11. echo -e $"${0##*/}: cannot fix web permissions on '$directory': Permission denied"
  12. exit 1;
  13. fi
  14.  
  15. if ! chown -R www-data:www-data $directory
  16. then
  17. echo -e $"${0##*/}: changing ownership failed"
  18. exit;
  19. fi
  20.  
  21. if ! find $directory -type f -exec chmod 644 {} \;
  22. then
  23. echo -e $"${0##*/}: Setting file permissions failed"
  24. exit;
  25. fi
  26.  
  27. if ! find $directory -type d -exec chmod 755 {} \;
  28. then
  29. echo -e $"${0##*/}: Setting directory permissions failed"
  30. exit;
  31. fi
  32.  
  33. echo -e $"${0##*/}: ownership and permissions have been set for web use at \"$directory\""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement