Created
January 20, 2026 14:00
-
-
Save jikamens/9037496f01a4343578167a99a7ec78e6 to your computer and use it in GitHub Desktop.
script to toggle WordPress permissions before and after updates
This file contains hidden or 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/bash -e | |
| TOPDIR=FILLMEIN | |
| OWNER=FILLMEIN | |
| DIRS=" | |
| wp-content/plugins/wordfence/tmp | |
| wp-content/uploads | |
| wp-content/wfcache | |
| wp-content/wflogs | |
| wp-content/cache | |
| wp-content/upgrade-temp-backup | |
| " | |
| ### END CONFIG | |
| if [ $(id -u) != 0 ]; then | |
| sudo=sudo | |
| fi | |
| cd $TOPDIR | |
| case "$1" in | |
| lock) | |
| $sudo chown -R $OWNER.$OWNER . | |
| $sudo chmod -R a+rX . | |
| $sudo chown -R apache.apache $DIRS | |
| $sudo chmod -R u+w,g+w $DIRS | |
| $sudo find $DIR -type d -print0 | $sudo xargs -0 chmod g+s | |
| ;; | |
| unlock) | |
| $sudo chown -R apache . | |
| ;; | |
| *) | |
| echo "Specify 'lock' or 'unlock'" 1>&2 | |
| exit 1 | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment