diff --git a/Dockerfile b/Dockerfile
index 643c464..446ba0b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,8 +3,7 @@ FROM ubuntu:18.04
COPY assets /assets
RUN /assets/setup.sh
-EXPOSE 22
EXPOSE 1521
EXPOSE 8080
-CMD /usr/sbin/startup.sh && tail -f /dev/null
\ No newline at end of file
+ENTRYPOINT ["/usr/sbin/startup.sh"]
diff --git a/README.md b/README.md
index 14f50cd..1e7cc84 100644
--- a/README.md
+++ b/README.md
@@ -3,58 +3,42 @@ docker-oracle-xe-11g
Oracle Express Edition 11g Release 2 on Ubuntu 18.04 LTS
-This **Dockerfile** is a [trusted build](https://registry.hub.docker.com/u/wnameless/oracle-xe-11g/) of [Docker Registry](https://registry.hub.docker.com/).
-Since 2019-Feb-13(the Valentine's day eve) this docker image has been removed by DockerHub due to the Docker DMCA Takedown Notice from the Copyright owner which is the Oracle.
-
-Happy Valentine's day!
-
-```diff
-+ The new DockerHub [wnameless/oracle-xe-11g-r2] has been released, because
-+ the old [wnameless/oracle-xe-11g] is banned by DockerHub and I cannot restore it.
-+ Thanks for the help from the staff in Oracle with my DMCA Takedown issue, however this problem
-+ is totally ignored by the DockerHub and I barely can't do anything but to open a new repo.
-+ Sep 29 2019
+## Installation
```
-
-## Installation(Local)
-```
-git clone https://github.com/wnameless/docker-oracle-xe-11g.git
+git clone https://github.com/interob/docker-oracle-xe-11g.git
cd docker-oracle-xe-11g
-docker build -t wnameless/oracle-xe-11g .
+docker build -t interob/oracle-xe-11g .
```
-## Installation(DockerHub)
-```
-docker pull wnameless/oracle-xe-11g-r2
+Volume support:
+
+```bash
+$ docker run -d -v /var/yourdata:/u01/app/oracle -p 1521:1521 epiclabs/docker-oracle-xe-11g
```
-SSH server has been removed since 18.04, please use "docker exec"
-## Quick Start
+`/var/yourdata` is an empty directory which will be initialized as soon as the image runs for the first time. If the directory already contains data produced by a previous instance of this image, then the data is preserved. With this, the container can be thrown away every time.
-Run with 1521 port opened:
-```
-docker run -d -p 49161:1521 wnameless/oracle-xe-11g-r2
-```
-Run this, if you want the database to be connected remotely:
-```
-docker run -d -p 49161:1521 -e ORACLE_ALLOW_REMOTE=true wnameless/oracle-xe-11g-r2
+Run like this, if you want the database to be connected remotely:
+
+```bash
+$ docker run -d -p 49161:1521 -e ORACLE_ALLOW_REMOTE=true epiclabs/docker-oracle-xe-11g
```
For performance concern, you may want to disable the disk asynch IO:
```
-docker run -d -p 49161:1521 -e ORACLE_DISABLE_ASYNCH_IO=true wnameless/oracle-xe-11g-r2
+docker run -d -p 49161:1521 -e ORACLE_DISABLE_ASYNCH_IO=true interob/oracle-xe-11g-r2
```
Enable XDB user with default password: xdb, run this:
```
-docker run -d -p 49161:1521 -e ORACLE_ENABLE_XDB=true wnameless/oracle-xe-11g-r2
+docker run -d -p 49161:1521 -e ORACLE_ENABLE_XDB=true interob/oracle-xe-11g-r2
```
For APEX user:
```
-docker run -d -p 49161:1521 -p 8080:8080 wnameless/oracle-xe-11g-r2
+docker run -d -p 49161:1521 -p 8080:8080 interob/oracle-xe-11g-r2
```
```
@@ -63,9 +47,9 @@ username: ADMIN
password: admin
```
-For latest APEX(18.1) user, please pull wnameless/oracle-xe-11g-r2:18.04-apex first:
+For latest APEX(18.1) user, please pull interob/oracle-xe-11g-r2:18.04-apex first:
```
-docker run -d -p 49161:1521 -p 8080:8080 wnameless/oracle-xe-11g-r2:18.04-apex
+docker run -d -p 49161:1521 -p 8080:8080 interob/oracle-xe-11g-r2:18.04-apex
```
```
@@ -84,7 +68,7 @@ username: system
password: oracle
```
-Password for SYS & SYSTEM
+Default password for SYS & SYSTEM
```
oracle
```
@@ -92,9 +76,33 @@ oracle
Support custom DB Initialization and running shell scripts
```
# Dockerfile
-FROM wnameless/oracle-xe-11g-r2
+FROM interob/oracle-xe-11g
ADD init.sql /docker-entrypoint-initdb.d/
ADD script.sh /docker-entrypoint-initdb.d/
```
Running order is alphabetically.
+
+### Environment variables
+
+* `ORACLE_PASSWORD` : Changes SYS and SYSTEM password to this value
+* `RELAX_SECURITY` : If set to 1, a relaxed password policy profile will be put in place with this parameters for `SYS` and `SYSTEM` :
+
+```
+CREATE PROFILE NOEXPIRY LIMIT
+ COMPOSITE_LIMIT UNLIMITED
+ PASSWORD_LIFE_TIME UNLIMITED
+ PASSWORD_REUSE_TIME UNLIMITED
+ PASSWORD_REUSE_MAX UNLIMITED
+ PASSWORD_VERIFY_FUNCTION NULL
+ PASSWORD_LOCK_TIME UNLIMITED
+ PASSWORD_GRACE_TIME UNLIMITED
+ FAILED_LOGIN_ATTEMPTS UNLIMITED;
+```
+
+Example:
+
+```bash
+$ docker run -d -p 1521:1521 -e ORACLE_ALLOW_REMOTE=true -e ORACLE_PASSWORD=testpassword -e RELAX_SECURITY=1 interob/docker-oracle-xe-11g
+```
+
diff --git a/assets/setup.sh b/assets/setup.sh
index 730a5a8..09d8247 100755
--- a/assets/setup.sh
+++ b/assets/setup.sh
@@ -3,11 +3,14 @@
# avoid dpkg frontend dialog / frontend warnings
export DEBIAN_FRONTEND=noninteractive
+cat /assets/oracle-xe_11.2.0-1.0_amd64.deba* > /assets/oracle-xe_11.2.0-1.0_amd64.deb
+
+apt-get update
+
# Prepare to install Oracle
-apt-get update &&
apt-get install -y libaio1 net-tools bc &&
ln -s /usr/bin/awk /bin/awk &&
-mkdir /var/lock/subsys &&
+mkdir -p /var/lock/subsys &&
mv /assets/chkconfig /sbin/chkconfig &&
chmod 755 /sbin/chkconfig &&
@@ -48,4 +51,17 @@ cat /assets/apex-default-pwd.sql | sqlplus -s SYSTEM/oracle
# Remove installation files
rm -r /assets/
+mv /u01/app/oracle/product /u01/app/oracle-product
+pushd /u01/app/oracle-product/11.2.0/xe/
+tar zcvf /u01/app/default-dbs.tar.gz dbs
+rm -rf dbs/
+popd
+
+tar zcvf /u01/app/default-admin.tar.gz /u01/app/oracle/admin && rm -rf /u01/app/oracle/admin
+tar zcvf /u01/app/default-oradata.tar.gz /u01/app/oracle/oradata && rm -rf /u01/app/oracle/oradata
+tar zcvf /u01/app/default-fast_recovery_area.tar.gz /u01/app/oracle/fast_recovery_area && rm -rf /u01/app/oracle/fast_recovery_area
+
+# Install startup script for container
+
+
exit $?
diff --git a/assets/startup.sh b/assets/startup.sh
old mode 100644
new mode 100755
index 79193ed..ba3d040
--- a/assets/startup.sh
+++ b/assets/startup.sh
@@ -1,6 +1,18 @@
#!/bin/bash
-LISTENER_ORA=/u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
-TNSNAMES_ORA=/u01/app/oracle/product/11.2.0/xe/network/admin/tnsnames.ora
+
+echo ""
+echo "Oracle XE 11g CI/Development image"
+echo "By Epic Labs, 2017 - http://www.epiclabs.io"
+echo ""
+echo "https://github.com/epiclabs-io/docker-oracle-xe-11g"
+echo "forked from wnameless/docker-oracle-xe-11g"
+echo ""
+echo ""
+
+
+
+LISTENER_ORA=/u01/app/oracle-product/11.2.0/xe/network/admin/listener.ora
+TNSNAMES_ORA=/u01/app/oracle-product/11.2.0/xe/network/admin/tnsnames.ora
cp "${LISTENER_ORA}.tmpl" "$LISTENER_ORA" &&
sed -i "s/%hostname%/$HOSTNAME/g" "${LISTENER_ORA}" &&
@@ -9,11 +21,94 @@ cp "${TNSNAMES_ORA}.tmpl" "$TNSNAMES_ORA" &&
sed -i "s/%hostname%/$HOSTNAME/g" "${TNSNAMES_ORA}" &&
sed -i "s/%port%/1521/g" "${TNSNAMES_ORA}" &&
+
+rm -rf /u01/app/oracle/product
+
+ln -s /u01/app/oracle-product /u01/app/oracle/product #Mount database installation to the Expanded VOLUME of container
+
+if [ ! -d /u01/app/oracle/dbs ] ; then
+ echo "using default configuration"
+ tar xf /u01/app/default-dbs.tar.gz -C /u01/app/oracle/
+fi
+
+if [ ! -d /u01/app/oracle/oradata ] ; then
+ echo "using default data directory"
+ tar xf /u01/app/default-oradata.tar.gz
+fi
+
+if [ ! -d /u01/app/oracle/admin ] ; then
+ echo "using default admin directory"
+ tar xf /u01/app/default-admin.tar.gz
+fi
+
+if [ ! -d /u01/app/oracle/fast_recovery_area ] ; then
+ echo "using default fast_recovery_area directory"
+ tar xf /u01/app/default-fast_recovery_area.tar.gz
+fi
+
+ln -s /u01/app/oracle/dbs /u01/app/oracle-product/11.2.0/xe/dbs #Link db configuration to the installation path form extended volume with DB data
+
+chown -R oracle:dba /u01/app/oracle
+
service oracle-xe start
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=XE
+export ORACLE_DATA=/u01/app/oracle/oradata/$ORACLE_SID
+
+
+if [ ! -e "/u01/app/oracle/initialized.id" ] ; then
+
+ echo "Performing initial database setup ..."
+
+ if [ ! -z "$RELAX_SECURITY" ] ; then
+ echo "WARNING: Relaxing profile security with no password reuse limits, etc. Use with caution ..."
+ echo "CREATE PROFILE NOEXPIRY LIMIT
+ COMPOSITE_LIMIT UNLIMITED
+ PASSWORD_LIFE_TIME UNLIMITED
+ PASSWORD_REUSE_TIME UNLIMITED
+ PASSWORD_REUSE_MAX UNLIMITED
+ PASSWORD_VERIFY_FUNCTION NULL
+ PASSWORD_LOCK_TIME UNLIMITED
+ PASSWORD_GRACE_TIME UNLIMITED
+ FAILED_LOGIN_ATTEMPTS UNLIMITED;" | sqlplus -s SYSTEM/oracle
+
+ echo "ALTER USER SYSTEM PROFILE NOEXPIRY;" | sqlplus -s SYSTEM/oracle
+ echo "ALTER USER SYS PROFILE NOEXPIRY;" | sqlplus -s SYSTEM/oracle
+ echo "Security relaxed."
+
+ fi
+
+ echo "Setting db_create_file_dest param..."
+ if ! echo "ALTER SYSTEM SET db_create_file_dest = '$ORACLE_DATA';" | sqlplus -s SYSTEM/oracle; then
+ echo "error setting db_create_file_dest param"
+ exit 1
+ fi
+
+ if [ -z "$ORACLE_PASSWORD" ] ; then
+ echo "Warning: using default password!!. Set ORACLE_PASSWORD environment variable to change it"
+ export ORACLE_PASSWORD="oracle";
+ else
+
+ echo "Setting SYS password... "
+ if ! echo "ALTER USER SYS IDENTIFIED BY \"$ORACLE_PASSWORD\";" | sqlplus -s SYSTEM/oracle ; then
+ echo "Error setting SYS password."
+ exit 1;
+ fi
+
+ echo "Setting SYSTEM password... "
+
+ if ! echo "ALTER USER SYSTEM IDENTIFIED BY \"$ORACLE_PASSWORD\";" | sqlplus -s SYSTEM/oracle ; then
+ echo "Error setting SYSTEM password."
+ exit 1;
+ fi
+ fi
+
+ touch "/u01/app/oracle/initialized.id"
+fi
+
+
if [ "$ORACLE_ENABLE_XDB" = true ]; then
echo "ALTER USER XDB ACCOUNT UNLOCK;" | sqlplus -s SYSTEM/oracle
@@ -21,7 +116,7 @@ if [ "$ORACLE_ENABLE_XDB" = true ]; then
fi
if [ "$ORACLE_ALLOW_REMOTE" = true ]; then
- echo "alter system disable restricted session;" | sqlplus -s SYSTEM/oracle
+ echo "alter system disable restricted session;" | sqlplus -s "SYSTEM/$ORACLE_PASSWORD"
fi
if [ "$ORACLE_DISABLE_ASYNCH_IO" = true ]; then
@@ -29,11 +124,13 @@ if [ "$ORACLE_DISABLE_ASYNCH_IO" = true ]; then
service oracle-xe restart
fi
+echo "Running startup scripts ..."
+
for f in /docker-entrypoint-initdb.d/*; do
[ -f "$f" ] || continue
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
- *.sql) echo "$0: running $f"; echo "exit" | /u01/app/oracle/product/11.2.0/xe/bin/sqlplus "SYS/oracle" AS SYSDBA @"$f"; echo ;;
+ *.sql) echo "$0: running $f"; echo "exit" | /u01/app/oracle/product/11.2.0/xe/bin/sqlplus "SYS/$ORACLE_PASSWORD" AS SYSDBA @"$f"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo
@@ -42,3 +139,13 @@ done
echo "#########################"
echo "DATABASE IS READY TO USE!"
echo "#########################"
+
+
+echo -e "\n\n Bring it on!! \n\n"
+
+tail -fn 0 /u01/app/oracle/diag/rdbms/xe/XE/trace/alert_XE.log
+
+echo -e '\n\nShutting down...\n\n'
+service oracle-xe stop
+
+echo -e "\nbye\n"