diff --git a/scripts/common/common_utils.sh b/scripts/common/common_utils.sh index 3f561b2..d14d93d 100644 --- a/scripts/common/common_utils.sh +++ b/scripts/common/common_utils.sh @@ -67,10 +67,10 @@ get_fqdn_and_domain() { # Vérification de la résolution DNS check_dns() { local server_name=$1 - + # Récupération de l'adresse IP publique du serveur SERVER_IP=$(curl -4 -s ifconfig.me || hostname -I | awk '{print $1}') - + # Récupération de l'adresse IP associée au FQDN FQDN_IP=$(dig +short A "$server_name" | tail -n1) @@ -78,17 +78,18 @@ check_dns() { if [[ -z "$FQDN_IP" ]]; then echo "❌ Erreur : Impossible de récupérer l'adresse IP associée à $server_name via DIG." echo "➡️ Vérifie la configuration DNS et l'existence du domaine." - exit 1 + return 1 # Erreur bloquante uniquement ici fi - # Comparaison des IPs + # Comparaison des IPs mais uniquement en Alerte non bloquante if [[ "$SERVER_IP" != "$FQDN_IP" ]]; then echo "⚠️ Alerte DNS : L'adresse IP résolue ($FQDN_IP) ne correspond pas à l'IP publique actuelle ($SERVER_IP)." - echo "➡️ Vérifie la configuration DNS et la propagation des enregistrements." - exit 1 + echo "➡️ Vérifie la configuration DNS et la propagation si nécessaire." + else + echo "✅ Vérification réussie : $server_name pointe correctement vers $SERVER_IP." fi - echo "✅ Vérification réussie : $server_name pointe correctement vers $SERVER_IP." + return 0 } diff --git a/scripts/server-httpd/add_domain.sh b/scripts/server-httpd/add_domain.sh index 082672c..02f1b38 100644 --- a/scripts/server-httpd/add_domain.sh +++ b/scripts/server-httpd/add_domain.sh @@ -9,16 +9,15 @@ source "$(dirname "$0")/../common/common_utils.sh" # Vérifier si le script est exécuté en root check_root -# Vérification DNS -check_dns "$DOMAIN" +# Vérification DNS (alerte non bloquante) +if ! check_dns "$DOMAIN"; then + echo "⚠️ Attention : Résolution DNS impossible pour $DOMAIN. Vérifie si c'est bien ce que tu veux." +fi REVERSED_DOMAIN=$(echo "$DOMAIN" | awk -F. '{for(i=NF; i>0; i--) printf "%s%s", $i, (i>1 ? "." : "")}') VHOST_CONF="/etc/apache2/sites-available/$REVERSED_DOMAIN.conf" -# Créer les dossiers nécessaires -mkdir -p "$BACKUP_DIR" "$TEMPLATE_DIR" "$CHALLENGE_DIR" -chown -R www-data:www-data "$CHALLENGE_DIR" - +# Préparer le dossier du VirtualHost mkdir -p "/var/www/$REVERSED_DOMAIN" chown -R www-data:www-data "/var/www/$REVERSED_DOMAIN" chmod -R 755 "/var/www/$REVERSED_DOMAIN" diff --git a/scripts/server-httpd/install-php8-3.sh b/scripts/server-httpd/install-php8-3.sh index 095697b..9c44c5f 100644 --- a/scripts/server-httpd/install-php8-3.sh +++ b/scripts/server-httpd/install-php8-3.sh @@ -43,11 +43,47 @@ PHP_VERSION="8.3" # Vérification de l'installation de PHP echo -e "${YELLOW}Installation de PHP $PHP_VERSION et des modules courants...${RESET}" -apt install -y php$PHP_VERSION php$PHP_VERSION-cli php$PHP_VERSION-fpm \ - php$PHP_VERSION-mysql php$PHP_VERSION-curl php$PHP_VERSION-gd \ - php$PHP_VERSION-mbstring php$PHP_VERSION-xml php$PHP_VERSION-zip \ - php$PHP_VERSION-bcmath php$PHP_VERSION-soap php$PHP_VERSION-intl \ - php$PHP_VERSION-readline php$PHP_VERSION-ldap php$PHP_VERSION-imagick || { echo -e "${RED}Échec de l'installation de PHP${RESET}"; exit 1; } + +# Base des modules PHP à installer +PHP_MODULES=( + php${PHP_VERSION} + php${PHP_VERSION}-cli + php${PHP_VERSION}-fpm + php${PHP_VERSION}-curl + php${PHP_VERSION}-gd + php${PHP_VERSION}-mbstring + php${PHP_VERSION}-xml + php${PHP_VERSION}-zip + php${PHP_VERSION}-bcmath + php${PHP_VERSION}-soap + php${PHP_VERSION}-intl + php${PHP_VERSION}-readline + php${PHP_VERSION}-ldap + php${PHP_VERSION}-imagick + php${PHP_VERSION}-exif + php${PHP_VERSION}-gmp + php${PHP_VERSION}-apcu + php${PHP_VERSION}-opcache +) + +# Vérification MySQL / MariaDB +if dpkg -l | grep -qE 'mysql-server|mariadb-server'; then + echo -e "${GREEN}MySQL/MariaDB détecté. Ajout du module php-mysql.${RESET}" + PHP_MODULES+=(php${PHP_VERSION}-mysql) +fi + +# Vérification PostgreSQL +if dpkg -l | grep -q postgresql; then + echo -e "${GREEN}PostgreSQL détecté. Ajout du module php-pgsql.${RESET}" + PHP_MODULES+=(php${PHP_VERSION}-pgsql) +fi + +# Installation des modules PHP +echo -e "${GREEN}Installation des modules PHP...${RESET}" +apt install -y "${PHP_MODULES[@]}" || { + echo -e "${RED}❌ Échec de l'installation de PHP ou des modules.${RESET}" + exit 1 +} # Vérification si Apache est installé et installation du module PHP si nécessaire if systemctl list-units --type=service --all | grep -q "apache2.service"; then