Files
soci/scripts/ci/install_oracle.sh
T
Vadim Zeitlin 186128d601 Don't hardcode bash path to improve portability
Under FreeBSD, for example, bash is installed only in /usr/local/bin and
/bin/bash is not available, so use "/usr/bin/env bash" to find it any
location.

As there doesn't seem to be any portable way to pass "-e" option to bash
when using env ("env -S" doesn't work with older GNU coreutils used in
GitHub CI Linux builds), set this option in common.sh once now instead
of doing it on the shebang line of all the scripts.

It would be even better to rewrite the scripts to avoid requiring bash,
but this would require more effort.
2022-06-21 20:09:44 +02:00

42 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Sets up Oracle database for SOCI Oracle backend CI builds.
#
source ${SOCI_SOURCE_DIR}/scripts/ci/common.sh
docker run --name ${ORACLE_CONTAINER} --detach --publish 1521:1521 -e ORACLE_ALLOW_REMOTE=true wnameless/oracle-xe-11g-r2
echo 'Waiting for Oracle startup...'
num_tries=1
wait_time=6 # seconds
while true; do
if oracle_exec /etc/init.d/oracle-xe status | grep -q 'Instance "XE", status READY'; then
if echo "SELECT STATUS, DATABASE_STATUS FROM V\$INSTANCE WHERE INSTANCE_NAME='XE';" | \
oracle_sqlplus sys/oracle AS SYSDBA | grep -q 'OPEN'; then
echo 'Oracle database is available now'
break
fi
fi
if [[ $num_tries -gt 50 ]]; then
echo 'Timed out waiting for Oracle startup'
break
fi
echo "Waiting $wait_time more seconds (attempt #$num_tries)"
sleep $wait_time
((num_tries++))
done
echo 'Oracle log:'
docker logs --timestamps ${ORACLE_CONTAINER}
echo 'Oracle global status:'
oracle_exec /etc/init.d/oracle-xe status
echo 'Oracle instance status:'
echo 'SELECT INSTANCE_NAME, STATUS, DATABASE_STATUS FROM V$INSTANCE;' | \
oracle_sqlplus sys/oracle AS SYSDBA
# Copy Oracle directory, notably containing the headers and the libraries
# needed for the compilation, from the container.
sudo mkdir -p ${ORACLE_HOME}
sudo docker cp ${ORACLE_CONTAINER}:${ORACLE_HOME} ${ORACLE_HOME}/..