From e5f63fbb1bf9ca0cb8efaf5f7dd0d3aaf4cb2b98 Mon Sep 17 00:00:00 2001 From: Stefan Oehrli Date: Thu, 12 Jul 2018 05:06:47 +0200 Subject: [PATCH] Initial release of OUD on docker for oracle/docker-images (#911) * initial release of OUD on docker for oracle/docker-images Signed-off-by: Stefan Oehrli --- OracleUnifiedDirectory/LICENSE | 27 ++ OracleUnifiedDirectory/README.md | 274 ++++++++++++++++++ .../dockerfiles/12.2.1.3/Dockerfile | 136 +++++++++ .../dockerfiles/12.2.1.3/install.rsp | 6 + .../dockerfiles/12.2.1.3/oraInst.loc | 2 + .../p26270957_122130_Generic.zip.download | 10 + .../12.2.1.3/scripts/check_oud_instance.sh | 93 ++++++ .../12.2.1.3/scripts/config_oud_instance.sh | 92 ++++++ .../12.2.1.3/scripts/create_oud_instance.sh | 226 +++++++++++++++ .../dockerfiles/12.2.1.3/scripts/setup_oud.sh | 121 ++++++++ .../12.2.1.3/scripts/setup_oudbase.sh | 45 +++ .../12.2.1.3/scripts/start_oud_instance.sh | 133 +++++++++ .../dockerfiles/buildDockerImage.sh | 3 + 13 files changed, 1168 insertions(+) create mode 100644 OracleUnifiedDirectory/LICENSE create mode 100644 OracleUnifiedDirectory/README.md create mode 100644 OracleUnifiedDirectory/dockerfiles/12.2.1.3/Dockerfile create mode 100644 OracleUnifiedDirectory/dockerfiles/12.2.1.3/install.rsp create mode 100644 OracleUnifiedDirectory/dockerfiles/12.2.1.3/oraInst.loc create mode 100644 OracleUnifiedDirectory/dockerfiles/12.2.1.3/p26270957_122130_Generic.zip.download create mode 100755 OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/check_oud_instance.sh create mode 100755 OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/config_oud_instance.sh create mode 100755 OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/create_oud_instance.sh create mode 100755 OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/setup_oud.sh create mode 100755 OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/setup_oudbase.sh create mode 100755 OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/start_oud_instance.sh create mode 100755 OracleUnifiedDirectory/dockerfiles/buildDockerImage.sh diff --git a/OracleUnifiedDirectory/LICENSE b/OracleUnifiedDirectory/LICENSE new file mode 100644 index 0000000000..9ab72014a7 --- /dev/null +++ b/OracleUnifiedDirectory/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + +The Universal Permissive License (UPL), Version 1.0 + +Subject to the condition set forth below, permission is hereby granted to any person obtaining a copy of this +software, associated documentation and/or data (collectively the "Software"), free of charge and under any and +all copyright rights in the Software, and any and all patent rights owned or freely licensable by each licensor +hereunder covering either (i) the unmodified Software as contributed to or provided by such licensor, or +(ii) the Larger Works (as defined below), to deal in both + +(a) the Software, and +(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if one is included with the Software +(each a “Larger Work” to which the Software is contributed by such licensors), + +without restriction, including without limitation the rights to copy, create derivative works of, display, +perform, and distribute the Software and make, use, sell, offer for sale, import, export, have made, and have +sold the Software and the Larger Work(s), and to sublicense the foregoing rights on either these or other terms. + +This license is subject to the following condition: +The above copyright notice and either this complete permission notice or at a minimum a reference to the UPL must +be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/OracleUnifiedDirectory/README.md b/OracleUnifiedDirectory/README.md new file mode 100644 index 0000000000..f9373ff7fd --- /dev/null +++ b/OracleUnifiedDirectory/README.md @@ -0,0 +1,274 @@ +# Oracle Unified Directory on Docker +Docker build files to facilitate installation, configuration, and environment setup for Docker DevOps users. For more information about Oracle Unified Directory please see the [Oracle Unified Directory 12.2.1.3.0 Online Documentation](https://docs.oracle.com/middleware/12213/oud/). + +Just to clarify these Docker build scripts are **unofficial Oracle Build scripts**. + +### Docker Images Content +The resulting Docker images are based on the official Oracle Java image for Java 8 u172 (_oracle/serverjre:8_). It has either be build manually using the [official](https://github.com/oracle/docker-images/tree/master/OracleJava) or [my unofficial](https://github.com/oehrlis/docker/tree/master/OracleJava) Oracle Docker build scripts or pulled from [Docker Store](https://store.docker.com/images/oracle-serverjre-8). See [Building the Oracle JDK base image](#building-the-oracle-jdk-base-image) + +They base image will be extended to provide some additional Linux packages and configuration: +* Install the following additional packages including there dependencies: + * *libaio* Linux-native asynchronous I/O access library + * *tar* A GNU file archiving program + * *gzip* The GNU data compression program +* Operating system user *oracle* (uid 1000) +* Dedicated groups for user *oracle*, oracle (gid 1000), oinstall (gid 1010) +* [OUD Base](https://github.com/oehrlis/oudbase) environment developed by [ORAdba](www.oradba.ch) +* Oracle OFA Directories see below +* Install Oracle Unified Directory 12c 12.2.1.3.0 (standalone) or Oracle Unified Directory 11g 11.1.2.3.0 + +### Environment Variable and Directories +Based on the idea of OFA (Oracle Flexible Architecture) we try to separate the data from the binaries. This means that the OUD instance as well as configuration files are explicitly stored in a separate directory. Ideally, a volume is assigned to this directory when a container is created. This ensures data persistence over the lifetime of a container. OUD Base supports the setup and operation of the environment based on OFA. See also [OraDBA](http://www.oradba.ch/category/oudbase/). + +The following environment variables have been used for the installation. In particular it is possible to modify the variables ORACLE_ROOT, ORACLE_DATA and ORACLE_BASE via *build-arg* during image build to have a different directory structure. All other parameters are only relevant for the creation of the container. They may be modify via ```docker run``` environment variables. + +Environment variable | Value / Directories | Modifiable | Comment +-------------------- | -------------------------------------- | -------------| --------------- +ORACLE_ROOT | ```/u00``` | docker build | Root directory for all the Oracle software +ORACLE_BASE | ```$ORACLE_ROOT/app/oracle``` | docker build | Oracle base directory +n/a | ```$ORACLE_BASE/product``` | no | Oracle product base directory +ORACLE_HOME_NAME | ```fmw12.2.1.3.0``` | no | Name of the Oracle Home, used to create to PATH to ORACLE_HOME eg. *$ORACLE_BASE/product/$ORACLE_HOME_NAME* +ORACLE_DATA | ```/u01``` | docker build | Root directory for the persistent data eg. OUD instances, etc. A docker volumes must be defined for */u01* +INSTANCE_BASE | ```$ORACLE_DATA/instances``` | no | Base directory for OUD instances +OUD_INSTANCE | ```oud_docker``` | docker run | Default name for OUD instance +OUD_INSTANCE_HOME | ```$INSTANCE_BASE/$OUD_INSTANCE``` | docker run | +OUD_INSTANCE_ADMIN | ```$ORACLE_DATA/admin/$OUD_INSTANCE``` | no | Instance admin directory for custom scripts, config and logs +CREATE_INSTANCE | ```TRUE``` | docker run | Flag to create OUD instance on first start of the container +OUD_PROXY | ```FALSE``` | docker run | Flag to create proxy instance. Not yet implemented. +OUD_INSTANCE_INIT | ```$ORACLE_DATA/scripts``` | docker run | Directory for the instance configuration scripts +PORT | ```1389``` | docker run | Default LDAP port for the OUD instance +PORT_SSL | ```1636``` | docker run | Default LDAPS port for the OUD instance +PORT_REP | ```8989``` | docker run | Default replication port for the OUD instance +PORT_ADMIN | ```4444``` | docker run | Default admin port for the OUD instance (4444) +ADMIN_USER | ```cn=Directory Manager``` | docker run | Default admin user for OUD instance +ADMIN_PASSWORD | n/a | docker run | No default password. Password will be autogenerated when not defined. +BASEDN | ```dc=example,dc=com``` | docker run | Default directory base DN +SAMPLE_DATA | ```TRUE``` | docker run | Flag to load sample data. Not yet implemented. +ETC_BASE | ```$ORACLE_DATA/etc``` | no | Oracle etc directory with configuration files +LOG_BASE | ```$ORACLE_DATA/log``` | no | Oracle log directory with log files +DOWNLOAD | ```/tmp/download``` | no | Temporary download directory, will be removed after build +DOCKER_BIN | ```/opt/docker/bin``` | no | Docker build and setup scripts +JAVA_DIR | ```/usr/java``` | no | Base directory for java home location +JAVA_HOME | ```$JAVA_DIR/jdk1.8.0_162``` | no | Java home directory when build manually. The official docker image may have an other minor release. + +In general it does not make sense to change all possible variables. Although *BASEDN* and *ADMIN_PASSWORD* are good candidates for customization. all other variables can generally easily be ignored. + +### Scripts to Build and Setup +The following scripts are used either during Docker image build or while setting up and starting the container. + +| Script | Purpose +| ---------------------------- | ---------------------------------------------------------------------------- +| ```check_oud_instance.sh``` | Check the status of the OUD instance for Docker HEALTHCHECK +| ```config_oud_instance.sh``` | Configure OUD instance using custom scripts +| ```create_oud_instance.sh``` | Script to create the OUD instance +| ```start_oud_instance.sh``` | Script to start the OUD instance +| ```setup_oud.sh``` | Script to install OUD binaries and patch +| ```setup_oudbase.sh``` | Script to install OUD base + +## Installation and Build +The required software has to be downloaded prior image build and must be part of the build context or made available in a local HTTP server. See [Build with local HTTP server](#build-with-local-http-server) below. Providing a local HTTP server to download the required software during image build will lead into smaller images, since the software will not be part of an intermediate intermediate container. The docker build parameter _--squash_ is not required. The procedure was briefly described in the blog post [Smaller Oracle Docker images](http://www.oradba.ch/2018/03/smaller-oracle-docker-images/). + +### Obtaining Product Distributions +The Oracle Software required to setup an Oracle Unified Directory Docker image is basically not public available. It is subject to Oracle's license terms. For this reason a valid license is required (eg. [OTN Developer License Terms](http://www.oracle.com/technetwork/licenses/standard-license-152015.html)). In addition, Oracle's license terms and conditions must be accepted before downloading. + +The following software is required for the Oracle Unified Directory Docker image: +* Oracle Unified Directory 12.2.1.3.0 + +The software can either be downloaded from [My Oracle Support (MOS)](https://support.oracle.com), [Oracle Technology Network (OTN)](http://www.oracle.com/technetwork/index.html) or [Oracle Software Delivery Cloud (OSDC)](http://edelivery.oracle.com). The following links refer to the MOS software download to simplify the build process. + +The corresponding links and checksum can be found in `*.download` files. Alternatively the Oracle Support Download Links: +* Oracle Unified Directory 12.2.1.3.0 [Patch 26270957](https://updates.oracle.com/ARULink/PatchDetails/process_form?patch_num=26270957) or [direct](https://updates.oracle.com/Orion/Services/download/p26270957_122130_Generic.zip?aru=21504981&patch_file=p26270957_122130_Generic.zip) + +### Building-the-Oracle-JDK-base-image +You must first download the Oracle Server JRE binary, locate it in the folder, `../OracleJava/java-8`, and build that image. For more information, see the [`OracleJava`](../OracleJava) folder's [README](../OracleJava/README.md) file. + + $ cd ../OracleJava/java-8 + $ sh build.sh + +You can also pull the Oracle Server JRE 8 image from the [Oracle Container Registry](https://container-registry.oracle.com) or the [Docker Store](https://store.docker.com/images/oracle-serverjre-8). When pulling the Server JRE 8 image, re-tag the image so that it works with the existing Dockerfiles. + + $ docker tag container-registry.oracle.com/java/serverjre:8 oracle/serverjre:8 + $ docker tag store/oracle/serverjre:8 oracle/serverjre:8 + +### Build using COPY +Simplest method to build the OUD image is to manually download the required software and put it into the build folder respectively context. However this will lead to bigger Docker images, since the software is copied during build, which temporary blow up the container file-system. + +Copy all files to the `OracleUnifiedDirectory/12.2.1.3` folder. + +``` +cp p26270957_122130_Generic.zip OracleUnifiedDirectory/12.2.1.3 +``` + +Build the docker image using `docker build`. + +``` +cd OracleUnifiedDirectory/dockerfiles/12.2.1.3 +docker build -t oracle/oud:12.2.1.3 . +``` + +### Build with local HTTP server +Alternatively the software can also be downloaded from a local HTTP server during build. For this a Docker image for an HTTP server is required eg. official Apache HTTP server Docker image based on alpine. See also [Smaller Oracle Docker images](http://www.oradba.ch/2018/03/smaller-oracle-docker-images/). + +Start a local HTTP server. httpd:alpine will be pulled from Docker Hub: + +``` +docker pull httpd:alpine +docker run -dit --hostname orarepo --name orarepo \ + -p 8080:80 \ + -v /Volumes/orarepo:/usr/local/apache2/htdocs/ \ + httpd:alpine +``` +Make sure, that the software is know copied to the volume folder not part of the build context any more: + +``` +cd OracleUnifiedDirectory/dockerfiles/12.2.1.3 +cp p26270957_122130_Generic.zip /Volumes/orarepo +rm p26270957_122130_Generic.zip +``` + +Get the IP address of the local HTTP server: + +``` +orarepo_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' orarepo) +``` +Build the docker image using `docker build` and provide the HTTP server. + +``` +cd OracleUnifiedDirectory/dockerfiles/12.2.1.3 +docker build --add-host=orarepo:${orarepo_ip} -t oracle/oud:12.2.1.3.0 . +``` + +The _RUN_ command in the Dockerfile will check if the software is part of the build context. If not, it will use the host _orarepo_ to download the software. This way the OUD Docker image will be about 400MB smaller. + +## Running the Docker Images +### Setup an Oracle Unified Directory Container +Creating a OUD container is straight forward with **docker run** command. The script `start_oud_instance.sh` will make sure, that a new OUD instance is created, when the container is started the first time. The instance is created using predefined values. (see below). If an OUD instance already exists, the script simply starts it. + +The creation of the OUD instance can be influenced by the following environment variables. You only have to set them with option -e when executing "docker run". + +* **ADMIN_PASSWORD** OUD admin password (default *autogenerated*) +* **ADMIN_USER** OUD admin user name (default *cn=Directory Manager*) +* **BASEDN** Directory base DN (default *dc=example,dc=com*) +* **CREATE_DOMAIN** Flag to create OUDS instance on first startup (default *TRUE*) +* **PORT** Regular LDAP port (default *1389*). Will also require to update the Dockerfile to expose a different port. +* **PORT_SSL** SSL LDAP port (default *1636*). Will also require to update the Dockerfile to expose a different port. +* **PORT_ADMIN** OUD admin port (default *4444*). Will also require to update the Dockerfile to expose a different port. +* **PORT_REP** OUD replication port (default *8989*). Will also require to update the Dockerfile to expose a different port. +* **OUD_INSTANCE** OUD instance name (default *oud_docker*) +* **OUD_INSTANCE_HOME** OUD home path (default */u01/instances/oud_docker*) +* **OUD_INSTANCE_INIT** default folder for OUD instance init scripts. These scripts are used to modify and adjust the new OUD instance. +* **OUD_PROXY** Flag to create proxy instance (default *FALSE*) Not yet implemented. +* **SAMPLE_DATA** Flag to load sample data (default *TRUE*) Not yet implemented. + +Run your Oracle Unified Directory Docker image use the **docker run** command as follows: + +``` +docker run --name \ +--hostname \ +-p 1389:1389 -p 1636:1636 -p 4444:4444 \ +-e OUD_INSTANCE= \ +--volume [:]/u01 \ +--volume [:]/u01/scripts \ +oracle/oud:12.2.1.3.0 + +Parameters: +--name: The name of the container (default: auto generated) +-p: The port mapping of the host port to the container port. + for ports are exposed: 1389 (LDAP), 1636 (LDAPS), 4444 (Admin Port), 8989 (Replication Port) +-e OUD_INSTANCE: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated) +-e Other environment variable according "Environment Variable and Directories" +-v /u01 + The data volume to use for the OUD instance. + Has to be writable by the Unix "oracle" (uid: 1000) user inside the container! + If omitted the OUD instance will not be persisted over container recreation. +-v /u01/app/oracle/scripts | /docker-entrypoint-initdb.d + Optional: A volume with custom scripts to be run after OUD instance setup. + For further details see the "Running scripts after setup" section below. +``` + +There are four ports that are exposed in this image: +* 1389 which is the regular LDAP port to connect to the OUD instance. +* 1636 which is the SSL LDAP port to connect to the OUD instance. +* 4444 which is the admin port to connect and configure the OUD instance using dsconfig. +* 8989 which is the replication port of the OUD instance. + +On the first startup of the container a random password will be generated for the OUD instance if not provided. You can find this password in the output line. If you need to find the passwords at a later time, grep for "password" in the Docker logs generated during the startup of the container. To look at the Docker Container logs run: + +``` +docker logs --details oud|grep -i password +``` + +Alternatively you can check the OUD Base environment for the instance ($OUD_INSTANCE) and look for the password file. It is located under _$PWD_FILE_ respectively _${OUD_INSTANCE_ADMIN}/etc/${OUD_INSTANCE}_pwd.txt_. + +``` +cat $PWD_FILE + +cat ${OUD_INSTANCE_ADMIN}/etc/${OUD_INSTANCE}_pwd.txt +``` + +Create a simple OUD container with an example instance. Define the ports to expose and a local volume `/Data/vm/docker/volumes/oudtest`. + +``` +docker run --detach --name oudtest \ +--hostname oudtest \ +-p 1389:1389 -p 1636:1636 -p 4444:4444 \ +--volume /Data/vm/docker/volumes/oudtest:/u01 \ +oracle/oud:12.2.1.3 +``` + +Check progress of initial startup and customization. + +``` +docker logs -f oudtest +``` + +Login using bash to access OUD instance localy via commandline. + +``` +user@host:/Data/ [ic12201] docker exec -it oudtest bash --login +Source environment for OUD Instance oud_docker +-------------------------------------------------------------- + Instance Name : oud_docker + Instance Home (ok) : /u01/instances/oud_docker + Oracle Home : /u00/app/oracle/product/fmw12.2.1.3.0 + Instance Status : up + LDAP Port : 1389 + LDAPS Port : 1636 + Admin Port : 4444 + Replication Port : 8989 +-------------------------------------------------------------- +oracle@oudtest:/u00/app/oracle/ [oud_docker] +``` + +#### Running Bash in a Docker container +Access your OUD container via bash. + +``` +docker exec -u oracle -it oud bash --login +``` + +#### Running dsconfig in a Docker container +Execute `dsconfig` within the OUD container. + +``` +docker exec -u oracle -it oud dsconfig +``` +#### Running scripts after setup +The OUD Docker image can be configured to run scripts after setup. Currently `sh`, `ldif` and `conf` extensions are supported. For post-setup scripts just create a folder `scripts/setup` in generic volume `/u01`, mount a dedicated volume `/u01/scripts/setup` or extend the image to include scripts in this directory. The location is also represented under the symbolic link `/docker-entrypoint-initdb.d`. This is done to provide synergy with other Docker images. The user is free to decide whether he wants to put his setup scripts under `/u01/scripts/setup` or `/docker-entrypoint-initdb.d`. Alternatively it is also possible to specify the scripts in the create folder of the instance admin directory `/u01/admin/$OUD_INSTANCE/create`. + +After the OUD instance is created by `create_oud_instance.sh` the scripts in those folders will be executed against the instance in the container. LDIF files (`ldif`) will be loaded using `ldapmodify` as *cn=Directory Manager* (ADMIN_USER). CONF files ( `conf` ) are interpreted as `dsconfig` batch files and will be executed accordingly. Shell scripts will be executed as the current user (oracle). To ensure proper order it is recommended to prefix your scripts with a number. For example `01_instance.conf`, `02_schema_extention.ldif`, etc. If files with the same name do exits eg. `02_schema_extention.ldif` and `02_schema_extention.sh` just the .sh file will be executed. + +* **Note:** The config scripts will only be executed when an instance is created on first startup or when using `create_oud_instance.sh`. +* **Note:** If files with the same name do exits eg. `02_schema_extention.ldif` and `02_schema_extention.sh` just the .sh file will be executed. +* **Note:** If `/u01/admin/$OUD_INSTANCE/create` folder exists, it is used instead of `/u01/scripts/setup`. + +## Frequently asked questions +Please see [FAQ.md](./FAQ.md) for frequently asked questions. + +## License +To download and run Oracle Unified Directory, regardless whether inside or outside a Docker container, you must download the binaries from the Oracle website and accept the license indicated at that page. + +All scripts and files hosted in this project and GitHub [docker-images/OracleUnifiedDirectory](./) repository required to build the Docker images are, unless otherwise noted, released under [UPL 1.0](https://oss.oracle.com/licenses/upl/) license. + +## Copyright +Copyright (c) 2014-2017 Oracle and/or its affiliates. All rights reserved. \ No newline at end of file diff --git a/OracleUnifiedDirectory/dockerfiles/12.2.1.3/Dockerfile b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/Dockerfile new file mode 100644 index 0000000000..444ae4e42e --- /dev/null +++ b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/Dockerfile @@ -0,0 +1,136 @@ +# ---------------------------------------------------------------------- +# Trivadis AG, Infrastructure Managed Services +# Saegereistrasse 29, 8152 Glattbrugg, Switzerland +# ---------------------------------------------------------------------- +# Name.......: Dockerfile +# Author.....: Stefan Oehrli (oes) stefan.oehrli@trivadis.com +# Editor.....: Stefan Oehrli +# Date.......: 2018.03.19 +# Revision...: 1.0 +# Purpose....: This Dockerfile is to build Oracle Unifid Directory +# Notes......: -- +# Reference..: -- +# License....: Licensed under the Universal Permissive License v 1.0 as +# shown at http://oss.oracle.com/licenses/upl. +# ---------------------------------------------------------------------- +# Modified...: +# see git revision history for more information on changes/updates +# ---------------------------------------------------------------------- + +# Pull base image +# ---------------------------------------------------------------------- +FROM oracle/serverjre:8 + +# Maintainer +# ---------------------------------------------------------------------- +LABEL maintainer="stefan.oehrli@trivadis.com" + +# Arguments for Oracle Installation +ARG ORACLE_ROOT +ARG ORACLE_DATA +ARG ORACLE_BASE +ARG ORAREPO + +# Environment variables required for this build (do NOT change) +# ------------------------------------------------------------- +ENV ORAREPO=${ORAREPO:-orarepo} \ + DOWNLOAD="/tmp/download" \ + DOCKER_SCRIPTS="/opt/docker/bin" \ + START_SCRIPT="start_oud_instance.sh" \ + CHECK_SCRIPT="check_oud_instance.sh" \ + INSTALL_SCRIPT="setup_oud.sh" \ + USER_MEM_ARGS="-Djava.security.egd=file:/dev/./urandom" \ + ORACLE_HOME_NAME="fmw12.2.1.3.0" \ + ORACLE_ROOT=${ORACLE_ROOT:-/u00} \ + ORACLE_DATA=${ORACLE_DATA:-/u01} \ + OUD_INSTANCE=${OUD_INSTANCE:-oud_docker} \ + PORT="${PORT:-1389}" \ + PORT_SSL="${PORT_SSL:-1636}" \ + PORT_HTTP="${PORT_HTTP:-8080}" \ + PORT_HTTPS="${PORT_HTTPS:-10443}" \ + PORT_REP="${PORT_REP:-8989}" \ + PORT_ADMIN="${PORT_ADMIN:-4444}" \ + PORT_ADMIN_HTTP="${PORT_ADMIN_HTTP:-8444}" \ + FMW_OUD_PKG="p26270957_122130_Generic.zip" + +# Use second ENV so that variable get substituted +ENV ORACLE_BASE=${ORACLE_BASE:-$ORACLE_ROOT/app/oracle} \ + OUD_INSTANCE_BASE=${OUD_INSTANCE_BASE:-$ORACLE_DATA/instances} + +# same same but different... +# third ENV so that variable get substituted +ENV PATH=${PATH}:"${OUD_INSTANCE_HOME}/OUD/bin:${ORACLE_BASE}/product/${ORACLE_HOME_NAME}/oud/bin:${DOCKER_SCRIPTS}" \ + ORACLE_HOME=${ORACLE_BASE}/product/${ORACLE_HOME_NAME} + +# RUN as user root +# ---------------------------------------------------------------------- +# - create group oracle and oinstall +# - create user oracle +# - setup subdirectory to install OUDpackage and container-scripts +# - create softlink for the OUD setup scripts +# - adjust owner ship of download folder +# - relax java.security and allow 3DES_EDE_CBC see MOS Note 2397791.1 +# ----------------------------------------------------------------- +RUN groupadd --gid 1000 oracle && \ + groupadd --gid 1010 oinstall && \ + useradd --create-home --gid oracle --groups oracle,oinstall \ + --shell /bin/bash oracle && \ + install --owner oracle --group oracle --mode=775 --verbose --directory \ + ${ORACLE_ROOT} \ + ${ORACLE_BASE} \ + ${ORACLE_DATA} \ + ${DOWNLOAD} \ + ${DOCKER_SCRIPTS} && \ + ln -s ${ORACLE_DATA}/scripts /docker-entrypoint-initdb.d && \ + chown oracle:oinstall ${DOWNLOAD} && \ + sed -i 's/, 3DES_EDE_CBC//' $(find /usr/java -name java.security) + +# Fallback if the base image does not provide libaio, tar and gzip +# This yum command will only be executed, if one of the file is not +# available. Otherwise it will just create the *.lang file and remove the +# yum cache which is anyway not there. +# ----------------------------------------------------------------- +RUN echo "%_install_langs en" >/etc/rpm/macros.lang && \ + [ -f /usr/bin/tar -a -f /usr/bin/gzip -a -f /lib64/libaio.so.? ] || \ + yum install -y libaio gzip tar && \ + rm -rf /var/cache/yum + +# Copy scripts and software +# ---------------------------------------------------------------------- +# copy all setup scripts to DOCKER_BIN +COPY scripts/* "${DOCKER_SCRIPTS}/" + +# COPY oud/software and response files +COPY *zip* install.rsp oraInst.loc "${DOWNLOAD}/" + +# RUN as oracle +# Switch to user oracle, oracle software as to be installed with regular user +# ---------------------------------------------------------------------- +USER oracle +RUN "${DOCKER_SCRIPTS}/${INSTALL_SCRIPT}" ${FMW_OUD_PKG} + +# get the latest OUD base from GitHub and install it +RUN "${DOCKER_SCRIPTS}/setup_oudbase.sh" + +# Finalize image +# ---------------------------------------------------------------------- +# expose the OUD ports for ldap, ldaps, http, https, replication, +# administration and http administration +EXPOSE ${PORT} ${PORT_SSL} \ + ${PORT_HTTP} ${PORT_HTTPS} \ + ${PORT_REP} \ + ${PORT_ADMIN} ${PORT_ADMIN_HTTP} + +# run container health check +HEALTHCHECK --interval=1m --start-period=5m \ + CMD "${DOCKER_SCRIPTS}/${CHECK_SCRIPT}" >/dev/null || exit 1 + +# Oracle data volume for OUD instance and configuration files +VOLUME ["${ORACLE_DATA}"] + +# set workding directory +WORKDIR "${ORACLE_BASE}" + +# Define default command to start OUD instance +CMD exec "${DOCKER_SCRIPTS}/${START_SCRIPT}" +# --- EOF -------------------------------------------------------------- diff --git a/OracleUnifiedDirectory/dockerfiles/12.2.1.3/install.rsp b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/install.rsp new file mode 100644 index 0000000000..6363785a67 --- /dev/null +++ b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/install.rsp @@ -0,0 +1,6 @@ +[ENGINE] +Response File Version=1.0.0.0.0 +[GENERIC] +DECLINE_SECURITY_UPDATES=true +SECURITY_UPDATES_VIA_MYORACLESUPPORT=false +INSTALL_TYPE="Standalone Oracle Unified Directory Server (Managed independently of WebLogic server)" diff --git a/OracleUnifiedDirectory/dockerfiles/12.2.1.3/oraInst.loc b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/oraInst.loc new file mode 100644 index 0000000000..bcf6d04c00 --- /dev/null +++ b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/oraInst.loc @@ -0,0 +1,2 @@ +inventory_loc=/u00/app/oracle/oraInventory +inst_group=oinstall diff --git a/OracleUnifiedDirectory/dockerfiles/12.2.1.3/p26270957_122130_Generic.zip.download b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/p26270957_122130_Generic.zip.download new file mode 100644 index 0000000000..059b9d338d --- /dev/null +++ b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/p26270957_122130_Generic.zip.download @@ -0,0 +1,10 @@ +# Download Fusion Middleware 12.2.1.3.0 Oracle Unified Directory +# +# The following link is a My Oracle Support (http://support.oracle.com) wget download link. You +# require a valid MOS Account to download Oracle Software from MOS. +# Patch Download URL: https://updates.oracle.com/ARULink/PatchDetails/process_form?patch_num=26270957 +# Direct Download : https://updates.oracle.com/Orion/Services/download/p26270957_122130_Generic.zip?aru=21504981&patch_file=p26270957_122130_Generic.zip +# +# SHA-256 File +# -------------------------------------------------------------- --------------------------------- +e6c0b15f06220d9599a976e170f0a4bfc419dd7f64e6ea874618c4c48c89e9c1 p26270957_122130_Generic.zip diff --git a/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/check_oud_instance.sh b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/check_oud_instance.sh new file mode 100755 index 0000000000..170ee922ec --- /dev/null +++ b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/check_oud_instance.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# --------------------------------------------------------------------------- +# Trivadis AG, Infrastructure Managed Services +# Saegereistrasse 29, 8152 Glattbrugg, Switzerland +# --------------------------------------------------------------------------- +# Name.......: check_oud_Instance.sh +# Author.....: Stefan Oehrli (oes) stefan.oehrli@trivadis.com +# Editor.....: Stefan Oehrli +# Date.......: 2017.12.04 +# Revision...: +# Purpose....: check the status of the OUD instance for docker HEALTHCHECK +# Notes......: Script is a wrapper for oud_status.sh. It makes sure, that the +# status of the docker OUD instance is checked and the exit code +# of oud_status.sh is docker compliant (0 or 1). +# Reference..: -- +# License....: Licensed under the Universal Permissive License v 1.0 as +# shown at http://oss.oracle.com/licenses/upl. +# --------------------------------------------------------------------------- +# Modified...: +# see git revision history for more information on changes/updates +# --------------------------------------------------------------------------- + +# - Environment Variables --------------------------------------------------- +# - Set default values for environment variables if not yet defined. +# --------------------------------------------------------------------------- +# Default name for OUD instance +export OUD_INSTANCE=${OUD_INSTANCE:-oud_docker} + +# OUD instance base directory +export OUD_INSTANCE_BASE=${OUD_INSTANCE_BASE:-"$ORACLE_DATA/instances"} + +# Default values for the instance home and admin directory +export OUD_INSTANCE_HOME=${OUD_INSTANCE_HOME:-"${OUD_INSTANCE_BASE}/${OUD_INSTANCE}"} +export OUD_INSTANCE_ADMIN=${OUD_INSTANCE_ADMIN:-${ORACLE_DATA}/admin/${OUD_INSTANCE}} + +# Default value for the directory +export ADMIN_USER=${ADMIN_USER:-'cn=Directory Manager'} # Default directory admin user +export PWD_FILE=${PWD_FILE:-${OUD_INSTANCE_ADMIN}/etc/${OUD_INSTANCE}_pwd.txt} +export TMP_DIRECTORY="/tmp" +export TMP_FILE="${TMP_DIRECTORY}/$(basename $0).$$" +# - EOF Environment Variables ----------------------------------------------- + +# check if password file is available +if [ ! -e ${PWD_FILE} ]; then + echo "$0: Can not find password file ${PWD_FILE}" + exit 1 +fi + +# Run status on OUD Instance +${OUD_INSTANCE_HOME}/OUD/bin/status --script-friendly --no-prompt \ + --noPropertiesFile --bindDN "${ADMIN_USER}" --bindPasswordFile ${PWD_FILE} \ + --trustAll >${TMP_FILE} 2>&1 +OUD_ERROR=$? + +# handle errors from OUD status +if [ ${OUD_ERROR} -gt 0 ]; then + echo "$0: Error ${OUD_ERROR} running status command ${OUD_INSTANCE_HOME}/OUD/bin/status" + exit 1 +fi + + # adjust temp file +# and add a - at the end +sed -i 's/^$/-/' ${TMP_FILE} +# join Backend ID with multiple lines +sed -i '/OracleContext for$/{N;s/\n/ /;}' ${TMP_FILE} +# join Base DN with multiple lines +sed -i '/^Base DN:$/{N;s/\n/ /;}' ${TMP_FILE} + +# check Server Run Status +if [ $(grep -ic 'Server Run Status: Started' ${TMP_FILE}) -eq 0 ]; then + echo "$0: Error OUD Instance ${OUD_INSTANCE} not running" + exit 1 +fi + +# check if connection handler are enabled +for i in LDAP LDAPS; do + AWK_OUT=$(awk 'BEGIN{RS="\n-\n";FS="\n";IGNORECASE=1; Error=51} $1 ~ /^Address/ && $2 ~ /\<'${i}'\>/ {if ($3 ~ /\/) Error=0; } END{exit Error}' ${TMP_FILE} ) + OUD_ERROR=$? + if [ ${OUD_ERROR} -eq 51 ]; then + echo "$0: Connection Handler ${i} is not enabled on ${OUD_INSTANCE}" + exit 1 + fi +done + +if [ -e ${TMP_FILE} ]; then + rm ${TMP_FILE} 2>/dev/null + # remove oud status temp file due to an oracle Bug + rm /tmp/oud-status*.log 2>/dev/null +fi + +# if we came that far just exit with 0 +exit 0 +# --- EOF ------------------------------------------------------------------- \ No newline at end of file diff --git a/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/config_oud_instance.sh b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/config_oud_instance.sh new file mode 100755 index 0000000000..70b30f863d --- /dev/null +++ b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/config_oud_instance.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# --------------------------------------------------------------------------- +# Trivadis AG, Infrastructure Managed Services +# Saegereistrasse 29, 8152 Glattbrugg, Switzerland +# --------------------------------------------------------------------------- +# Name.......: config_oud_instance.sh +# Author.....: Stefan Oehrli (oes) stefan.oehrli@trivadis.com +# Editor.....: Stefan Oehrli +# Date.......: 2017.12.04 +# Revision...: +# Purpose....: Configure OUD instance using custom scripts +# Notes......: Script is a wrapper for custom setup script in SCRIPTS_ROOT +# All files in folder SCRIPTS_ROOT will be executet but not in +# any subfolder. Currently just *.sh, *.ldif and *.conf files +# are supported. +# sh : Shell scripts will be executed +# ldif : LDIF files will be loaded via ldapmodify +# conf : Config files will be loaded via dsconfig +# To ensure proper order it is recommended to prefix your scripts +# with a number. For example 01_instance.conf, +# 02_schemaextention.ldif, etc. +# Reference..: -- +# License....: Licensed under the Universal Permissive License v 1.0 as +# shown at http://oss.oracle.com/licenses/upl. +# --------------------------------------------------------------------------- +# Modified...: +# see git revision history for more information on changes/updates +# --------------------------------------------------------------------------- + +# Default name for OUD instance +export OUD_INSTANCE=${OUD_INSTANCE:-oud_docker} + +# Default values for the instance home and admin directory +export OUD_INSTANCE_ADMIN=${OUD_INSTANCE_ADMIN:-${ORACLE_DATA}/admin/${OUD_INSTANCE}} +export OUD_INSTANCE_HOME=${OUD_INSTANCE_HOME:-"${OUD_INSTANCE_BASE}/${OUD_INSTANCE}"} + +# Default values for host and ports +export HOST=$(hostname 2>/dev/null ||cat /etc/hostname ||echo $HOSTNAME) # Hostname +export PORT=${PORT:-1389} # Default LDAP port +export PORT_ADMIN=${PORT_ADMIN:-4444} # Default admin port + +# Default value for the directory +export ADMIN_USER=${ADMIN_USER:-'cn=Directory Manager'} # Default directory admin user +export PWD_FILE=${PWD_FILE:-${OUD_INSTANCE_ADMIN}/etc/${OUD_INSTANCE}_pwd.txt} + +# default folder for OUD instance init scripts +export OUD_INSTANCE_INIT=${OUD_INSTANCE_INIT:-$ORACLE_DATA/scripts} +# - EOF Environment Variables ----------------------------------------------- + +# use parameter 1 as script root +SCRIPTS_ROOT="$1"; + +# Check whether parameter has been passed on +if [ -z "${SCRIPTS_ROOT}" ]; then + echo "$0: No SCRIPTS_ROOT passed on, no scripts will be run"; + exit 1; +fi + +# Execute custom provided files (only if directory exists and has files in it) +if [ -d "${SCRIPTS_ROOT}" ] && [ -n "$(ls -A ${SCRIPTS_ROOT})" ]; then + echo ""; + echo "--- Executing user defined scripts -------------------------------------" + +# Loop over the files in the current directory + for f in $(find ${SCRIPTS_ROOT} -maxdepth 1 -type f|sort); do + # Skip ldif and conf file if a bash script with same name exists + if [ -f "$(dirname $f)/$(basename $f .ldif).sh" ]; then + echo "INFO: skip file $f, bash script with same name exists." + continue + elif [ -f "$(dirname $f)/$(basename $f .conf).sh" ]; then + echo "INFO: skip file $f, bash script with same name exists." + continue + elif [ -f "$(dirname $f)/$(basename $f .sh).sh" ]; then + echo "INFO: bash script $f." + else + echo "INFO: no bash script for file $f." + fi + echo "--- --------------------------------------------------------------------" + case "$f" in + *.sh) echo "INFO: running $f"; "$f" ;; + *.ldif) echo "INFO: running $f"; echo "exit" | ${OUD_INSTANCE_HOME}/OUD/bin/ldapmodify --defaultAdd --hostname ${HOST} --port ${PORT} --bindDN "${ADMIN_USER}" --bindPasswordFile ${PWD_FILE} --filename "$f"; echo ;; + *.conf) echo "INFO: running $f"; echo "exit" | ${OUD_INSTANCE_HOME}/OUD/bin/dsconfig --hostname ${HOST} --port ${PORT_ADMIN} --bindDN "${ADMIN_USER}" --bindPasswordFile ${PWD_FILE} --trustAll --no-prompt -F "$f"; echo ;; + *) echo "INFO: skip file $f" ;; + esac + echo ""; + done + echo "--- Successfully executed user defined ---------------------------------" + echo "" +else + echo "--- no user defined scripts to execute ---------------------------------" +fi +# --- EOF ------------------------------------------------------------------- \ No newline at end of file diff --git a/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/create_oud_instance.sh b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/create_oud_instance.sh new file mode 100755 index 0000000000..20d2a8fa44 --- /dev/null +++ b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/create_oud_instance.sh @@ -0,0 +1,226 @@ +#!/bin/bash +# --------------------------------------------------------------------------- +# Trivadis AG, Infrastructure Managed Services +# Saegereistrasse 29, 8152 Glattbrugg, Switzerland +# --------------------------------------------------------------------------- +# Name.......: create_oud_instance.sh +# Author.....: Stefan Oehrli (oes) stefan.oehrli@trivadis.com +# Editor.....: Stefan Oehrli +# Date.......: 2017.12.04 +# Revision...: +# Purpose....: Helper script to create the OUD instance +# Notes......: Script to create an OUD instance. If configuration files are +# provided, the will be used to configure the instance. +# Reference..: -- +# License....: Licensed under the Universal Permissive License v 1.0 as +# shown at http://oss.oracle.com/licenses/upl. +# --------------------------------------------------------------------------- +# Modified...: +# see git revision history for more information on changes/updates +# --------------------------------------------------------------------------- + +# - Environment Variables --------------------------------------------------- +# - Set default values for environment variables if not yet defined. +# --------------------------------------------------------------------------- + +# Default name for OUD instance +export OUD_INSTANCE=${OUD_INSTANCE:-oud_docker} + +# Default values for the instance home and admin directory +export OUD_INSTANCE_ADMIN=${OUD_INSTANCE_ADMIN:-${ORACLE_DATA}/admin/${OUD_INSTANCE}} +export OUD_INSTANCE_BASE=${OUD_INSTANCE_BASE:-"$ORACLE_DATA/instances"} +export OUD_INSTANCE_HOME=${OUD_INSTANCE_HOME:-"${OUD_INSTANCE_BASE}/${OUD_INSTANCE}"} + +# Default values for host and ports +export HOST=$(hostname 2>/dev/null ||cat /etc/hostname ||echo $HOSTNAME) # Hostname +export PORT=${PORT:-1389} # Default LDAP port +export PORT_SSL=${PORT_SSL:-1636} # Default LDAPS port +export PORT_HTTP=${PORT_HTTP:-8080} # Default LDAPS port +export PORT_HTTPS=${PORT_HTTPS:-10443} # Default LDAPS port +export PORT_REP=${PORT_REP:-8989} # Default replication port +export PORT_ADMIN=${PORT_ADMIN:-4444} # Default admin port +export PORT_ADMIN_HTTP=${PORT_ADMIN_HTTP:-8444} # Default admin port + +# Default value for the directory +export ADMIN_USER=${ADMIN_USER:-'cn=Directory Manager'} # Default directory admin user +export ADMIN_PASSWORD=${ADMIN_PASSWORD:-""} # Default directory admin password +export PWD_FILE=${PWD_FILE:-${OUD_INSTANCE_ADMIN}/etc/${OUD_INSTANCE}_pwd.txt} +export BASEDN=${BASEDN:-'dc=example,dc=com'} # Default directory base DN +export SAMPLE_DATA=${SAMPLE_DATA:-'TRUE'} # Flag to load sample data +export OUD_PROXY=${OUD_PROXY:-'FALSE'} # Flag to create proxy instance +export OUD_CUSTOM=${OUD_CUSTOM:-'FALSE'} # Flag to create custom instance + +# default folder for OUD instance init scripts +export OUD_INSTANCE_INIT=${OUD_INSTANCE_INIT:-$ORACLE_DATA/scripts} +# - EOF Environment Variables ----------------------------------------------- + +# Normalize CREATE_INSTANCE +export OUD_PROXY=$(echo $OUD_PROXY| sed 's/^false$/0/gi') +export OUD_PROXY=$(echo $OUD_PROXY| sed 's/^true$/1/gi') + +# Normalize CREATE_INSTANCE +export OUD_CUSTOM=$(echo $OUD_CUSTOM| sed 's/^false$/0/gi') +export OUD_CUSTOM=$(echo $OUD_CUSTOM| sed 's/^true$/1/gi') + +# Normalize SAMPLE_DATA and DIRECTORY_DATA +DIRECTORY_DATA="--addBaseEntry" +if [ -z ${SAMPLE_DATA} ]; then + echo "SAMPLE_DATA is not set. Create base entry $BASEDN" + DIRECTORY_DATA="--addBaseEntry" +elif [[ "${SAMPLE_DATA}" =~ ^[0-9]+$ ]]; then + echo "SAMPLE_DATA is set to a number. Creating $SAMPLE_DATA sample entries" + DIRECTORY_DATA="--sampleData $SAMPLE_DATA" +elif [[ "${SAMPLE_DATA^^}" =~ ^TRUE$ ]]; then + echo "SAMPLE_DATA is true. Creating 100 sample entries" + DIRECTORY_DATA="--sampleData 100" +else + echo "SAMPLE_DATA is undefined. Create base entry $BASEDN" + DIRECTORY_DATA="--addBaseEntry" +fi + +echo "--- Setup OUD environment on volume ${ORACLE_DATA} ---------------------" +# create instance directories on volume +mkdir -v -p ${ORACLE_DATA} +for i in admin backup etc instances domains log scripts; do + mkdir -v -p ${ORACLE_DATA}/${i} +done +mkdir -v -p ${OUD_INSTANCE_ADMIN}/etc + +# create oudtab file for OUD Base, comment is just for documenttion.. +OUDTAB=${ORACLE_DATA}/etc/oudtab +echo "# OUD Config File" >${OUDTAB} +echo "# 1: OUD Instance Name" >>${OUDTAB} +echo "# 2: OUD LDAP Port" >>${OUDTAB} +echo "# 3: OUD LDAPS Port" >>${OUDTAB} +echo "# 4: OUD Admin Port" >>${OUDTAB} +echo "# 5: OUD Replication Port" >>${OUDTAB} +echo "# 6: Directory type eg. OUD, OID, ODSEE or OUDSM" >>${OUDTAB} +echo "# -----------------------------------------------" >>${OUDTAB} +echo "${OUD_INSTANCE}:${PORT}:${PORT_SSL}:${PORT_ADMIN}:${PORT_REP}:OUD" >>${OUDTAB} + +# reuse existing password file +if [ -f "$PWD_FILE" ]; then + echo " found password file $PWD_FILE" + export ADMIN_PASSWORD=$(cat $PWD_FILE) +fi +# generate a password +if [ -z ${ADMIN_PASSWORD} ]; then + # Auto generate Oracle WebLogic Server admin password + while true; do + s=$(cat /dev/urandom | tr -dc "A-Za-z0-9" | fold -w 10 | head -n 1) + if [[ ${#s} -ge 10 && "$s" == *[A-Z]* && "$s" == *[a-z]* && "$s" == *[0-9]* ]]; then + break + else + echo "Password does not Match the criteria, re-generating..." + fi + done + echo "------------------------------------------------------------------------" + echo " Oracle Unified Directory Server auto generated instance" + echo " admin password :" + echo " ----> Directory Admin : ${ADMIN_USER} " + echo " ----> Admin password : $s" + echo "------------------------------------------------------------------------" +else + s=${ADMIN_PASSWORD} + echo "------------------------------------------------------------------------" + echo " Oracle Unified Directory Server use pre defined instance" + echo " admin password :" + echo " ----> Directory Admin : ${ADMIN_USER} " + echo " ----> Admin password : $s" + echo "------------------------------------------------------------------------" +fi + +# write password file +mkdir -p "${OUD_INSTANCE_ADMIN}/etc/" +echo "$s" > ${PWD_FILE} + +# set instant init location create folder if it does exists +if [ -d "${OUD_INSTANCE_ADMIN}/create" ]; then + OUD_INSTANCE_INIT="${OUD_INSTANCE_ADMIN}/create" +else + OUD_INSTANCE_INIT="${OUD_INSTANCE_INIT}/setup" +fi + +echo "--- Create OUD instance ------------------------------------------------" +echo " OUD_INSTANCE = ${OUD_INSTANCE}" +echo " OUD_INSTANCE_BASE = ${OUD_INSTANCE_BASE}" +echo " OUD_INSTANCE_ADMIN = ${OUD_INSTANCE_ADMIN}" +echo " OUD_INSTANCE_INIT = ${OUD_INSTANCE_INIT}" +echo " OUD_INSTANCE_HOME = ${OUD_INSTANCE_HOME}" +echo " PORT = ${PORT}" +echo " PORT_SSL = ${PORT_SSL}" +echo " PORT_HTTP = ${PORT_HTTP}" +echo " PORT_HTTPS = ${PORT_HTTPS}" +echo " PORT_REP = ${PORT_REP}" +echo " PORT_ADMIN = ${PORT_ADMIN}" +echo " PORT_ADMIN_HTTP = ${PORT_ADMIN_HTTP}" +echo " ADMIN_USER = ${ADMIN_USER}" +echo " BASEDN = ${BASEDN}" +echo " SAMPLE_DATA = ${SAMPLE_DATA}" +echo " OUD_PROXY = ${OUD_PROXY}" +echo "" + +if [ ${OUD_CUSTOM} -eq 1 ]; then + echo "--- Create OUD instance (${OUD_INSTANCE}) using custom scripts ---------" + ${DOCKER_SCRIPTS}/config_oud_instance.sh ${OUD_INSTANCE_INIT} +elif [ ${OUD_PROXY} -eq 0 ]; then +# Create an directory + echo "--- Create regular OUD instance (${OUD_INSTANCE}) ----------------------" + ${ORACLE_BASE}/product/${ORACLE_HOME_NAME}/oud/oud-setup \ + --cli \ + --instancePath "${OUD_INSTANCE_HOME}/OUD" \ + --rootUserDN "${ADMIN_USER}" \ + --rootUserPasswordFile "${OUD_INSTANCE_ADMIN}/etc/${OUD_INSTANCE}_pwd.txt" \ + --adminConnectorPort ${PORT_ADMIN} \ + --httpAdminConnectorPort ${PORT_ADMIN_HTTP} \ + --ldapPort ${PORT} \ + --httpPort ${PORT_HTTP} \ + --ldapsPort ${PORT_SSL} \ + --httpsPort ${PORT_HTTPS} \ + --generateSelfSignedCertificate \ + --enableStartTLS \ + --hostname ${HOST} \ + --baseDN "${BASEDN}" \ + ${DIRECTORY_DATA} \ + --serverTuning jvm-default \ + --offlineToolsTuning autotune \ + --no-prompt \ + --noPropertiesFile + if [ $? -eq 0 ]; then + echo "--- Successfully created regular OUD instance (${OUD_INSTANCE}) --------" + # Execute custom provided setup scripts + + ${DOCKER_SCRIPTS}/config_oud_instance.sh ${OUD_INSTANCE_INIT} + else + echo "--- ERROR creating regular OUD instance (${OUD_INSTANCE}) --------------" + exit 1 + fi +elif [ ${OUD_PROXY} -eq 1 ]; then + echo "--- Create OUD proxy instance (${OUD_INSTANCE}) ------------------------" + ${ORACLE_BASE}/product/${ORACLE_HOME_NAME}/oud/oud-proxy-setup \ + --cli \ + --instancePath "${OUD_INSTANCE_HOME}/OUD" \ + --rootUserDN "${ADMIN_USER}" \ + --rootUserPasswordFile "${OUD_INSTANCE_ADMIN}/etc/${OUD_INSTANCE}_pwd.txt" \ + --adminConnectorPort ${PORT_ADMIN} \ + --httpAdminConnectorPort ${PORT_ADMIN_HTTP} \ + --ldapPort ${PORT} \ + --httpPort ${PORT_HTTP} \ + --ldapsPort ${PORT_SSL} \ + --httpsPort ${PORT_HTTPS} \ + --generateSelfSignedCertificate \ + --enableStartTLS \ + --hostname ${HOST} \ + --no-prompt \ + --noPropertiesFile + if [ $? -eq 0 ]; then + echo "--- Successfully created OUD proxy instance (${OUD_INSTANCE}) ----------" + # Execute custom provided setup scripts + + ${DOCKER_SCRIPTS}/config_oud_instance.sh ${OUD_INSTANCE_INIT} + else + echo "--- ERROR creating OUD proxy instance (${OUD_INSTANCE}) -----------------" + exit 1 + fi +fi +# --- EOF ------------------------------------------------------------------- \ No newline at end of file diff --git a/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/setup_oud.sh b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/setup_oud.sh new file mode 100755 index 0000000000..3710b8969f --- /dev/null +++ b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/setup_oud.sh @@ -0,0 +1,121 @@ +#!/bin/bash +# ---------------------------------------------------------------------- +# Trivadis AG, Infrastructure Managed Services +# Saegereistrasse 29, 8152 Glattbrugg, Switzerland +# ---------------------------------------------------------------------- +# Name.......: install_database.sh +# Author.....: Stefan Oehrli (oes) stefan.oehrli@trivadis.com +# Editor.....: Stefan Oehrli +# Date.......: 2017.12.04 +# Revision...: +# Purpose....: Helper script to install Oracle Unified Directory binaries +# Notes......: tbd. +# Reference..: -- +# License....: Licensed under the Universal Permissive License v 1.0 as +# shown at http://oss.oracle.com/licenses/upl. +# ---------------------------------------------------------------------- +# Modified...: +# see git revision history for more information on changes/updates +# ---------------------------------------------------------------------- + +# - Environment Variables ---------------------------------------------- +# - Set default values for environment variables if not yet defined. +# ---------------------------------------------------------------------- +# OUD Software and Patchs +DEFAULT_FMW_OUD_PKG="p26270957_122130_Generic.zip" +DEFAULT_OUD_PATCH="" +ORACLE_HOME=${ORACLE_BASE}/product/${ORACLE_HOME_NAME} +ORAREPO=${ORAREPO:-"orarepo"} +# - EOF Environment Variables ------------------------------------------- + +# Get the package and psu's from cli +FMW_OUD_PKG=${1:-${DEFAULT_FMW_OUD_PKG}} +FMW_OUD_PKG_LOG=$(basename ${FMW_OUD_PKG} .zip).log +OUD_PATCH=${2:-${DEFAULT_OUD_PATCH}} +SLIM=${3:-"FALSE"} + +# - Install OUD binaries ----------------------------------------------- +# Get the oracle binaries if they are not there yet orarepo +if [ ! -s "${DOWNLOAD}/${FMW_OUD_PKG}" ]; then + echo "download ${DOWNLOAD}/${FMW_OUD_PKG} from orarepo" + curl -f http://${ORAREPO}/${FMW_OUD_PKG} -o ${DOWNLOAD}/${FMW_OUD_PKG} +else + echo "use local copy of ${DOWNLOAD}/${FMW_OUD_PKG}" +fi + +# unpack OUD binary package +cd ${DOWNLOAD} +$JAVA_HOME/bin/jar xvf ${FMW_OUD_PKG} >${FMW_OUD_PKG_LOG} + +if [ $? -ne 0 ]; then + echo "unable to extract file ${FMW_OUD_PKG}" + exit 1 +fi + +# the jar file name from the logfile +FMW_OUD_JAR=$(grep -i jar ${FMW_OUD_PKG_LOG} |cut -d' ' -f3| tr -d " ") + +# Install OUD binaries +$JAVA_HOME/bin/java -jar ${DOWNLOAD}/$FMW_OUD_JAR -silent \ + -responseFile ${DOWNLOAD}/install.rsp \ + -invPtrLoc ${DOWNLOAD}/oraInst.loc \ + -ignoreSysPrereqs -force \ + -novalidation ORACLE_HOME=${ORACLE_HOME} \ + INSTALL_TYPE="Standalone Oracle Unified Directory Server (Managed independently of WebLogic server)" + +# clean up +rm -rf ${DOWNLOAD}/${FMW_OUD_PKG} \ + ${DOWNLOAD}/${FMW_OUD_PKG_LOG} \ + ${DOWNLOAD}/${FMW_OUD_JAR} + +# - Install OUD Patch / PSU -------------------------------------------- +if [ -n ${OUD_PATCH} ]; then + for i in $(echo "${OUD_PATCH}"|sed s/\,/\ /g); do + OUD_PSU=${i} + OUD_PSU_ID=$(echo $OUD_PSU| sed -E 's/p([[:digit:]]+).*/\1/') + echo "Install Oracle Patch / PSU ${OUD_PSU_ID}" + # Get the latest database RU if it is not there yet + if [ ! -s "${DOWNLOAD}/${OUD_PSU}" ]; then + echo "download ${DOWNLOAD}/${OUD_PSU} from orarepo" + curl -f http://${ORAREPO}/${OUD_PSU} -o ${DOWNLOAD}/${OUD_PSU} + else + echo "use local copy of ${DOWNLOAD}/${OUD_PSU}" + fi + + # unzip OUD PSU + cd ${DOWNLOAD} + $JAVA_HOME/bin/jar xvf ${OUD_PSU} + + # install OUD PSU + cd ${OUD_PSU_ID} + ${ORACLE_HOME}/OPatch/opatch apply -silent + + # clean up + rm -rf ${DOWNLOAD}/${OUD_PSU} \ + ${DOWNLOAD}/${OUD_PSU_ID} + done +else + echo "No OUD Patch / PSU specified" +fi +# - final clean up ----------------------------------------------------- +# Remove not needed components +# tbd +# remove patch storage +rm -rf ${ORACLE_HOME}/.patch_storage +# OUI backup +rm -rf ${ORACLE_HOME}/inventory/backup/* +# Temp location +rm -rf ${DOWNLOAD}/* +rm -rf /tmp/OraInstall* + +if [ "${SLIM}" = "TRUE" ]; then + # remove inventory + rm -rf ${ORACLE_HOME}/inventory + # remove oui + rm -rf ${ORACLE_HOME}/oui + # remove OPatch + rm -rf ${ORACLE_HOME}/OPatch + rm -rf ${DOWNLOAD}/* + rm -rf /tmp/OraInstall* +fi +# --- EOF -------------------------------------------------------------- \ No newline at end of file diff --git a/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/setup_oudbase.sh b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/setup_oudbase.sh new file mode 100755 index 0000000000..e675d32687 --- /dev/null +++ b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/setup_oudbase.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Trivadis AG, Infrastructure Managed Services +# Saegereistrasse 29, 8152 Glattbrugg, Switzerland +# ----------------------------------------------------------------------------- +# Name.......: setup_oudbase.sh +# Author.....: Stefan Oehrli (oes) stefan.oehrli@trivadis.com +# Editor.....: Stefan Oehrli +# Date.......: 2018.04.11 +# Revision...: +# Purpose....: Script to download and install latest version of oudbase +# Notes......: The script does download the latest version of OUD Base from +# GitHub and install it in ${ORACLE_BASE} +# Reference..: -- +# License....: Licensed under the Universal Permissive License v 1.0 as +# shown at http://oss.oracle.com/licenses/upl. +# ----------------------------------------------------------------------------- +# Modified...: +# see git revision history for more information on changes/updates +# ----------------------------------------------------------------------------- + +# - Customization ----------------------------------------------------------- +DOWNLOAD="/tmp/download" +# oudbase install script +OUDBASE_PKG="oudbase_install.sh" +# OUD base GitHub download URL +OUDBASE_URL=$(curl -s https://api.github.com/repos/oehrlis/oudbase/releases/latest \ + | grep "browser_download_url.*${OUDBASE_PKG}" \ + | cut -d: -f 2,3 \ + | tr -d \" ) +# - End of Customization ---------------------------------------------------- + +# geht the OUD base install package +curl -f --location-trusted ${OUDBASE_URL} -o ${DOWNLOAD}/${OUDBASE_PKG} + +#adapt permissions +chmod 755 ${DOWNLOAD}/${OUDBASE_PKG} + +# install OUD base +${DOWNLOAD}/${OUDBASE_PKG} -va -b ${ORACLE_BASE} -m ${ORACLE_HOME} -d ${ORACLE_DATA} && \ + +# clean up +rm -rf ${DOWNLOAD}/${OUDBASE_PKG} ${DOWNLOAD}/oudbase_install.log + +# --- EOF ------------------------------------------------------------------- \ No newline at end of file diff --git a/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/start_oud_instance.sh b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/start_oud_instance.sh new file mode 100755 index 0000000000..b1d9c784c4 --- /dev/null +++ b/OracleUnifiedDirectory/dockerfiles/12.2.1.3/scripts/start_oud_instance.sh @@ -0,0 +1,133 @@ +#!/bin/bash +# --------------------------------------------------------------------------- +# Trivadis AG, Infrastructure Managed Services +# Saegereistrasse 29, 8152 Glattbrugg, Switzerland +# --------------------------------------------------------------------------- +# Name.......: start_oud_instance.sh +# Author.....: Stefan Oehrli (oes) stefan.oehrli@trivadis.com +# Editor.....: Stefan Oehrli +# Date.......: 2017.12.04 +# Revision...: +# Purpose....: Helper script to start the OUD instance +# Notes......: Script does look for the config.ldif. If it does not exist +# it assume that the container is started the first time. A new +# OUD instance will be created. If CREATE_INSTANCE is set to false +# no instance will be created. +# Reference..: -- +# License....: Licensed under the Universal Permissive License v 1.0 as +# shown at http://oss.oracle.com/licenses/upl. +# --------------------------------------------------------------------------- +# Modified...: +# see git revision history for more information on changes/updates +# --------------------------------------------------------------------------- + +# - Environment Variables --------------------------------------------------- +# - Set default values for environment variables if not yet defined. +# --------------------------------------------------------------------------- +# Default name for OUD instance +export OUD_INSTANCE=${OUD_INSTANCE:-oud_docker} + +# Flag to create instance on first boot +export CREATE_INSTANCE=${CREATE_INSTANCE:-'TRUE'} + +# OUD instance base directory +export OUD_INSTANCE_BASE=${OUD_INSTANCE_BASE:-"$ORACLE_DATA/instances"} + +# OUD instance home directory +export OUD_INSTANCE_HOME=${OUD_INSTANCE_BASE}/${OUD_INSTANCE} +# - EOF Environment Variables ----------------------------------------------- + +# --------------------------------------------------------------------------- +# SIGINT handler +# --------------------------------------------------------------------------- +function int_oud() { + echo "---------------------------------------------------------------" + echo "SIGINT received, shutting down OUD instance!" + echo "---------------------------------------------------------------" + ${OUD_INSTANCE_HOME}/OUD/bin/stop-ds >/dev/null 2>&1 +} + +# --------------------------------------------------------------------------- +# SIGTERM handler +# --------------------------------------------------------------------------- +function term_oud() { + echo "---------------------------------------------------------------" + echo "SIGTERM received, shutting down OUD instance!" + echo "---------------------------------------------------------------" + ${OUD_INSTANCE_HOME}/OUD/bin/stop-ds >/dev/null 2>&1 +} + +# --------------------------------------------------------------------------- +# SIGKILL handler +# --------------------------------------------------------------------------- +function kill_oud() { + echo "---------------------------------------------------------------" + echo "SIGKILL received, shutting down OUD instance!" + echo "---------------------------------------------------------------" +kill -9 $childPID +} + +# Set SIGINT handler +trap int_oud SIGINT + +# Set SIGTERM handler +trap term_oud SIGTERM + +# Set SIGKILL handler +trap kill_oud SIGKILL + +# Normalize CREATE_INSTANCE +export CREATE_INSTANCE=$(echo $CREATE_INSTANCE| sed 's/^false$/0/gi') +export CREATE_INSTANCE=$(echo $CREATE_INSTANCE| sed 's/^true$/1/gi') + +echo "--- Seeking for an OUD environment on volume ${ORACLE_DATA} -------------" +# check if config.ldif does exists +if [ -f ${OUD_INSTANCE_HOME}/OUD/config/config.ldif ]; then + # Start existing OUD instance + echo "---------------------------------------------------------------" + echo " Start OUD instance (${OUD_INSTANCE}):" + echo "---------------------------------------------------------------" + ${OUD_INSTANCE_HOME}/OUD/bin/start-ds >/dev/null 2>&1 +elif [ ${CREATE_INSTANCE} -eq 1 ]; then + echo "---------------------------------------------------------------" + echo " Create OUD instance (${OUD_INSTANCE}):" + echo "---------------------------------------------------------------" + # CREATE_INSTANCE is true, therefore we will create new OUD instance + ${DOCKER_SCRIPTS}/create_oud_instance.sh + + if [ $? -eq 0 ]; then + # restart OUD instance + ${OUD_INSTANCE_HOME}/OUD/bin/stop-ds --restart >/dev/null 2>&1 + fi +else + echo "---------------------------------------------------------------" + echo " WARNING: OUD config.ldif does not exist and CREATE_INSTANCE " + echo " is false. OUD instance has to be created manually using" + echo " oud_setup or oud-proxy-setup via cli" + echo "---------------------------------------------------------------" +fi + +# Check whether OUD instance is up and running +${DOCKER_SCRIPTS}/check_oud_Instance.sh >/dev/null 2>&1 +if [ $? -eq 0 ]; then + echo "---------------------------------------------------------------" + echo " OUD instance is ready to use:" + echo " Instance Name : ${OUD_INSTANCE}" + echo " Instance Home (ok) : ${OUD_INSTANCE_HOME}" + echo " Oracle Home : ${ORACLE_BASE}/product/${ORACLE_HOME_NAME}" + echo " Instance Status : up" + echo " LDAP Port : ${PORT}" + echo " LDAPS Port : ${PORT_SSL}" + echo " Admin Port : ${PORT_ADMIN}" + echo " Replication Port : ${PORT_REP}" + echo "---------------------------------------------------------------" +fi + +# Tail on server log and wait (otherwise container will exit) +mkdir -p ${OUD_INSTANCE_HOME}/OUD/logs +touch ${OUD_INSTANCE_HOME}/OUD/logs/server.out +tail -f ${OUD_INSTANCE_HOME}/OUD/logs/server.out & + +childPID=$! +wait $childPID +# --- EOF ------------------------------------------------------------------- \ No newline at end of file diff --git a/OracleUnifiedDirectory/dockerfiles/buildDockerImage.sh b/OracleUnifiedDirectory/dockerfiles/buildDockerImage.sh new file mode 100755 index 0000000000..8b3038f514 --- /dev/null +++ b/OracleUnifiedDirectory/dockerfiles/buildDockerImage.sh @@ -0,0 +1,3 @@ +#!/bin/bash +# +#To be defined \ No newline at end of file