Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Externalise script createAppUser #103

Merged
merged 1 commit into from
Apr 17, 2022
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
2 changes: 1 addition & 1 deletion Dockerfile.11202
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ENV ORACLE_BASE=/u01/app/oracle \
ORACLE_SID=XE \
PATH=${PATH}:/u01/app/oracle/product/11.2.0/xe/bin:/u01/app/oracle

COPY oracle-xe-11.2.0-1.0.x86_64.rpm xe.11202.rsp install.11202.sh container-entrypoint.sh resetPassword healthcheck.sh /install/
COPY oracle-xe-11.2.0-1.0.x86_64.rpm xe.11202.rsp install.11202.sh container-entrypoint.sh resetPassword createAppUser healthcheck.sh /install/

RUN /install/install.11202.sh "${BUILD_MODE}"

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.1840
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ENV ORACLE_BASE=/opt/oracle \
ORACLE_SID=XE \
PATH=${PATH}:/opt/oracle/product/18c/dbhomeXE/bin:/opt/oracle

COPY oracle-database-xe-18c-1.0-1.x86_64.rpm install.1840.sh container-entrypoint.sh resetPassword healthcheck.sh /install/
COPY oracle-database-xe-18c-1.0-1.x86_64.rpm install.1840.sh container-entrypoint.sh resetPassword createAppUser healthcheck.sh /install/

RUN /install/install.1840.sh "${BUILD_MODE}"

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.2130
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ENV ORACLE_BASE=/opt/oracle \
ORACLE_SID=XE \
PATH=${PATH}:/opt/oracle/product/21c/dbhomeXE/bin:/opt/oracle

COPY oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm install.2130.sh container-entrypoint.sh resetPassword healthcheck.sh /install/
COPY oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm install.2130.sh container-entrypoint.sh resetPassword createAppUser healthcheck.sh /install/

RUN /install/install.2130.sh "${BUILD_MODE}"

Expand Down
46 changes: 46 additions & 0 deletions createAppUser
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
#
# Since: April, 2022
# Author: gvenzl
# Name: createAppUser
# Description: Creates the user in the XEPDB1 database
#
# Copyright 2022 Gerald Venzl
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Exit on errors
# Great explanation on https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -Eeuo pipefail

APP_USER="${1}"
APP_USER_PASSWORD="${2}"

ORACLE_VERSION=$(sqlplus -version | grep "Release" | awk '{ print $3 }')

# Check whether the user needs to be in a PDB or not
ALTER_SESSION_CMD="ALTER SESSION SET CONTAINER=XEPDB1;"
if [[ "${ORACLE_VERSION}" = "11.2"* ]]; then
ALTER_SESSION_CMD="";
fi;

sqlplus -s / as sysdba << EOF
-- Exit on any errors
WHENEVER SQLERROR EXIT SQL.SQLCODE

${ALTER_SESSION_CMD}

CREATE USER ${APP_USER} IDENTIFIED BY "${APP_USER_PASSWORD}" QUOTA UNLIMITED ON USERS;
GRANT CONNECT, RESOURCE, CREATE VIEW, CREATE MATERIALIZED VIEW, CREATE SYNONYM TO ${APP_USER};
exit;
EOF
7 changes: 5 additions & 2 deletions install.11202.sh
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,15 @@ echo "BUILDER: install operational files"
# Move operational files to ${ORACLE_BASE}
mv /install/*.sh "${ORACLE_BASE}"/
mv /install/resetPassword "${ORACLE_BASE}"/
mv /install/createAppUser "${ORACLE_BASE}"/

chown oracle:dba "${ORACLE_BASE}"/*.sh \
"${ORACLE_BASE}"/resetPassword
"${ORACLE_BASE}"/resetPassword \
"${ORACLE_BASE}"/createAppUser

chmod u+x "${ORACLE_BASE}"/*.sh \
"${ORACLE_BASE}"/resetPassword
"${ORACLE_BASE}"/resetPassword \
"${ORACLE_BASE}"/createAppUser

#########################
####### Cleanup #########
Expand Down
7 changes: 5 additions & 2 deletions install.1840.sh
Original file line number Diff line number Diff line change
Expand Up @@ -872,12 +872,15 @@ echo "BUILDER: install operational files"
# Move operational files to ${ORACLE_BASE}
mv /install/*.sh "${ORACLE_BASE}"/
mv /install/resetPassword "${ORACLE_BASE}"/
mv /install/createAppUser "${ORACLE_BASE}"/

chown oracle:dba "${ORACLE_BASE}"/*.sh \
"${ORACLE_BASE}"/resetPassword
"${ORACLE_BASE}"/resetPassword \
"${ORACLE_BASE}"/createAppUser

chmod u+x "${ORACLE_BASE}"/*.sh \
"${ORACLE_BASE}"/resetPassword
"${ORACLE_BASE}"/resetPassword \
"${ORACLE_BASE}"/createAppUser

# TODO: relink Oracle binaries
# Multimedia: ord/im/lib/env_ordim.mk
Expand Down
7 changes: 5 additions & 2 deletions install.2130.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1887,12 +1887,15 @@ echo "BUILDER: install operational files"
# Move operational files to ${ORACLE_BASE}
mv /install/*.sh "${ORACLE_BASE}"/
mv /install/resetPassword "${ORACLE_BASE}"/
mv /install/createAppUser "${ORACLE_BASE}"/

chown oracle:dba "${ORACLE_BASE}"/*.sh \
"${ORACLE_BASE}"/resetPassword
"${ORACLE_BASE}"/resetPassword \
"${ORACLE_BASE}"/createAppUser

chmod u+x "${ORACLE_BASE}"/*.sh \
"${ORACLE_BASE}"/resetPassword
"${ORACLE_BASE}"/resetPassword \
"${ORACLE_BASE}"/createAppUser

#########################
####### Cleanup #########
Expand Down