|
| 1 | +# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved |
| 2 | + |
| 3 | +#!/usr/bin/env bash |
| 4 | +set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ |
| 5 | +cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 |
| 6 | + |
| 7 | +# Remove an existing Oracle DB docker image |
| 8 | +docker-compose -p oraclexedb down --remove-orphans |
| 9 | + |
| 10 | +# Bring up new Oracle DB docker image |
| 11 | +docker-compose -p oraclexedb up -d |
| 12 | + |
| 13 | +# Wait until Oracle DB is set up and docker state is healthy |
| 14 | +./../wait-until-healthy.sh oraclexedb |
| 15 | + |
| 16 | +# Moving privileges.sql to docker container |
| 17 | +docker cp ../privileges.sql oraclexedb:/opt/oracle/. |
| 18 | + |
| 19 | +# Granting all the needed privileges to sequelizetest user |
| 20 | +docker exec -t oraclexedb sqlplus system/password@XEPDB1 @privileges.sql |
| 21 | + |
| 22 | +SEQ_WORKSPACE="$PWD"/../../../ |
| 23 | + |
| 24 | +if [[ ! -d "$SEQ_WORKSPACE"/.oracle/ ]] |
| 25 | +then |
| 26 | + mkdir "$SEQ_WORKSPACE"/.oracle/ |
| 27 | + if [[ $(uname) == 'Linux' ]] |
| 28 | + then |
| 29 | + wget https://download.oracle.com/otn_software/linux/instantclient/217000/instantclient-basic-linux.x64-21.7.0.0.0dbru.zip --no-check-certificate && |
| 30 | + unzip instantclient-basic-linux.x64-21.7.0.0.0dbru.zip -d "$SEQ_WORKSPACE"/.oracle/ && |
| 31 | + rm instantclient-basic-linux.x64-21.7.0.0.0dbru.zip && |
| 32 | + mv "$SEQ_WORKSPACE"/.oracle/instantclient_21_7 "$SEQ_WORKSPACE"/.oracle/instantclient |
| 33 | + |
| 34 | + echo "Local Oracle instant client on Linux has been setup!" |
| 35 | + elif [[ $(uname) == 'Darwin' ]] |
| 36 | + then |
| 37 | + if [[ ! -d ~/Downloads/instantclient_19_8 ]] |
| 38 | + then |
| 39 | + curl -O https://download.oracle.com/otn_software/mac/instantclient/198000/instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg && |
| 40 | + hdiutil mount instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg && |
| 41 | + /Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru/install_ic.sh && |
| 42 | + hdiutil unmount /Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru && |
| 43 | + rm instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg && |
| 44 | + mv ~/Downloads/instantclient_19_8/ "$SEQ_WORKSPACE"/.oracle/instantclient |
| 45 | + else |
| 46 | + cp -rf ~/Downloads/instantclient_19_8/ "$SEQ_WORKSPACE"/.oracle/instantclient |
| 47 | + fi |
| 48 | + ln -s "$SEQ_WORKSPACE"/.oracle/instantclient/libclntsh.dylib "$SEQ_WORKSPACE"/node_modules/oracledb/build/Release/ |
| 49 | + |
| 50 | + echo "Local Oracle instant client on macOS has been setup!" |
| 51 | + else |
| 52 | + # Windows |
| 53 | + curl -O https://download.oracle.com/otn_software/nt/instantclient/216000/instantclient-basic-windows.x64-21.6.0.0.0dbru.zip && |
| 54 | + unzip instantclient-basic-windows.x64-21.6.0.0.0dbru.zip -d "$SEQ_WORKSPACE"/.oracle/ && |
| 55 | + rm instantclient-basic-windows.x64-21.6.0.0.0dbru.zip && |
| 56 | + mv "$SEQ_WORKSPACE"/.oracle/instantclient_21_6/* "$SEQ_WORKSPACE"/node_modules/oracledb/build/Release |
| 57 | + |
| 58 | + echo "Local Oracle instant client on $(uname) has been setup!" |
| 59 | + fi |
| 60 | +fi |
| 61 | +echo "Local Oracle DB is ready for use!" |
0 commit comments