Skip to content

Instantly share code, notes, and snippets.

@wabson
Created November 19, 2018 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wabson/d0395777918a3d7430b4eb4854add263 to your computer and use it in GitHub Desktop.
Save wabson/d0395777918a3d7430b4eb4854add263 to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ -z "$1" -o -z "$2" ]; then
echo "Usage: $0 <target-dir> 1|0"
exit 1
fi
targets="$1/wp-content/plugins $1/wp-content/themes";
if [ "$2" -eq 1 ]; then
owner="www-data:www-data"
elif [ "$2" -eq 0 ]; then
owner="wabson:wabson"
else
echo "Unsupported action $2"
exit 1
fi
if [ ! -d "$1/wp-content/plugins" ]; then
echo "Cannot find wp-content/plugins folder"
exit 1
fi
if [ ! -d "$1/wp-content/themes" ]; then
echo "Cannot find wp-content/themes folder"
exit 1
fi
if [ ! -d "$1/wp-content/upgrade" ]; then
echo "Warning: Cannot find wp-content/upgrade folder"
else
targets="$targets $1/wp-content/upgrade"
fi
chown -R $owner $targets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment