#!/bin/sh GRAY="\e[0;30m" RED="\e[0;31m" GREEN="\e[0;32m" YELLOW="\e[0;33m" BLUE="\e[0;34m" PURPLE="\e[0;35m" CYAN="\e[0;36m" WHITE="\e[0;37m" RESET="\e[0m" # it gets the ENV variables from .env because specified in the docker-compose.yml file # install wordpress with cli : https://make.wordpress.org/cli/handbook/how-to-install/ # commands : https://developer.wordpress.org/cli/commands/ # bug with wp commands : https://github.com/wp-cli/config-command/issues/31 # -> use `php wp-cli.phar` instead of `wp` as command echo -e ${YELLOW}download wordpress :${RESET} if ! wp core version --path="${WP_VOLUME_DIR}" 2> /dev/null then echo -e ${YELLOW}wp core download...${RESET} mkdir -p ${WP_VOLUME_DIR} #wp core download --path="${WP_VOLUME_DIR}" --allow-root php wp-cli.phar core download --path="${WP_VOLUME_DIR}" --allow-root else echo -e ${GREEN}already there !${RESET} fi # install wp if not already installed if ! wp core is-installed --path="${WP_VOLUME_DIR}" 2> /dev/null then echo -e ${YELLOW}installing :${RESET} #wp config create \ echo -e ${YELLOW}wp config create...${RESET} php wp-cli.phar config create \ --dbhost="${DB_HOST}" \ --dbname="${DB_NAME}" \ --dbuser="${DB_USER}" \ --dbpass="${DB_PSWD}" \ --path="${WP_VOLUME_DIR}" --allow-root #wp core install \ echo -e ${YELLOW}wp core install...${RESET} php wp-cli.phar core install \ --url="${WP_URL}" \ --title="${WP_TITLE}" \ --admin_user="${WP_ADMIN}" \ --admin_email="${WP_ADMIN_EMAIL}" \ --admin_password="${WP_ADMIN_PSWD}" \ --skip-email \ --path="${WP_VOLUME_DIR}" --allow-root echo -e ${YELLOW}chown and chmod...${RESET} chown -R www-data:www-data /var/www/* chmod 755 -R /var/www/* echo -e ${YELLOW}plugins...${RESET} plugins=$(ls ${WP_VOLUME_PLUGINS}) for dir in $plugins; do ln -s ${WP_VOLUME_PLUGINS}/$dir ${WP_VOLUME_DIR}/wp-content/plugins/$dir done echo -e ${GREEN}done !${RESET} else echo -e ${GREEN}wp is installed${RESET} fi # https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/ echo -e ${YELLOW}configuring the error logs...${RESET} # Enable WP_DEBUG mode php wp-cli.phar config set WP_DEBUG true --raw --path=${WP_VOLUME_DIR} # Enable Debug logging to a file (if set to true, this is the /wp-content/debug.log file) php wp-cli.phar config set WP_DEBUG_LOG true --raw --path=${WP_VOLUME_DIR} #php wp-cli.phar config set WP_DEBUG_LOG "${ERRORS_LOGS_VOLUME}/wp_error.log" --path=${WP_VOLUME_DIR} # Disable display of errors and warnings php wp-cli.phar config set WP_DEBUG_DISPLAY false --raw --path=${WP_VOLUME_DIR} # exec php-fpm7 -FR # php-fpm7 --help : # -F, --nodaemonize : force to stay in foreground, and ignore daemonize option from config file # -R, --allow-to-run-as-root : Allow pool to run as root (disabled by default) exec "${PHP_VERSION}" -FR