Created
June 9, 2026 02:16
-
-
Save khoipro/8fd5e07b25ed8a5904257b0c0b969ad3 to your computer and use it in GitHub Desktop.
Quick fix site permission (without wp-content/uploads/ folder)
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
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| SITE="" | |
| while [[ $# -gt 0 ]]; do | |
| case "$1" in | |
| --site=*) | |
| SITE="${1#*=}" | |
| shift | |
| ;; | |
| --site) | |
| SITE="${2:-}" | |
| shift 2 | |
| ;; | |
| *) | |
| echo "Usage: $0 --site=<site-name>" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| done | |
| if [[ -z "$SITE" ]]; then | |
| echo "Missing required flag: --site" >&2 | |
| exit 1 | |
| fi | |
| ROOT="/home/ubuntu/webapps/$SITE" | |
| UPLOADS="$ROOT/wp-content/uploads" | |
| if [[ ! -d "$ROOT" ]]; then | |
| echo "Site path not found: $ROOT" >&2 | |
| exit 1 | |
| fi | |
| sudo find "$ROOT" \ | |
| \( -path "$UPLOADS" -o -path "$UPLOADS/*" \) -prune -o \ | |
| -exec chown www-data:www-data {} + |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment