From 3c53a5aead410cb300238470bbb8b9bfd96f0ad7 Mon Sep 17 00:00:00 2001 From: Evilham Date: Tue, 20 Sep 2022 19:20:38 +0200 Subject: [PATCH] [wp] Fix multisite installation While there we also simplify DD by removing an the unnecessary wp-cli container. --- dd-apps/docker/wordpress/multisite.sh | 32 -------------------------- dd-apps/docker/wordpress/wordpress.yml | 28 ---------------------- dd-ctl | 14 +++++++---- 3 files changed, 9 insertions(+), 65 deletions(-) delete mode 100755 dd-apps/docker/wordpress/multisite.sh diff --git a/dd-apps/docker/wordpress/multisite.sh b/dd-apps/docker/wordpress/multisite.sh deleted file mode 100755 index 73370ef..0000000 --- a/dd-apps/docker/wordpress/multisite.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# -# Copyright © 2021,2022 IsardVDI S.L. -# -# This file is part of DD -# -# DD is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# DD is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more -# details. -# -# You should have received a copy of the GNU Affero General Public License -# along with DD. If not, see . -# -# SPDX-License-Identifier: AGPL-3.0-or-later -cat <> multisite.cfg -define( 'WP_ALLOW_MULTISITE', true ); -define( 'MULTISITE', true ); -define( 'SUBDOMAIN_INSTALL', false ); -\$base = '/'; -define( 'DOMAIN_CURRENT_SITE', '$WORDPRESS_DOMAIN_CURRENT_SITE' ); -define( 'PATH_CURRENT_SITE', '/' ); -define( 'SITE_ID_CURRENT_SITE', 1 ); -define( 'BLOG_ID_CURRENT_SITE', 1 ); -EOT - -sed -i '/Happy publishing/e cat multisite.cfg' /var/www/html/wp-config.php diff --git a/dd-apps/docker/wordpress/wordpress.yml b/dd-apps/docker/wordpress/wordpress.yml index 5da5ff1..00f19e4 100644 --- a/dd-apps/docker/wordpress/wordpress.yml +++ b/dd-apps/docker/wordpress/wordpress.yml @@ -26,7 +26,6 @@ x-volumes: - ${SRC_FOLDER}/wordpress:/var/www/html - ${BUILD_APPS_ROOT_PATH}/docker/wordpress/plugins:/plugins - ${BUILD_APPS_ROOT_PATH}/docker/wordpress/.htaccess:/var/www/html/.htaccess:ro - - ${BUILD_APPS_ROOT_PATH}/docker/wordpress/multisite.sh:/multisite.sh:ro - ${DATA_FOLDER}/wordpress:/var/www/html/wp-content/uploads services: @@ -57,30 +56,3 @@ services: retries: 5 networks: - dd_net - - dd-apps-wordpress-cli: - image: ${WORDPRESS_CLI_IMG} - container_name: dd-apps-wordpress-cli - volumes: - *wordpress-volumes - command: > - bash -c 'wp core install --path="/var/www/html" --url=wp.${DOMAIN} --title="${TITLE}" --admin_user=${WORDPRESS_ADMIN_USER} --admin_password=${WORDPRESS_ADMIN_PASSWORD} --admin_email=${SMTP_USER}; - wp core multisite-convert;' - depends_on: - dd-apps-mariadb: - condition: service_healthy - dd-apps-wordpress: - condition: service_healthy - networks: - - dd_net - restart: "no" - environment: - WORDPRESS_DB_HOST: dd-apps-mariadb - WORDPRESS_DB_NAME: "wordpress" - WORDPRESS_DB_USER: ${WORDPRESS_MARIADB_USER} - WORDPRESS_DB_PASSWORD: ${WORDPRESS_MARIADB_PASSWORD} - DOMAIN: ${DOMAIN} - TITLE: ${TITLE} - SMTP_USER: ${SMTP_USER} - - diff --git a/dd-ctl b/dd-ctl index 6d126bd..6c38630 100755 --- a/dd-ctl +++ b/dd-ctl @@ -448,10 +448,15 @@ setup_moodle(){ setup_wordpress(){ echo " --> Applying custom settings in wordpress" - ## Multisite - docker exec -ti dd-apps-wordpress /bin/sh -c "/multisite.sh" + chown -R 33:33 "${DATA_FOLDER}/wordpress" + docker exec -i --user=33 dd-apps-wordpress sh -s <<-EOF + wp core install --path="/var/www/html" \ + --url=wp.${DOMAIN} --title="${TITLE}" \ + --admin_user=${WORDPRESS_ADMIN_USER} \ + --admin_password=${WORDPRESS_ADMIN_PASSWORD} \ + --admin_email=${SMTP_USER} + wp core multisite-convert - docker-compose run --user=33 dd-apps-wordpress-cli /bin/bash -s <<-EOF wp plugin activate onelogin-saml-sso wp plugin install generateblocks --activate wp plugin activate generateblocks --network @@ -465,7 +470,6 @@ setup_wordpress(){ wp option set WPLANG ca wp option set date_format "d/m/Y" EOF - docker-compose run --user=root dd-apps-wordpress-cli /bin/bash -c 'chown -R 33:33 /var/www/html/wp-content/uploads;' } setup_keycloak(){ @@ -663,7 +667,7 @@ upgrade_plugins_wp(){ else sh -c "cd $SRC_FOLDER/wordpress/wp-content/mu-plugins; git pull" fi - docker-compose run --user=root dd-apps-wordpress-cli /bin/bash -c 'chown -R 33:33 /var/www/html/wp-content/mu-plugins;' + chown -R 33:33 "${SRC_FOLDER}/wordpress/wp-content/mu-plugins" # TODO: Fix this, check https://gitlab.com/DD-workspace/DD/-/issues/16 ##install plugin gsite docker exec -i dd-apps-wordpress sh -s <<-EOF