diff --git a/Makefile b/Makefile index 3f94f53..0eb1535 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ require: mkdir -p $(VOLUMES_D) # verify if the wordpress url is added to the local path @echo $(B_PURPLE)"verify if the wordpress url is added to the local path"$(RESET) - - if ! grep "127.0.0.1 $(WP_URL)" /etc/hosts 2> /dev/null; then \ + - if ! grep "127.0.0.1 $(WP_URL)" /etc/hosts 2> /dev/null; then \ echo $(B_PURPLE)"nop ! adding it"$(RESET) \ bash -c 'echo -e "\n# adding for lejourduprof (you can delete it)\n127.0.0.1 $(WP_URL)" >> /etc/hosts'; \ fi @@ -76,7 +76,7 @@ build_logs: up: docker compose -f $(COMPOSE_FILE) up -d - @echo $(B_PURPLE)"you can now connect at "$(B_YELLOW)"https://$(WP_URL)"$(B_PURPLE)" or 127.0.0.1"$(RESET) + @echo $(B_PURPLE)"you can now connect at "$(B_YELLOW)"https://$(WP_COMPLETE_URL)"$(B_PURPLE)" or 127.0.0.1"$(RESET) down: docker compose -f $(COMPOSE_FILE) down diff --git a/srcs/.env b/srcs/.env index fea73ab..56dd5f0 100644 --- a/srcs/.env +++ b/srcs/.env @@ -12,6 +12,7 @@ PROJECT=jipf WP_ADMIN=admin WP_ADMIN_EMAIL=admin@email.fr WP_ADMIN_PSWD='you shall not password !' +WP_COMPLETE_URL=local_lejourduprof.com:3003 WP_PORT=3003 WP_TITLE=title WP_URL=local_lejourduprof.com diff --git a/srcs/model.env b/srcs/model.env index 543a1d0..dede21e 100644 --- a/srcs/model.env +++ b/srcs/model.env @@ -17,6 +17,11 @@ DB_PSWD="you dont want to know" WP_URL=local_lejourduprof.com WP_PORT=3003 +# concat url with port if not 443 +WP_COMPLETE_URL="${WP_URL}" +if [ ! ${WP_PORT} -eq 443 ]; then + WP_COMPLETE_URL="${WP_URL}:${WP_PORT}" +fi WP_VOLUME_DIR=/var/www/html #WP_VOLUME_PLUGINS=/home/www-data WP_TITLE=title diff --git a/srcs/requirements/wordpress/conf/wp_entrypoint.sh b/srcs/requirements/wordpress/conf/wp_entrypoint.sh index 406101f..988cccc 100644 --- a/srcs/requirements/wordpress/conf/wp_entrypoint.sh +++ b/srcs/requirements/wordpress/conf/wp_entrypoint.sh @@ -29,13 +29,6 @@ else fi -# concat url with port if not 443 -echo -n "check port : " -COMPLETE_URL="${WP_URL}" -if [ ! ${WP_PORT} -eq 443 ]; then - COMPLETE_URL="${WP_URL}:${WP_PORT}" -fi - # install wp if not already installed if ! wp core is-installed --path="${WP_VOLUME_DIR}" 2> /dev/null then @@ -73,12 +66,12 @@ else #https://stackoverflow.com/questions/56344567/wordpress-prevent-redirection-to-main-url echo -e ${YELLOW}checking config.php file with current url...${RESET} HOME=$(php wp-cli.phar config get WP_HOME --path=${WP_VOLUME_DIR}) - if [ ${HOME} != ${COMPLETE_URL} ] ; then - php wp-cli.phar config set WP_HOME ${COMPLETE_URL} --path=${WP_VOLUME_DIR} + if [ ${HOME} != ${WP_COMPLETE_URL} ] ; then + php wp-cli.phar config set WP_HOME ${WP_COMPLETE_URL} --path=${WP_VOLUME_DIR} fi SITEURL=$(php wp-cli.phar config get WP_SITEURL --path=${WP_VOLUME_DIR}) - if [ ${SITEURL} != ${COMPLETE_URL} ] ; then - php wp-cli.phar config set WP_SITEURL ${COMPLETE_URL} --path=${WP_VOLUME_DIR} + if [ ${SITEURL} != ${WP_COMPLETE_URL} ] ; then + php wp-cli.phar config set WP_SITEURL ${WP_COMPLETE_URL} --path=${WP_VOLUME_DIR} fi fi