From 551e2a2938c6fc24a13606e5334c1a3e6d787cc8 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sun, 25 Mar 2018 23:13:55 +0200 Subject: [PATCH] Unify Motech naming and nginx configuration for spotter-appmgr --- motech.sh | 15 +++++---------- motech/Dockerfile | 4 +--- motech/etc/init.d/motech | 5 ++++- motech/etc/nginx/conf.d/motech.conf | 11 ----------- motech/srv/motech/update-ip.sh | 4 ---- motech/srv/motech/update-url.sh | 6 ++++++ 6 files changed, 16 insertions(+), 29 deletions(-) delete mode 100644 motech/etc/nginx/conf.d/motech.conf delete mode 100755 motech/srv/motech/update-ip.sh create mode 100644 motech/srv/motech/update-url.sh diff --git a/motech.sh b/motech.sh index 5d53261..65ab933 100755 --- a/motech.sh +++ b/motech.sh @@ -22,8 +22,7 @@ cp ${SOURCE_DIR}/srv/motech/conf/config-locations.properties /srv/motech/conf/co cp ${SOURCE_DIR}/srv/motech/conf/config/motech-settings.properties /srv/motech/conf/config/motech-settings.properties cp ${SOURCE_DIR}/srv/motech/conf/config/org.motechproject.motech-platform-email/motech-email.properties /srv/motech/conf/config/org.motechproject.motech-platform-email/motech-email.properties chown -R 8013:8013 /srv/motech/conf -cp ${SOURCE_DIR}/srv/motech/update-ip.sh /srv/motech/update-ip.sh -/srv/motech/update-ip.sh +cp ${SOURCE_DIR}/srv/motech/update-url.sh /srv/motech/update-url.sh # Create Motech service cp ${SOURCE_DIR}/etc/init.d/motech /etc/init.d/motech @@ -32,17 +31,13 @@ service motech start # Configure Motech admin echo `date` '- Waiting for database to be populated. This should take about a minute.' -until curl -s http://127.0.0.1:8013/motech/module/server/startup/ | grep -q adminLogin; do +until curl -s "http://motech:8080/motech/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://127.0.0.1:8013/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:8080/motech/module/server/startup/ -# Create nginx app definition -cp ${SOURCE_DIR}/etc/nginx/conf.d/motech.conf /etc/nginx/conf.d/motech.conf -service nginx reload - -# Add portal application definition -portal-app-manager motech "https://{host}:8413/motech/" "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}" +# Add application definition +spotter-appmgr add-app motech "https://motech.{host}/motech/" "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}" diff --git a/motech/Dockerfile b/motech/Dockerfile index f70d782..a04a131 100644 --- a/motech/Dockerfile +++ b/motech/Dockerfile @@ -10,8 +10,6 @@ RUN \ && 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.0.jar -O /srv/tomcat/webapps/motech/WEB-INF/lib/postgresql-42.2.0.jar \ && cp /srv/tomcat/webapps/motech/WEB-INF/lib/postgresql-42.2.0.jar /srv/tomcat/webapps/motech/WEB-INF/bundles/postgresql-42.2.0.jar \ - # Configure Tomcat port - && sed -i 's/port="8080"/port="8013"/g' /srv/tomcat/conf/server.xml \ # Create OS user && addgroup -S -g 8013 motech \ && adduser -S -u 8013 -h /srv/tomcat -s /bin/false -g motech -G motech motech \ @@ -20,7 +18,7 @@ RUN \ && rm -f /tmp/motech.war VOLUME ["/srv/tomcat/.motech"] -EXPOSE 8013 +EXPOSE 8080 USER motech WORKDIR /srv/tomcat diff --git a/motech/etc/init.d/motech b/motech/etc/init.d/motech index df4f4be..5098f07 100755 --- a/motech/etc/init.d/motech +++ b/motech/etc/init.d/motech @@ -14,11 +14,14 @@ start() { --link activemq \ --link postfix \ --link postgres \ - -p 127.0.0.1:8013:8013 \ -v /srv/motech/conf:/srv/tomcat/.motech \ motech } +start_post() { + /usr/local/bin/spotter-appmgr update-hosts motech +} + stop() { /usr/bin/docker stop motech } diff --git a/motech/etc/nginx/conf.d/motech.conf b/motech/etc/nginx/conf.d/motech.conf deleted file mode 100644 index 81a6318..0000000 --- a/motech/etc/nginx/conf.d/motech.conf +++ /dev/null @@ -1,11 +0,0 @@ -server { - listen [::]:8813 ipv6only=off; - listen [::]:8413 ssl http2 ipv6only=off; - - access_log /var/log/nginx/motech.access.log; - error_log /var/log/nginx/motech.error.log; - - location / { - proxy_pass http://127.0.0.1:8013; - } -} diff --git a/motech/srv/motech/update-ip.sh b/motech/srv/motech/update-ip.sh deleted file mode 100755 index 5588ab9..0000000 --- a/motech/srv/motech/update-ip.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -URL=$(ip route get 1 | awk '{print $NF;exit}') -sed -i "s|^server\.url.*|server.url=https://${URL}:8413/motech|" /srv/motech/conf/config/motech-settings.properties diff --git a/motech/srv/motech/update-url.sh b/motech/srv/motech/update-url.sh new file mode 100644 index 0000000..3b9bcea --- /dev/null +++ b/motech/srv/motech/update-url.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +HOST="${1}" +[ "${2}" != "443" ] && HOST="${1}:${2}" + +sed -i "s|^server\.url.*|server.url=https://${HOST}/motech|" /srv/motech/conf/config/motech-settings.properties