From ae43b232db148f4483b8ef68e2e5051199214274 Mon Sep 17 00:00:00 2001
From: Disassembler <disassembler@dasm.cz>
Date: Tue, 24 Apr 2018 23:37:18 +0200
Subject: [PATCH] Move Motech to Tomcat root context

---
 basic/srv/portal/index.html     |  2 +-
 motech.sh                       |  4 ++--
 motech/Dockerfile               | 10 +++++-----
 motech/srv/motech/update-url.sh |  2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/basic/srv/portal/index.html b/basic/srv/portal/index.html
index b9cd2e3..0ffb09b 100644
--- a/basic/srv/portal/index.html
+++ b/basic/srv/portal/index.html
@@ -249,7 +249,7 @@
         </div>
 
         <div class="c" id="motech">
-            <h2><a href="https://motech.{host}/motech/"><img src="img/Motech.png" alt="Motech" title="Motech">Motech</a></h2>
+            <h2><a href="https://motech.{host}/"><img src="img/Motech.png" alt="Motech" title="Motech">Motech</a></h2>
             <p>Integrace zdravotnických a komunikačních služeb.</p>
             <ul>
                 <li><strong>Login:</strong> <span class="login"></span></li>
diff --git a/motech.sh b/motech.sh
index 44076c2..9edb590 100755
--- a/motech.sh
+++ b/motech.sh
@@ -31,11 +31,11 @@ cp ${SOURCE_DIR}/srv/motech/update-url.sh /srv/motech/update-url.sh
 service motech start
 echo `date` '- Waiting for database to be populated. This should take about a minute.'
 MOTECH_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' motech)
-until curl -s "http://${MOTECH_IP}:8080/motech/module/server/startup/" | grep -q adminLogin; do
+until curl -s "http://${MOTECH_IP}:8080/module/server/startup/" | grep -q adminLogin; do
     sleep 1
 done
 export MOTECH_ADMIN_USER="admin"
 export MOTECH_ADMIN_EMAIL="admin@example.com"
 export MOTECH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
-curl -H "Content-Type: application/json" -X POST -d "{\"adminLogin\":\"${MOTECH_ADMIN_USER}\",\"adminEmail\":\"${MOTECH_ADMIN_EMAIL}\",\"adminPassword\":\"${MOTECH_ADMIN_PWD}\",\"adminConfirmPassword\":\"${MOTECH_ADMIN_PWD}\",\"language\":\"cs\",\"providerName\":\"\",\"providerUrl\":\"\",\"schedulerUrl\":\"\"}" http://${MOTECH_IP}:8080/motech/module/server/startup/
+curl -H "Content-Type: application/json" -X POST -d "{\"adminLogin\":\"${MOTECH_ADMIN_USER}\",\"adminEmail\":\"${MOTECH_ADMIN_EMAIL}\",\"adminPassword\":\"${MOTECH_ADMIN_PWD}\",\"adminConfirmPassword\":\"${MOTECH_ADMIN_PWD}\",\"language\":\"cs\",\"providerName\":\"\",\"providerUrl\":\"\",\"schedulerUrl\":\"\"}" http://${MOTECH_IP}:8080/module/server/startup/
 spotter-appmgr update-login motech "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}"
diff --git a/motech/Dockerfile b/motech/Dockerfile
index ad205d5..74d283c 100644
--- a/motech/Dockerfile
+++ b/motech/Dockerfile
@@ -4,12 +4,12 @@ MAINTAINER Disassembler <disassembler@dasm.cz>
 RUN \
  # Download Motech
  wget http://nexus.motechproject.org/service/local/repositories/releases/content/org/motechproject/motech-platform-server/1.0/motech-platform-server-1.0.war -O /tmp/motech.war \
- && mkdir /srv/tomcat/webapps/motech \
- && unzip /tmp/motech.war -d /srv/tomcat/webapps/motech \
+ && mkdir /srv/tomcat/webapps/ROOT \
+ && unzip /tmp/motech.war -d /srv/tomcat/webapps/ROOT \
  # Update Postgres JDBC driver
- && rm -f /srv/tomcat/webapps/motech/WEB-INF/lib/postgresql-9.1-901.jdbc4.jar /srv/tomcat/webapps/motech/WEB-INF/bundles/postgresql-9.1-901.jdbc4.jar \
- && wget https://jdbc.postgresql.org/download/postgresql-42.2.2.jar -O /srv/tomcat/webapps/motech/WEB-INF/lib/postgresql-42.2.2.jar \
- && cp /srv/tomcat/webapps/motech/WEB-INF/lib/postgresql-42.2.2.jar /srv/tomcat/webapps/motech/WEB-INF/bundles/postgresql-42.2.2.jar \
+ && rm -f /srv/tomcat/webapps/ROOT/WEB-INF/lib/postgresql-9.1-901.jdbc4.jar /srv/tomcat/webapps/ROOT/WEB-INF/bundles/postgresql-9.1-901.jdbc4.jar \
+ && wget https://jdbc.postgresql.org/download/postgresql-42.2.2.jar -O /srv/tomcat/webapps/ROOT/WEB-INF/lib/postgresql-42.2.2.jar \
+ && cp /srv/tomcat/webapps/ROOT/WEB-INF/lib/postgresql-42.2.2.jar /srv/tomcat/webapps/ROOT/WEB-INF/bundles/postgresql-42.2.2.jar \
  # Create OS user
  && addgroup -S -g 8013 motech \
  && adduser -S -u 8013 -h /srv/tomcat -s /bin/false -g motech -G motech motech \
diff --git a/motech/srv/motech/update-url.sh b/motech/srv/motech/update-url.sh
index 3b9bcea..f71af36 100755
--- a/motech/srv/motech/update-url.sh
+++ b/motech/srv/motech/update-url.sh
@@ -3,4 +3,4 @@
 HOST="${1}"
 [ "${2}" != "443" ] && HOST="${1}:${2}"
 
-sed -i "s|^server\.url.*|server.url=https://${HOST}/motech|" /srv/motech/conf/config/motech-settings.properties
+sed -i "s|^server\.url.*|server.url=https://${HOST}|" /srv/motech/conf/config/motech-settings.properties