v-fix-website-permissions: exclude specific file types from permission changes to avoid altering 'Change' file attribute

This commit is contained in:
Peca 2025-07-16 12:50:25 +02:00
commit 29f030205e

View file

@ -69,8 +69,8 @@ fi
echo "Updating permissions for /home/$USER/web/$domain/public_html/" echo "Updating permissions for /home/$USER/web/$domain/public_html/"
find public_html/ -type d ! -perm 755 -exec chmod 755 {} + find public_html/ -type d ! \( -name "*.php" -o -name "*.env" \) ! -perm 755 -exec chmod 755 {} +
find public_html/ -type f ! -perm 644 -exec chmod 644 {} + find public_html/ -type f ! \( -name "*.php" -o -name "*.env" \) ! -perm 644 -exec chmod 644 {} +
find public_html/ ! -user $USER -exec chown $USER:$USER {} + find public_html/ ! -user $USER -exec chown $USER:$USER {} +
php_chmod="600" php_chmod="600"
@ -80,8 +80,7 @@ fi
# Setting chmod 600 for all php files # Setting chmod 600 for all php files
echo "= Setting chmod $php_chmod for all php files" echo "= Setting chmod $php_chmod for all php files"
find -name "*.php" -type f ! -perm $php_chmod -exec chmod $php_chmod {} + find -type f \( -name "*.php" -o -name "*.env" \) ! -perm $php_chmod -exec chmod $php_chmod {} +
find -name ".env" -type f ! -perm $php_chmod -exec chmod $php_chmod {} +
find -name "*.php" -type f ! -user $USER -exec chown $USER:$USER {} + find -name "*.php" -type f ! -user $USER -exec chown $USER:$USER {} +
find -name ".env" -type f ! -user $USER -exec chown $USER:$USER {} + find -name ".env" -type f ! -user $USER -exec chown $USER:$USER {} +