From f1dc3267e96e5c2258a8afc262352effb7ed995e Mon Sep 17 00:00:00 2001 From: Yacine31 Date: Tue, 2 Dec 2025 16:19:48 +0100 Subject: [PATCH] Fix run_db_install.sh template for first-time installations - Check if inventory.xml exists before grep operation - Handle first installation scenario properly - Add informative messages for different installation states - Use more robust comparison (-ge 1 instead of == 1) --- .../templates/run_db_install.sh.j2 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/roles/oracle-db-install/templates/run_db_install.sh.j2 b/roles/oracle-db-install/templates/run_db_install.sh.j2 index a15144f..33aae49 100644 --- a/roles/oracle-db-install/templates/run_db_install.sh.j2 +++ b/roles/oracle-db-install/templates/run_db_install.sh.j2 @@ -1,11 +1,18 @@ # {{ ansible_managed }} #!/bin/bash -chkifinstalled=`grep "{{ oracle_home }}" "{{ oracle_inventory }}/ContentsXML/inventory.xml" |wc -l` -if [[ $chkifinstalled == 1 ]]; then - echo "Error: ORACLE_HOME: {{ oracle_home }} already present. Exiting" - exit 0 +# Vérifier si c'est une première installation ou si ORACLE_HOME existe déjà +if [[ -f "{{ oracle_inventory }}/ContentsXML/inventory.xml" ]]; then + chkifinstalled=`grep "{{ oracle_home }}" "{{ oracle_inventory }}/ContentsXML/inventory.xml" | wc -l` + if [[ $chkifinstalled -ge 1 ]]; then + echo "Error: ORACLE_HOME: {{ oracle_home }} already present. Exiting" + exit 0 + fi else + echo "First installation - inventory.xml not found, proceeding with installation" +fi + +# Configuration et installation linux_version=$(cat /etc/os-release | egrep "^VERSION=" | cut -d= -f2 | sed 's/"//g' | cut -d. -f1) if [ "${linux_version}" -ge 9 ] then