added protections when installing wp
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
|
||||
# DOCKER-COMPOSE
|
||||
|
||||
LOGIN=$USER
|
||||
LOGIN=hulamy
|
||||
|
||||
# MARIADB SETUP
|
||||
|
||||
DB_HOST=mariadb
|
||||
DB_NAME=db_wp_inception
|
||||
DB_USER=user_wp_inception
|
||||
DB_PSWD="if you read this i will have to erase your memory"
|
||||
#ROOT_PSWD="root passphrase"
|
||||
DB_PSWD="too bad you have read this now i have to erase your memory"
|
||||
|
||||
# WORDPRESS SETUP
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ version: "3.8"
|
||||
services:
|
||||
# ---------------------------------
|
||||
nginx:
|
||||
# restart: on-failure
|
||||
#restart: on-failure
|
||||
networks:
|
||||
- inception
|
||||
ports:
|
||||
- "443:443"
|
||||
# - "80:80"
|
||||
#- "80:80"
|
||||
volumes:
|
||||
- wp_volume:/var/www/html
|
||||
build: ./requirements/nginx
|
||||
@@ -26,7 +26,7 @@ services:
|
||||
condition: service_started
|
||||
# ---------------------------------
|
||||
mariadb:
|
||||
# restart: on-failure
|
||||
#restart: on-failure
|
||||
env_file: .env
|
||||
networks:
|
||||
- inception
|
||||
@@ -48,7 +48,7 @@ services:
|
||||
container_name: mariadb_container
|
||||
# ---------------------------------
|
||||
wordpress:
|
||||
# restart: on-failure
|
||||
#restart: on-failure
|
||||
env_file: ./.env
|
||||
networks:
|
||||
- inception
|
||||
|
||||
@@ -1,22 +1,45 @@
|
||||
#!/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"
|
||||
|
||||
# install wordpress with cli : https://make.wordpress.org/cli/handbook/how-to-install/
|
||||
# commands : https://developer.wordpress.org/cli/commands/
|
||||
mkdir -p ${WP_DIR}
|
||||
wp core download --path="${WP_DIR}" --allow-root
|
||||
#if ! wp core version --path="${WP_DIR}" --quiet; then
|
||||
echo -e ${YELLOW}download wordpress :${RESET}
|
||||
if ! wp core version --path="${WP_DIR}" 2> /dev/null
|
||||
then
|
||||
mkdir -p ${WP_DIR}
|
||||
wp core download --path="${WP_DIR}" --allow-root
|
||||
else
|
||||
echo -e ${GREEN}already there !${RESET}
|
||||
fi
|
||||
|
||||
# create config file :
|
||||
if ! wp core version --path="${WP_DIR}"; then
|
||||
echo -e ${YELLOW}config wordpress :${RESET}
|
||||
if ! wp config path --path="${WP_DIR}" --quiet 2> /dev/null
|
||||
then
|
||||
wp config create \
|
||||
--dbhost="${DB_HOST}" \
|
||||
--dbname="${DB_NAME}" \
|
||||
--dbuser="${DB_USER}" \
|
||||
--dbpass="${DB_PSWD}" \
|
||||
--path="${WP_DIR}" --allow-root
|
||||
else
|
||||
echo -e ${GREEN}already configured !${RESET}
|
||||
fi
|
||||
|
||||
# install wordpress :
|
||||
if ! wp core is-installed --path="${WP_DIR}"; then
|
||||
echo -e ${YELLOW}install wordpress :${RESET}
|
||||
if ! wp core is-installed --path="${WP_DIR}" 2> /dev/null
|
||||
then
|
||||
wp core install \
|
||||
--url="${WP_URL}" \
|
||||
--title="${WP_TITLE}" \
|
||||
@@ -25,13 +48,21 @@ if ! wp core is-installed --path="${WP_DIR}"; then
|
||||
--admin_password="${WP_ADMIN_PSWD}" \
|
||||
--skip-email \
|
||||
--path="${WP_DIR}" --allow-root
|
||||
else
|
||||
echo -e ${GREEN}already installed !${RESET}
|
||||
fi
|
||||
|
||||
# create user :
|
||||
echo -e ${YELLOW}create wordpress user :${RESET}
|
||||
if ! wp user get ${WP_USER} --path="${WP_DIR}" --field=login 2> /dev/null
|
||||
then
|
||||
wp user create \
|
||||
"${WP_USER}" "${WP_USER_EMAIL}" \
|
||||
--user_pass="${WP_USER_PSWD}" \
|
||||
--path="${WP_DIR}" --allow-root
|
||||
else
|
||||
echo -e ${GREEN}already created !${RESET}
|
||||
fi
|
||||
|
||||
# change owner and permissions to wp files
|
||||
chown -R www-data:www-data /var/www/*
|
||||
|
||||
Reference in New Issue
Block a user