Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add set-codebase-owner function #320

Open
wants to merge 10 commits into
base: development
Choose a base branch
from
31 changes: 30 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,35 @@ download-default-certs:
composer_update:
docker compose exec -T drupal with-contenv bash -lc su nginx -s /bin/bash -c "composer update"

.PHONY: set-codebase-owner
.SILENT: set-codebase-owner
## JHU: Updates codebase folder to be owned by the host user and nginx group and ensures vendor directory permissions.
set-codebase-owner:
@echo ""
@echo "Setting codebase/ folder owner back to $(shell id -u):101"
if [ -n "$$(docker ps -q -f name=drupal)" ]; then \
echo " └─ Using docker-compose codebase/ directory"; \
docker-compose exec -T drupal with-contenv bash -lc "find . -not -user $(shell id -u) -not -path '*/sites/default/files' -exec chown $(shell id -u):101 {} \;" ; \
docker-compose exec -T drupal with-contenv bash -lc "find . -not -group 101 -not -path '*/sites/default/files' -exec chown $(shell id -u):101 {} \;" ; \
# Check and fix vendor directory ownership and permissions \
echo " └─ Checking vendor directory permissions"; \
docker-compose exec -T drupal with-contenv bash -lc "[ ! -d ./vendor ] && mkdir -p ./vendor" ; \
docker-compose exec -T drupal with-contenv bash -lc "[ ! -d ./vendor ] || find ./vendor -not -user $(shell id -u) -exec chown $(shell id -u):101 {} \;" ; \
docker-compose exec -T drupal with-contenv bash -lc "[ ! -d ./vendor ] || chmod -R 775 ./vendor" ; \
elif [ -d "codebase" ]; then \
echo " └─ Using local codebase/ directory"; \
sudo find ./codebase -not -user $(shell id -u) -not -path '*/sites/default/files' -exec chown $(shell id -u):101 {} \; ; \
sudo find ./codebase -not -group 101 -not -path '*/sites/default/files' -exec chown $(shell id -u):101 {} \; ; \
# Check and fix vendor directory ownership and permissions \
echo " └─ Checking vendor directory permissions"; \
[ ! -d ./codebase/vendor ] || sudo mkdir -p ./codebase/vendor ; \
[ ! -d ./codebase/vendor ] || sudo find ./codebase/vendor -not -user $(shell id -u) -exec chown $(shell id -u):101 {} \; ; \
[ ! -d ./codebase/vendor ] || sudo chmod -R 775 ./codebase/vendor ; \
else \
echo " └─ No codebase/ directory found, skipping"; \
fi
@echo " └─ Done"
@echo ""

reindex-fcrepo-metadata:
# Re-index RDF in Fedora
Expand Down Expand Up @@ -385,9 +414,9 @@ endif
.SILENT: config-export
## Exports the sites configuration.
config-export:
$(MAKE) set-codebase-owner
docker compose exec -T drupal drush -l $(SITE) config:export -y


.PHONY: config-import
.SILENT: config-import
## Import the sites configuration. N.B You may need to run this multiple times in succession due to errors in the configurations dependencies.
Expand Down