From a263b6235d18f9ad112f34449a95b2e1f95cca74 Mon Sep 17 00:00:00 2001 From: Yacine31 Date: Thu, 24 Jun 2021 10:20:05 +0200 Subject: [PATCH] update dbora init --- .../tasks/scripts_exploitation.yml | 7 ++- install-oracle-sw/templates/dbora_initd.j2 | 44 +++++++++++++ install-oracle-sw/templates/oracledb_initd.j2 | 63 ------------------- 3 files changed, 49 insertions(+), 65 deletions(-) create mode 100644 install-oracle-sw/templates/dbora_initd.j2 delete mode 100644 install-oracle-sw/templates/oracledb_initd.j2 diff --git a/install-oracle-sw/tasks/scripts_exploitation.yml b/install-oracle-sw/tasks/scripts_exploitation.yml index 89eb90a..c451e59 100644 --- a/install-oracle-sw/tasks/scripts_exploitation.yml +++ b/install-oracle-sw/tasks/scripts_exploitation.yml @@ -10,9 +10,12 @@ # copy du fichier oracledb dans /etc/init.d pour redémmarage auto # --------------------------------------------------- - name: Copie du script de démarrage auto des bases Oracle - template: src=oracledb_initd.j2 dest=/etc/init.d/oracle_db owner=root mode=755 + template: src=dbora_initd.j2 dest=/etc/init.d/dbora owner=root mode=755 - - debug: msg="Le script /etc/init.d/oracle_db est postionné pour démarrer et arrêter les bases au reboot" + - name: Activation par chkconfig du script de démarrage auto des bases Oracle + service: name=dbora enabled=yes + + - debug: msg="Le script /etc/init.d/dbora est postionné pour démarrer et arrêter les bases au reboot" - debug: msg="Pensez à mettre Y au lieu de N dans /etc/oratab pour les bases à démarreage automatique" - debug: msg="Pensez aussi à activier le script par chkconfig ou systemd" diff --git a/install-oracle-sw/templates/dbora_initd.j2 b/install-oracle-sw/templates/dbora_initd.j2 new file mode 100644 index 0000000..ff73b93 --- /dev/null +++ b/install-oracle-sw/templates/dbora_initd.j2 @@ -0,0 +1,44 @@ +#!/bin/bash +# +# +# chkconfig: 35 98 08 +# +# description: Oracle auto start-stop script. +# Set ORA_HOME to be equivalent to the $ORACLE_HOME +# from which you wish to execute dbstart and dbshut; +# +# Set ORA_OWNER to the user id of the owner of the +# Oracle database in ORACLE_HOME. + +ORA_HOME={{ db_home }} +ORACLE_HOME_LISTENER={{ db_home }} +ORA_OWNER={{ oracle_user }} + +case "$1" in +'start') + # Start the Oracle databases: + # The following command assumes that the oracle login + # will not prompt the user for any values + # Remove "&" if you don't want startup as a background process. + su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" + touch /var/lock/subsys/dbora + ;; + +'stop') + # Stop the Oracle databases: + # The following command assumes that the oracle login + # will not prompt the user for any values + su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME" + rm -f /var/lock/subsys/dbora + ;; + +'restart') + stop + start + ;; + + *) + echo $"Usage: $0 {start|stop|restart}" + exit 2 +esac + diff --git a/install-oracle-sw/templates/oracledb_initd.j2 b/install-oracle-sw/templates/oracledb_initd.j2 deleted file mode 100644 index 84a2fbf..0000000 --- a/install-oracle-sw/templates/oracledb_initd.j2 +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# -# -# chkconfig: 35 98 08 - -### BEGIN INIT INFO -# Short-Description: start and stop db, oms and agent -# Description: start and stop db, oms and agent -### END INIT INFO - -# Source function library. -. /etc/init.d/functions - -prog=oracledb -lockfile=/var/lock/subsys/$prog - -export ORACLE_HOME={{ db_home }} - -start() { - [ "$NETWORKING" = "no" ] && exit 1 - - # Start daemons. - echo -n $"Starting $prog: " - - # Start everything - su - oracle -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" - - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && touch $lockfile - return $RETVAL -} - -stop() { - [ "$EUID" != "0" ] && exit 4 - echo -n $"Shutting down $prog: " - - # stop everything - su - oracle -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" - - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && rm -f $lockfile - return $RETVAL -} - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop - start - ;; - *) - echo $"Usage: $0 {start|stop|restart}" - exit 2 -esac -