Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions OracleDatabase/dockerfiles/11.2.0.2/checkDBStatus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#

ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
POSITIVE_RETURN="OPEN"
ORAENV_ASK=NO
source oraenv

Expand All @@ -28,10 +29,10 @@ EOF`
ret=$?

# SQL Plus execution was successful and database is open
if [ $ret -eq 0 ] && [ "$status" = "OPEN" ]; then
if [ $ret -eq 0 ] && [ "$status" = "$POSITIVE_RETURN" ]; then
exit 0;
# Database is not open
elif [ "$status" != "OPEN" ]; then
elif [ "$status" != "$POSITIVE_RETURN" ]; then
exit 1;
# SQL Plus execution failed
else
Expand Down
15 changes: 8 additions & 7 deletions OracleDatabase/dockerfiles/12.1.0.2/checkDBStatus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,34 @@
# Since: May, 2017
# Author: gerald.venzl@oracle.com
# Description: Checks the status of Oracle Database.
# Return codes: 0 = Database is open and ready to use
# 1 = Database is not open
# Return codes: 0 = PDB is open and ready to use
# 1 = PDB is not open
# 2 = Sql Plus execution failed
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#

ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
ORACLE_PDB="`ls -dl $ORACLE_BASE/oradata/$ORACLE_SID/*/ | grep -v pdbseed | awk '{print $9}' | cut -d/ -f6`"
POSITIVE_RETURN="READ WRITE"
ORAENV_ASK=NO
source oraenv

# Check Oracle DB status and store it in status
status=`sqlplus -s / as sysdba << EOF
set heading off;
set pagesize 0;
select status from v\\$instance;
SELECT open_mode FROM v\\$pdbs WHERE name = '$ORACLE_PDB';
exit;
EOF`

# Store return code from SQL*Plus
ret=$?

# SQL Plus execution was successful and database is open
if [ $ret -eq 0 ] && [ "$status" = "OPEN" ]; then
# SQL Plus execution was successful and PDB is open
if [ $ret -eq 0 ] && [ "$status" = "$POSITIVE_RETURN" ]; then
exit 0;
# Database is not open
elif [ "$status" != "OPEN" ]; then
# PDB is not open
elif [ "$status" != "$POSITIVE_RETURN" ]; then
exit 1;
# SQL Plus execution failed
else
Expand Down
15 changes: 8 additions & 7 deletions OracleDatabase/dockerfiles/12.2.0.1/checkDBStatus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,34 @@
# Since: May, 2017
# Author: gerald.venzl@oracle.com
# Description: Checks the status of Oracle Database.
# Return codes: 0 = Database is open and ready to use
# 1 = Database is not open
# Return codes: 0 = PDB is open and ready to use
# 1 = PDB is not open
# 2 = Sql Plus execution failed
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#

ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
ORACLE_PDB="`ls -dl $ORACLE_BASE/oradata/$ORACLE_SID/*/ | grep -v pdbseed | awk '{print $9}' | cut -d/ -f6`"
POSITIVE_RETURN="READ WRITE"
ORAENV_ASK=NO
source oraenv

# Check Oracle DB status and store it in status
status=`sqlplus -s / as sysdba << EOF
set heading off;
set pagesize 0;
select status from v\\$instance;
SELECT open_mode FROM v\\$pdbs WHERE name = '$ORACLE_PDB';
exit;
EOF`

# Store return code from SQL*Plus
ret=$?

# SQL Plus execution was successful and database is open
if [ $ret -eq 0 ] && [ "$status" = "OPEN" ]; then
# SQL Plus execution was successful and PDB is open
if [ $ret -eq 0 ] && [ "$status" = "$POSITIVE_RETURN" ]; then
exit 0;
# Database is not open
elif [ "$status" != "OPEN" ]; then
# PDB is not open
elif [ "$status" != "$POSITIVE_RETURN" ]; then
exit 1;
# SQL Plus execution failed
else
Expand Down