Last active
February 2, 2022 09:08
-
-
Save iBet7o/8bbba12d295e85d0edfe21dd3846c75d to your computer and use it in GitHub Desktop.
Fix permissions for a project in Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Messages | |
# ---------------------- | |
txtSuccess='\033[1;32m' | |
txtError='\033[0;31m' | |
txtNoColor='\033[0m' | |
# Methods | |
# ---------------------- | |
echoError () { | |
echo "$txtError$1$txtNoColor" | |
} | |
echoSuccess () { | |
echo "$txtSuccess$1$txtNoColor" | |
} | |
dir=$1 | |
if [ ! -d "$dir" ]; then | |
echoError "ERROR: Directory '$dir' does not exist!" | |
exit 1 | |
fi | |
echoSuccess "> chown -R www-data:www-data $dir" | |
chown -R www-data:www-data $dir | |
echoSuccess "> find $dir -type f -exec chmod 644 {} \;" | |
find $dir -type f -exec chmod 644 {} \; | |
echoSuccess "> find $dir -type d -exec chmod 755 {} \;" | |
find $dir -type d -exec chmod 755 {} \; | |
echoSuccess "> cd $dir" | |
cd $dir | |
echoSuccess "> chgrp -R www-data storage bootstrap/cache" | |
chgrp -R www-data storage bootstrap/cache | |
echoSuccess "> chmod -R ug+rwx storage bootstrap/cache" | |
chmod -R ug+rwx storage bootstrap/cache | |
echoSuccess "\nCompleted!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment