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)
This commit is contained in:
Yacine31
2025-12-02 16:19:48 +01:00
parent c9671bbf60
commit f1dc3267e9

View File

@@ -1,11 +1,18 @@
# {{ ansible_managed }} # {{ ansible_managed }}
#!/bin/bash #!/bin/bash
chkifinstalled=`grep "{{ oracle_home }}" "{{ oracle_inventory }}/ContentsXML/inventory.xml" |wc -l` # Vérifier si c'est une première installation ou si ORACLE_HOME existe déjà
if [[ $chkifinstalled == 1 ]]; then 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" echo "Error: ORACLE_HOME: {{ oracle_home }} already present. Exiting"
exit 0 exit 0
fi
else 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) linux_version=$(cat /etc/os-release | egrep "^VERSION=" | cut -d= -f2 | sed 's/"//g' | cut -d. -f1)
if [ "${linux_version}" -ge 9 ] if [ "${linux_version}" -ge 9 ]
then then