This commit is contained in:
Ladebeze66 2024-07-17 15:06:12 +02:00
commit 69ca21b80e
22 changed files with 830 additions and 0 deletions

62
data/Makefile Normal file
View File

@ -0,0 +1,62 @@
SHELL := /bin/bash
# Variables
HOSTNAME=fgras-ca.42.fr
HOSTS_FILE=/etc/hosts
VOLUME_DIR_MYSQL=/home/fgras-ca/Inception/data/mysql
VOLUME_DIR_HTML=/home/fgras-ca/Inception/data/html
all: sudo-validate setup-hosts create-volumes start-docker
sudo-validate:
@echo "Validating sudo credentials..."
@sudo -v
down:
@echo "Stopping and removing all Docker containers..."
@docker-compose -f /home/fgras-ca/Inception/data/scrs/docker-compose.yml down
re: down all
clean: down
@echo "Cleaning up Docker resources..."
@if [ $$(docker ps -qa | wc -l) -gt 0 ]; then \
echo "Stopping containers..."; \
docker stop $$(docker ps -qa); \
echo "Removing containers..."; \
docker rm $$(docker ps -qa); \
fi
@if [ $$(docker images -qa | wc -l) -gt 0 ]; then \
echo "Removing images..."; \
docker rmi -f $$(docker images -qa); \
fi
@if [ $$(docker volume ls -q | wc -l) -gt 0 ]; then \
echo "Removing volumes..."; \
docker volume rm $$(docker volume ls -q); \
fi
@docker system prune -a --force --volumes
@echo "Removing MySQL and HTML data directories..."
@sudo chmod -R 777 $(VOLUME_DIR_MYSQL)
@sudo chmod -R 777 $(VOLUME_DIR_HTML)
@sudo rm -rf $(VOLUME_DIR_MYSQL) $(VOLUME_DIR_HTML)
setup-hosts:
@echo "Configuring /etc/hosts..."
@if ! grep -q "$(HOSTNAME)" $(HOSTS_FILE); then \
echo "127.0.0.1 $(HOSTNAME)" | sudo tee -a $(HOSTS_FILE); \
fi
create-volumes:
@echo "Creating volume directories..."
@mkdir -p $(VOLUME_DIR_MYSQL) $(VOLUME_DIR_HTML)
start-docker:
@echo "Starting Docker Compose in detached mode..."
@docker-compose -f /home/fgras-ca/Inception/data/scrs/docker-compose.yml up -d --build
.PHONY: all re down clean setup-hosts create-volumes start-docker sudo-validate

16
data/scrs/.env Normal file
View File

@ -0,0 +1,16 @@
DOMAIN_NAME=fgras-ca.42.fr
CERTS_=/etc/nginx/ssl/inception.key
MYSQL_HOSTNAME=mariadb
MYSQL_DATABASE=wordpress
MYSQL_USER=fgras
MYSQL_PASSWORD=1234
MYSQL_ROOT_PASSWORD=5678
WP_TITLE=FernandGrasCalvet
WP_ADMIN_USR=fgras-ca
WP_ADMIN_PWD=1234
WP_ADMIN_EMAIL=fgras.ca@gmail.com
WP_USR=fgras
WP_EMAIL=fgras.ca@42.com
WP_PWD=123
ftp_user=Dino
ftp_pwd=gg66!

View File

@ -0,0 +1,62 @@
networks:
inception:
name: inception
driver: bridge
services:
mariadb:
container_name: mariadb
build: ./requirements/mariadb
ports:
- "3306:3306"
env_file:
- .env
volumes:
- mariadb_data:/var/lib/mysql
networks:
- inception
restart: always
wordpress:
container_name: wordpress
build:
context: ./requirements/wordpress
dockerfile: Dockerfile
env_file:
- .env
expose:
- "9000"
networks:
- inception
volumes:
- wordpress_data:/var/www/html
restart: always
nginx:
container_name: nginx
build: ./requirements/nginx
depends_on:
- wordpress
- mariadb
ports:
- "443:443"
volumes:
- wordpress_data:/var/www/html
- ./requirements/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
networks:
- inception
restart: always
volumes:
mariadb_data:
driver: local
driver_opts:
type: none
device: /home/fgras-ca/Inception/data/mysql
o: bind
wordpress_data:
driver: local
driver_opts:
type: none
device: /home/fgras-ca/Inception/data/html
o: bind

View File

@ -0,0 +1,26 @@
FROM debian:buster
# Install necessary packages
RUN apt update -y && apt upgrade -y
RUN apt-get install -y mariadb-server mariadb-client gettext-base
# Create the required directory for the Unix socket file
RUN mkdir -p /run/mysqld /var/www
RUN chown mysql:mysql /run/mysqld
# Copy configuration files
COPY ./conf/50-server.cnf /etc/mysql/mariadb.conf.d/
COPY ./tools/init_db.sql /etc/mysql/init_db.sql
COPY ./tools/init_db.sql /docker-entrypoint-initdb.d/init_db.sql
COPY ./tools/entrypoint.sh /usr/local/bin/entrypoint.sh
# Ensure the script and SQL file have the correct permissions
RUN chmod +x /usr/local/bin/entrypoint.sh
RUN chmod 644 /etc/mysql/init_db.sql
RUN chmod 644 /docker-entrypoint-initdb.d/init_db.sql
RUN chmod -R 777 /var/lib/mysql
EXPOSE 3306
# Use the entrypoint script
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

View File

@ -0,0 +1,9 @@
[mysql]
default-character-set=utf8
[mysqld]
datadir = /var/lib/mysql
#socket = /run/mysqld/mysqld.sock
bind_address=*
port = 3306
user = mysql

View File

@ -0,0 +1,32 @@
#!/bin/bash
# Créer un fichier SQL pour initialiser la base de données
cat << EOF > /docker-entrypoint-initdb.d/init_db.sql
CREATE DATABASE IF NOT EXISTS ${MYSQL_DATABASE};
CREATE USER IF NOT EXISTS '${MYSQL_USER}'@'%' IDENTIFIED BY '${MYSQL_PASSWORD}';
GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE}.* TO '${MYSQL_USER}'@'%';
FLUSH PRIVILEGES;
EOF
service mysql start
# Vérifier si le socket existe
if [ ! -S /var/run/mysqld/mysqld.sock ]; then
echo "Le fichier de socket MySQL n'existe pas. Création du socket..."
mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld
service mysql restart
fi
# Exécuter le script SQL
mysql -u root -p"${MYSQL_ROOT_PASSWORD}" < /docker-entrypoint-initdb.d/init_db.sql
if [ $? -ne 0 ]; then
echo "Échec de l'exécution du script SQL"
exit 1
fi
echo "=== Script SQL exécuté avec succès ==="
# Garder le conteneur en cours d'exécution
chown -R mysql:mysql /var/lib/mysql
tail -f /dev/null

View File

@ -0,0 +1,4 @@
CREATE DATABASE IF NOT EXISTS '${MYSQL_DATABASE}';
CREATE USER IF NOT EXISTS '${MYSQL_USER}'@'%' IDENTIFIED BY '${MYSQL_PASSWORD}';
GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE}.* TO '${MYSQL_USER}'@'%';
FLUSH PRIVILEGES;

View File

@ -0,0 +1,21 @@
FROM debian:buster
# Installer Nginx et OpenSSL
RUN apt update -y && apt upgrade -y
RUN apt-get install -y nginx vim openssl
# Créer le répertoire requis pour les certificats SSL
RUN mkdir -p /etc/nginx/ssl
# Copier les configurations de Nginx et le fichier default
COPY ./conf/nginx.conf /etc/nginx/nginx.conf
COPY ./conf/default /etc/nginx/sites-available/default
# Générer des certificats auto-signés pour SSL
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/inception.key -out /etc/nginx/ssl/inception.crt -subj "/C=FR/ST=IDF/L=Paris/O=42/OU=42/CN=fgras-ca.42.fr"
# Supprimer le lien symbolique existant et créer un nouveau lien symbolique pour le site par défaut
RUN rm -f /etc/nginx/sites-enabled/default && ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/
# Démarrer Nginx
CMD ["nginx", "-g", "daemon off;"]

View File

@ -0,0 +1,28 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name fgras.42.fr;
server_name www.fgras.42.fr;
# SSL certificates
ssl_certificate /etc/nginx/ssl/inception.crt;
ssl_certificate_key /etc/nginx/ssl/inception.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
root /var/www/html;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass wordpress:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

View File

@ -0,0 +1,49 @@
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/inception.crt;
ssl_certificate_key /etc/nginx/ssl/inception.key;
root /var/www/html;
server_name fgras-ca.42.fr;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass wordpress:9000;
}
}
}

View File

@ -0,0 +1,30 @@
FROM debian:buster
# Installer les paquets nécessaires
RUN apt update -y && apt upgrade -y && \
apt-get install -y php7.3-fpm php7.3-mysql mariadb-client wget curl vim && \
mkdir -p /var/www/html && \
wget https://fr.wordpress.org/wordpress-6.0-fr_FR.tar.gz -O /tmp/wordpress.tar.gz && \
tar -xzvf /tmp/wordpress.tar.gz -C /var/www/html --strip-components=1 && \
rm /tmp/wordpress.tar.gz && \
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x wp-cli.phar && mv wp-cli.phar /usr/local/bin/wp
RUN apt-get install sendmail -y
# Copier les fichiers de configuration PHP et le script d'auto-configuration
COPY ./conf/www.conf /etc/php/7.3/fpm/pool.d/
COPY ./conf/wp-config.php /var/www/html/
COPY ./tools/auto_config.sh /usr/local/bin/
# Assurer les bonnes permissions pour les fichiers
RUN chmod +x /usr/local/bin/auto_config.sh && \
chmod -R 755 /var/www/html && \
chown -R www-data:www-data /var/www/html ; \
chown www-data:www-data /var/www/html/index.php
RUN chmod -R 777 /var/www/html
COPY ./conf/web /var/www/html
RUN chmod -R 777 /var/www/html
EXPOSE 9000
ENTRYPOINT ["/usr/local/bin/auto_config.sh"]

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 KiB

View File

@ -0,0 +1,170 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>INCEPTION - 42 Perpignan</title>
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap" rel="stylesheet">
<style>
body, html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background: #141414;
overflow: hidden;
font-family: 'Orbitron', sans-serif;
position: relative;
}
.container {
text-align: center;
color: #ffffff;
z-index: 1;
position: relative;
width: 100%;
height: 100%;
}
.title {
font-size: 4em;
font-weight: bold;
color: #ffffff; /* Blanc */
position: absolute;
top: 20px;
left: 20px;
}
.school {
font-size: 3em;
font-weight: bold;
color: #0000ff; /* Bleu */
position: absolute;
top: 50%;
right: 20px;
transform: translateY(-50%);
}
.pseudo {
font-size: 2em;
font-weight: bold;
color: #8b0000; /* Rouge tendant vers le violet */
position: absolute;
bottom: 20px;
left: 20px;
}
.datetime {
font-size: 1.5em;
color: #ff6666; /* Rouge plus clair */
position: absolute;
bottom: 20px;
right: 20px;
}
.button {
display: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 10px 20px;
font-size: 1.5em;
background-color: rgba(255, 255, 255, 0.5); /* Transparence */
color: #000000;
font-weight: bold;
border: none;
cursor: pointer;
}
.jump-scare {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 9999;
width: 0;
height: 0;
overflow: hidden;
}
.jump-scare img {
width: 100%;
height: auto;
}
@keyframes rainEffect {
0% {
clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
}
100% {
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
}
.background {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-image: url('Inception_Visual.webp');
background-repeat: no-repeat;
background-size: cover;
animation: zoomIn 20s infinite;
}
@keyframes zoomIn {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
</style>
</head>
<body>
<div class="background"></div>
<div class="container">
<div class="title">INCEPTION</div>
<div class="school">42 Perpignan</div>
<div class="pseudo">fgras-ca</div>
<div class="datetime" id="datetime"></div>
<button class="button" id="myButton">Click there!!</button>
<div class="jump-scare" id="jumpScare">
<!-- Columns will be generated by JavaScript -->
</div>
</div>
<script>
function updateDateTime() {
const now = new Date();
const datetimeElement = document.getElementById('datetime');
const options = { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' };
datetimeElement.textContent = now.toLocaleDateString('fr-FR', options);
}
setInterval(updateDateTime, 1000);
updateDateTime();
function showButton() {
document.getElementById('myButton').style.display = 'block';
}
setTimeout(showButton, 5000);
document.getElementById('myButton').addEventListener('click', function() {
const jumpScareContainer = document.getElementById('jumpScare');
const imageSrc = 'jump_scare_image.webp'; // Update with your image path
const columns = 50; // Number of columns
const columnWidth = 100 / columns;
jumpScareContainer.style.width = '80%';
jumpScareContainer.style.height = '80%';
for (let i = 0; i < columns; i++) {
const column = document.createElement('div');
column.classList.add('column');
column.style.position = 'absolute';
column.style.top = '0';
column.style.left = `${i * columnWidth}%`;
column.style.width = `${columnWidth}%`;
column.style.height = '100%';
column.style.backgroundImage = `url(${imageSrc})`;
column.style.backgroundSize = `${columns * 100}% 100%`;
column.style.backgroundPosition = `${-i * 100}% 0`;
column.style.animation = `rainEffect 10s ease-in-out ${Math.random() * 5}s forwards`;
jumpScareContainer.appendChild(column);
}
jumpScareContainer.style.display = 'block';
});
</script>
</body>
</html>

View File

@ -0,0 +1,170 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>INCEPTION - 42 Perpignan</title>
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap" rel="stylesheet">
<style>
body, html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background: #141414;
overflow: hidden;
font-family: 'Orbitron', sans-serif;
position: relative;
}
.container {
text-align: center;
color: #ffffff;
z-index: 1;
position: relative;
width: 100%;
height: 100%;
}
.title {
font-size: 4em;
font-weight: bold;
color: #ffffff; /* Blanc */
position: absolute;
top: 20px;
left: 20px;
}
.school {
font-size: 3em;
font-weight: bold;
color: #0000ff; /* Bleu */
position: absolute;
top: 50%;
right: 20px;
transform: translateY(-50%);
}
.pseudo {
font-size: 2em;
font-weight: bold;
color: #8b0000; /* Rouge tendant vers le violet */
position: absolute;
bottom: 20px;
left: 20px;
}
.datetime {
font-size: 1.5em;
color: #ff6666; /* Rouge plus clair */
position: absolute;
bottom: 20px;
right: 20px;
}
.button {
display: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 10px 20px;
font-size: 1.5em;
background-color: rgba(255, 255, 255, 0.5); /* Transparence */
color: #000000;
font-weight: bold;
border: none;
cursor: pointer;
}
.jump-scare {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 9999;
width: 0;
height: 0;
overflow: hidden;
}
.jump-scare img {
width: 100%;
height: auto;
}
@keyframes rainEffect {
0% {
clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
}
100% {
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
}
.background {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-image: url('Inception_Visual.webp');
background-repeat: no-repeat;
background-size: cover;
animation: zoomIn 20s infinite;
}
@keyframes zoomIn {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
</style>
</head>
<body>
<div class="background"></div>
<div class="container">
<div class="title">INCEPTION</div>
<div class="school">42 Perpignan</div>
<div class="pseudo">fgras-ca</div>
<div class="datetime" id="datetime"></div>
<button class="button" id="myButton">Click there!!</button>
<div class="jump-scare" id="jumpScare">
<!-- Columns will be generated by JavaScript -->
</div>
</div>
<script>
function updateDateTime() {
const now = new Date();
const datetimeElement = document.getElementById('datetime');
const options = { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' };
datetimeElement.textContent = now.toLocaleDateString('fr-FR', options);
}
setInterval(updateDateTime, 1000);
updateDateTime();
function showButton() {
document.getElementById('myButton').style.display = 'block';
}
setTimeout(showButton, 5000);
document.getElementById('myButton').addEventListener('click', function() {
const jumpScareContainer = document.getElementById('jumpScare');
const imageSrc = 'jump_scare_image.webp'; // Update with your image path
const columns = 50; // Number of columns
const columnWidth = 100 / columns;
jumpScareContainer.style.width = '80%';
jumpScareContainer.style.height = '80%';
for (let i = 0; i < columns; i++) {
const column = document.createElement('div');
column.classList.add('column');
column.style.position = 'absolute';
column.style.top = '0';
column.style.left = `${i * columnWidth}%`;
column.style.width = `${columnWidth}%`;
column.style.height = '100%';
column.style.backgroundImage = `url(${imageSrc})`;
column.style.backgroundSize = `${columns * 100}% 100%`;
column.style.backgroundPosition = `${-i * 100}% 0`;
column.style.animation = `rainEffect 10s ease-in-out ${Math.random() * 5}s forwards`;
jumpScareContainer.appendChild(column);
}
jumpScareContainer.style.display = 'block';
});
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 KiB

View File

@ -0,0 +1,31 @@
<?php
define('DB_NAME', 'wordpress');
define('DB_USER', 'fgras');
define('DB_PASSWORD', '1234');
define('DB_HOST', 'mariadb');
define('URL', getenv('DOMAIN_NAME'));
define('TITLE', getenv('WP_TITLE'));
define('ADMIN_USER', getenv('WP_ADMIN_USR'));
define('ADMIN_PASSWORD', getenv('WP_ADMIN_PWD'));
define('ADMIN_EMAIL', getenv('WP_ADMIN_EMAIL'));
define('WP_HOME', 'https://' . getenv('DOMAIN_NAME'));
define('WP_SITEURL', 'https://' . getenv('DOMAIN_NAME'));
define('WP_USR', getenv('fgras'));
define('AUTH_KEY', 'AIE4!9u^Xf93DSe(-Y-=v$CU#f}N5qwR/43{/A_?aX@6{!8Ysk^G];W= DXtN.pV');
define('SECURE_AUTH_KEY', ';o*Qw7fZg,=2{SpKy8Ic9<=wGJAPt|8s<.yxfTcrSQgvH[/+!/@l20?1nd^C#MS`');
define('LOGGED_IN_KEY', ')?zr-W7s~RDR5PW|V6Ie`9Heq~T23IeQeD%*Z/U^|b%3 sk+z`3m|)#zyRr2pf=!');
define('NONCE_KEY', 'Gtp-]EJS)-T&4NQP4R$-|2=5w}p|Ac:UFX#+ bU$%1|2[H6xH=;zIvH$)r)q2Y>v');
define('AUTH_SALT', 'P`?.eaIu-G3fZYiN|/X[Sdc!ZVu9Lf<J}0&%/5B0Tp~)<),WqGdpKgC~W>vP>26(');
define('SECURE_AUTH_SALT', 'ZnDGUX{EtppgS7gTLqg|xYcS26(WB-xP3?ldWSs|Ak;UTWpJ<SCoh(]2sE8(jL9a');
define('LOGGED_IN_SALT', 'h}7^=g(R+c#[T3tIu3|wJpBQ{]aheu(+{k>`fGisKDii7agi^P}-@}Gm#m>A6Gb|');
define('NONCE_SALT', 'ZaiFh{H~?Z34?18v[=Wi<T0k&nQMm2%L:l:|:z<f[knH^yz&#oEaR0g6h1Z-MLzH');
$table_prefix = 'wp_';
define('WP_DEBUG', false);
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
require_once(ABSPATH . 'wp-settings.php');

View File

@ -0,0 +1,12 @@
[www]
user = www-data
group = www-data
listen = wordpress:9000
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 5
pm.start_Servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
clear_env = no

View File

@ -0,0 +1,37 @@
#!/bin/bash
# Démarrer PHP-FPM
service php7.3-fpm start
# Attendre que MariaDB soit prêt
until mysqladmin ping -h mariadb --silent; do
echo "Waiting for MariaDB to be ready..."
sleep 2
done
# Télécharger WP-CLI si nécessaire
if [ ! -f /usr/local/bin/wp ]; then
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
fi
# Télécharger et extraire WordPress
if [ ! -f /var/www/html/wp-config.php ]; then
wget https://fr.wordpress.org/wordpress-6.0-fr_FR.tar.gz -O /tmp/wordpress.tar.gz
tar -xzvf /tmp/wordpress.tar.gz -C /var/www/html --strip-components=1
chown -R www-data:www-data /var/www/html
chmod -R 755 /var/www/html
chmod -R 777 /var/www/html
fi
# Installer WordPress
if ! $(wp core is-installed --path='/var/www/html' --allow-root); then
wp core install --url=${DOMAIN_NAME} --title=${WP_TITLE} --admin_user=${WP_ADMIN_USR} --admin_password=${WP_ADMIN_PWD} --admin_email=${WP_ADMIN_EMAIL} --path='/var/www/html' --allow-root
echo "=== WordPress installed ==="
else
echo "=== WordPress is already installed ==="
fi
# Garder le conteneur en cours d'exécution
tail -f /dev/null

71
data/setup.sh Executable file
View File

@ -0,0 +1,71 @@
#!/bin/bash
USER="fgras-ca"
# Vérifiez si le script est exécuté en tant que root
if [ "$(whoami)" != "root" ]; then
echo "This script must be run as root"
exit 1
fi
# Ajouter l'utilisateur au fichier sudoers
if ! grep -q "$USER ALL=(ALL:ALL) ALL" /etc/sudoers; then
echo "Adding $USER to sudoers file..."
echo "$USER ALL=(ALL:ALL) ALL" >> /etc/sudoers
fi
# Configurer le délai de validité du mot de passe sudo à une durée indéfinie
if ! grep -q "timestamp_timeout=-1" /etc/sudoers; then
echo "Setting sudo password timeout to indefinite..."
echo "Defaults timestamp_timeout=-1" >> /etc/sudoers
fi
# Mise à jour des paquets
echo "Updating package lists..."
apt-get update
# Installer les dépendances nécessaires pour Docker
echo "Installing necessary packages..."
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release \
git \
make \
wget
# Ajouter la clé GPG officielle de Docker
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Ajouter le dépôt Docker
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
# Mettre à jour les paquets à nouveau et installer Docker
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io
# Installer Docker Compose
echo "Installing Docker Compose..."
DOCKER_COMPOSE_VERSION="1.29.2"
curl -L "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# Ajouter l'utilisateur au groupe Docker
echo "Adding user to Docker group..."
usermod -aG docker $USER
# Installation de Visual Studio Code
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
install -o root -g root -m 644 packages.microsoft.gpg /usr/share/keyrings/
sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
apt-get update
apt-get install -y code
rm packages.microsoft.gpg
echo "Setup completed. Please log out and log back in for the Docker group changes to take effect."