Skip to content

Instantly share code, notes, and snippets.

@devzorg
Last active August 19, 2017 09:04
Show Gist options
  • Save devzorg/9132fa1427775a715d3d58364b11a111 to your computer and use it in GitHub Desktop.
Save devzorg/9132fa1427775a715d3d58364b11a111 to your computer and use it in GitHub Desktop.
Magento reset script to restore right permissions
#!/bin/sh
#if you have difficulties with permissions just run in root of magento dir
#default permissions gets from var/cache or index.php else use arg like owner:group
path="index.php"
if [ -z $1 ]; then
if [ -d "var/cache" ]; then
path="var/cache"
fi
perm=$(stat -c "%U:%G" $path)
else
perm=$1
fi
echo "Change directories permissions"
find . -not \( -path ./.modman -prune \) -type d -exec chmod 0775 {} \;
echo "Change files permissions"
find . -not \( -path ./.modman -prune \) -type f -exec chmod 0664 {} \;
echo "Set other files owner and permissions"
chown -R $perm ./
chmod o+w var var/.htaccess app/etc
chmod -R o+w var/package
chmod -R o+w media
if [ -w "var/Currency.xml" ]; then chmod o+w var/Currency.xml; fi
if [ -w "var/resource_config.json" ]; then chmod o+w var/resource_config.json; fi
rm -rf var/cache
chmod +x ./mage
chmod +x $0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment