From 0c5827b716b0a9837ba496ee1efd80b2add99119 Mon Sep 17 00:00:00 2001 From: Don Richards <2738244+DonRichards@users.noreply.github.com> Date: Fri, 13 Jan 2023 10:24:18 -0500 Subject: [PATCH 1/9] Update Makefile --- Makefile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Makefile b/Makefile index a6cdc3937..eb4135ee8 100644 --- a/Makefile +++ b/Makefile @@ -311,6 +311,22 @@ download-default-certs: composer_update: docker-compose exec -T drupal with-contenv bash -lc 'composer update' +.PHONY: set-codebase-owner +.SILENT: set-codebase-owner +## JHU: Updates codebase folder to be owned by the host user and nginx group. +set-codebase-owner: + @echo "" + @echo "Setting codebase/ folder owner back to $(shell id -u):101" + 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 {} \; + @echo " └─ Done" + @echo "" + +.PHONY: config-export +.SILENT: config-export +## Exports the sites configuration. +config-export: + docker-compose exec -T drupal drush -l $(SITE) config:export -y reindex-fcrepo-metadata: # Re-index RDF in Fedora From d47f0186fa5e937cffde25d45bc3f604a5a82d14 Mon Sep 17 00:00:00 2001 From: Don Richards Date: Tue, 17 Jan 2023 13:28:50 -0500 Subject: [PATCH 2/9] Improve codebase check before starting --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index eb4135ee8..926f5cc67 100644 --- a/Makefile +++ b/Makefile @@ -317,8 +317,9 @@ composer_update: set-codebase-owner: @echo "" @echo "Setting codebase/ folder owner back to $(shell id -u):101" - 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 {} \; + [ -d ./codebase ] || echo " └─ No codebase/ folder found, skipping" + [ -d ./codebase ] && sudo find ./codebase -not -user $(shell id -u) -not -path '*/sites/default/files/*' -exec chown $(shell id -u):101 {} \; || true + [ -d ./codebase ] && sudo find ./codebase -not -group 101 -not -path '*/sites/default/files/*' -exec chown $(shell id -u):101 {} \; || true @echo " └─ Done" @echo "" From abed421f8dc19a734d0a87cbe013e94d8c8156bf Mon Sep 17 00:00:00 2001 From: Don Richards <2738244+DonRichards@users.noreply.github.com> Date: Tue, 7 Feb 2023 09:05:30 -0500 Subject: [PATCH 3/9] Switch from host to VM to run chown --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 926f5cc67..05f933ae7 100644 --- a/Makefile +++ b/Makefile @@ -318,8 +318,8 @@ set-codebase-owner: @echo "" @echo "Setting codebase/ folder owner back to $(shell id -u):101" [ -d ./codebase ] || echo " └─ No codebase/ folder found, skipping" - [ -d ./codebase ] && sudo find ./codebase -not -user $(shell id -u) -not -path '*/sites/default/files/*' -exec chown $(shell id -u):101 {} \; || true - [ -d ./codebase ] && sudo find ./codebase -not -group 101 -not -path '*/sites/default/files/*' -exec chown $(shell id -u):101 {} \; || true + [ -d ./codebase ] && 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 {} \;" || true + [ -d ./codebase ] && docker-compose exec -T drupal with-contenv bash -lc "find . -not -group 101 -not -path '*/sites/default/files/*' -exec chown $(shell id -u):101 {} \;" || true @echo " └─ Done" @echo "" From b4be09f5c203eb07192ec6841a1b864711c6834a Mon Sep 17 00:00:00 2001 From: Don Richards <2738244+DonRichards@users.noreply.github.com> Date: Tue, 7 Feb 2023 09:44:29 -0500 Subject: [PATCH 4/9] Switch config-export permissions reset --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 05f933ae7..230cade61 100644 --- a/Makefile +++ b/Makefile @@ -327,6 +327,7 @@ set-codebase-owner: .SILENT: config-export ## Exports the sites configuration. config-export: + $(MAKE) set-codebase-owner docker-compose exec -T drupal drush -l $(SITE) config:export -y reindex-fcrepo-metadata: From 87cfcb05d5af8446f056c3d7668ad9dd30c78a1d Mon Sep 17 00:00:00 2001 From: Don Richards <2738244+DonRichards@users.noreply.github.com> Date: Tue, 7 Feb 2023 16:20:38 -0500 Subject: [PATCH 5/9] Really expanded it --- Makefile | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 230cade61..fea8b5d22 100644 --- a/Makefile +++ b/Makefile @@ -317,10 +317,18 @@ composer_update: set-codebase-owner: @echo "" @echo "Setting codebase/ folder owner back to $(shell id -u):101" - [ -d ./codebase ] || echo " └─ No codebase/ folder found, skipping" - [ -d ./codebase ] && 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 {} \;" || true - [ -d ./codebase ] && docker-compose exec -T drupal with-contenv bash -lc "find . -not -group 101 -not -path '*/sites/default/files/*' -exec chown $(shell id -u):101 {} \;" || true - @echo " └─ Done" + 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 {} \;" ; \ + 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 {} \; ; \ + else \ + echo " └─ No codebase/ directory found, skipping"; \ + fi + @echo " └─ Done" @echo "" .PHONY: config-export From 6d638b39ab10a1abe51708240a2a538bcc5c4e05 Mon Sep 17 00:00:00 2001 From: Don Richards <2738244+DonRichards@users.noreply.github.com> Date: Thu, 23 Feb 2023 17:05:59 -0500 Subject: [PATCH 6/9] removed the * for files --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index fea8b5d22..4ebdb959a 100644 --- a/Makefile +++ b/Makefile @@ -319,12 +319,12 @@ set-codebase-owner: @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 {} \;" ; \ + 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 {} \;" ; \ 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 {} \; ; \ + 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 {} \; ; \ else \ echo " └─ No codebase/ directory found, skipping"; \ fi From 3e9edf2d6992e7708c25facf83732237d1bbe5cc Mon Sep 17 00:00:00 2001 From: Don Richards Date: Tue, 11 Apr 2023 10:04:37 -0400 Subject: [PATCH 7/9] Removed extra config-export --- Makefile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 4ebdb959a..686a646c8 100644 --- a/Makefile +++ b/Makefile @@ -331,13 +331,6 @@ set-codebase-owner: @echo " └─ Done" @echo "" -.PHONY: config-export -.SILENT: config-export -## Exports the sites configuration. -config-export: - $(MAKE) set-codebase-owner - docker-compose exec -T drupal drush -l $(SITE) config:export -y - reindex-fcrepo-metadata: # Re-index RDF in Fedora docker-compose exec -T drupal with-contenv bash -lc 'drush --root /var/www/drupal/web -l $${DRUPAL_DEFAULT_SITE_URL} vbo-exec non_fedora_files emit_file_event --configuration="queue=islandora-indexing-fcrepo-file-external&event=Update"' @@ -407,6 +400,7 @@ 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 From 3331ae944d1de2c469064cdb67f42d66d43bd61b Mon Sep 17 00:00:00 2001 From: Don Richards <2738244+DonRichards@users.noreply.github.com> Date: Wed, 16 Oct 2024 13:55:14 -0400 Subject: [PATCH 8/9] Update Makefile Improve the approach and handle the vendor directory --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 686a646c8..17d6a632c 100644 --- a/Makefile +++ b/Makefile @@ -313,7 +313,7 @@ composer_update: .PHONY: set-codebase-owner .SILENT: set-codebase-owner -## JHU: Updates codebase folder to be owned by the host user and nginx group. +## 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" @@ -321,10 +321,18 @@ set-codebase-owner: 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 ] || 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 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 From 76aa687ba2aeae6b90e7c2fb7156d83b78a925c7 Mon Sep 17 00:00:00 2001 From: Don Richards <2738244+DonRichards@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:12:07 -0400 Subject: [PATCH 9/9] Add mkdir for vendor --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index b5d9c4e27..cddf2bb3b 100644 --- a/Makefile +++ b/Makefile @@ -326,6 +326,7 @@ set-codebase-owner: 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 \ @@ -334,6 +335,7 @@ set-codebase-owner: 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 \