From 67ee97d2488b99b143f879bdde3bedaacf6783ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Erik=20Hedenstr=C3=B6m?= <erik@hedenstroem.com>
Date: Tue, 5 Aug 2014 13:10:53 +0200
Subject: [PATCH] Fixed docs. Added support for directory overlays.

---
 Dockerfile |  6 ++++--
 README.md  | 14 ++++++++++----
 init.sh    | 13 +++++--------
 3 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index ce53096..2e68793 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -30,8 +30,10 @@ RUN \
 
 # Import self-signed cert as trusted CA
 RUN \
-  openssl s_client -servername cert.codemate.se -connect codemate.se:443 </dev/null | sed -ne '/--BEGIN CERTIFICATE--/,/--END CERTIFICATE--/p' > /tmp/codemate.cert && \
-  keytool -import -noprompt -trustcacerts -keystore /usr/lib/jvm/java-7-oracle/jre/lib/security/cacerts -storepass changeit -noprompt -alias codemate-self-signed -file /tmp/codemate.cert
+  mkdir -p /usr/share/ca-certificates/extra && \
+  openssl s_client -servername cert.codemate.se -connect codemate.se:443 </dev/null | sed -ne '/--BEGIN CERTIFICATE--/,/--END CERTIFICATE--/p' > /usr/share/ca-certificates/extra/codemate.crt && \
+  update-ca-certificates && \
+  keytool -import -noprompt -trustcacerts -keystore /usr/lib/jvm/java-7-oracle/jre/lib/security/cacerts -storepass changeit -noprompt -alias codemate-self-signed -file /usr/share/ca-certificates/extra/codemate.crt
 
 # Install and configure Exim
 RUN \
diff --git a/README.md b/README.md
index c434427..c81b89f 100644
--- a/README.md
+++ b/README.md
@@ -47,13 +47,20 @@ docker run -e JIRA_VERSION=6.3.1 -d registry.codemate.se/jira
 
 ### Overriding JIRA files
 
-By providing an environment variable name `JIRA_OVERLAY` that points to a gzipped tar file you can apply an overlay on the JIRA installation. This tarball will be unzipped and extracted in the root of the JIRA installation directory. The overlay enables you to add custom jira configurations such as SSL or Crowd integration.
+By providing an environment variable name `JIRA_OVERLAY` that points to a directory or URL of a gzipped tar file you can apply an overlay on the JIRA installation. A directory will be recursively copied, and a tarball will be unzipped and extracted in the root of the Confluence installation directory. The overlay enables you to add custom JIRA configurations such as SSL or Crowd integration.
 
 ```
 docker run -e JIRA_OVERLAY=http://10.0.0.1/jira-config.tgz -d registry.codemate.se/jira
+docker run -e JIRA_OVERLAY=/tmp/jira-config -d registry.codemate.se/jira
 ```
 
-The overlay is fetched using curl so if you need to provide basic auth credentials simply prefix the url with the credentials, for example:
+The overlay is fetched using curl so file URLs are valid:
+
+```
+JIRA_OVERLAY="file:///tmp/jira-config.tgz"
+```
+
+If you need to provide basic auth credentials simply prefix the url with the credentials, for example:
 
 ```
 JIRA_OVERLAY="-u username:password http://10.0.0.1/jira-config.tgz"
@@ -67,7 +74,7 @@ By providing an environment variable name `MYSQL_INIT` that points to an SQL scr
 docker run -e MYSQL_INIT=http://10.0.0.1/jira-init.sql -d registry.codemate.se/jira
 ```
 
-Basic auth credentials can be used as mentioned in the JIRA overlay section.
+Basic auth credentials and file URLs can be used as mentioned in the overlay section.
 
 ### Combined options
 
@@ -81,7 +88,6 @@ docker run \
   -e JIRA_OVERLAY=http://10.0.0.1/jira-config.tgz \
   -v /opt/application-data/jira:/home/jira \
   -p 8080:8080 \
-  -p 8081:8081 \
   -d registry.codemate.se/jira
 ```
 
diff --git a/init.sh b/init.sh
index c592a99..8f628df 100644
--- a/init.sh
+++ b/init.sh
@@ -2,19 +2,19 @@
 
 set -e # Exit on errors
 
-SEPARATOR="-------------------------------------------------------------------------------"
 JIRA_DIR=/opt/atlassian-jira-$JIRA_VERSION-standalone
 MYSQL_DIR=$JIRA_HOME/mysql-data
 
 if [ ! -d $JIRA_DIR ]; then
     curl -s -v -L http://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-$JIRA_VERSION.tar.gz | tar xzf - -C /opt
-    curl -s -v -L -o $JIRA_DIR/lib/mysql-connector-java-5.1.31.jar http://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.31/mysql-connector-java-5.1.31.jar
-    echo "$SEPARATOR"
 fi
 
 if [ ${JIRA_OVERLAY:+x} ] && [ -d $JIRA_DIR ]; then
-    curl -s -v -L $JIRA_OVERLAY | tar xzf - -C $JIRA_DIR
-    echo "$SEPARATOR"
+    if [ -d $JIRA_OVERLAY ]; then
+        cp -R $JIRA_OVERLAY/* $JIRA_DIR
+    else
+        curl -s -v -L $JIRA_OVERLAY | tar xzf - -C $JIRA_DIR
+    fi
 fi
 
 chown -R root:root $JIRA_DIR
@@ -30,7 +30,6 @@ if [ ! -d $MYSQL_DIR ]; then
     mysql_install_db
     mysqld_safe &
     sleep 5s
-    echo "$SEPARATOR"
 else
     mysqld_safe &
     sleep 5s
@@ -38,11 +37,9 @@ fi
 
 if [ ${MYSQL_INIT:+x} ] && [ -d $MYSQL_DIR ]; then
     curl -s -v -L $MYSQL_INIT | mysql
-    echo "$SEPARATOR"
 fi
 
 env | sort
-echo "$SEPARATOR"
 
 exim4 -v -bdf -q15m &
 
-- 
GitLab