diff --git a/basic/srv/portal/img/Motech.png b/basic/srv/portal/img/Motech.png new file mode 100644 index 0000000..55636a8 Binary files /dev/null and b/basic/srv/portal/img/Motech.png differ diff --git a/basic/srv/portal/index.html b/basic/srv/portal/index.html index 3d6716e..8e43bf1 100644 --- a/basic/srv/portal/index.html +++ b/basic/srv/portal/index.html @@ -200,6 +200,15 @@ +
+

MotechMotech

+

Integrace zdravotnických a komunikačních služeb.

+ +
+

diaspora*diaspora*

Autonomní sociání síť s možností propojení do cizích sociálních sítí.

diff --git a/motech.sh b/motech.sh new file mode 100755 index 0000000..260f868 --- /dev/null +++ b/motech.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +SOURCE_DIR=$(realpath $(dirname "${0}"))/motech + +# Install dependencies +apt-get -y --no-install-recommends install activemq openjdk-8-jre-headless + +# Download Tomcat 8.0 +wget http://mirror.dkm.cz/apache/tomcat/tomcat-8/v8.0.47/bin/apache-tomcat-8.0.47.tar.gz -O /tmp/apache-tomcat-8.tgz +tar xf /tmp/apache-tomcat-8.tgz -C /srv +mv /srv/apache-tomcat-8.0.47 /srv/motech +rm -f /tmp/apache-tomcat-8.tgz + +# Download Motech +wget 'http://nexus.motechproject.org/service/local/artifact/maven/redirect?r=releases&g=org.motechproject&a=motech-platform-server&v=RELEASE&e=war' -O /tmp/motech.war +unzip /tmp/motech.war -d /srv/motech/webapps/motech +rm -f /tmp/motech.war + +# Update Postgres JDBC driver +rm -f /srv/motech/webapps/motech/WEB-INF/lib/postgresql-9.1-901.jdbc4.jar +rm -f /srv/motech/webapps/motech/WEB-INF/bundles/postgresql-9.1-901.jdbc4.jar +wget https://jdbc.postgresql.org/download/postgresql-42.1.4.jar -O /srv/motech/webapps/motech/WEB-INF/lib/postgresql-42.1.4.jar +cp /srv/motech/webapps/motech/WEB-INF/lib/postgresql-42.1.4.jar /srv/motech/webapps/motech/WEB-INF/bundles/postgresql-42.1.4.jar + +# Create database +export MOTECH_PWD=$(head -c 18 /dev/urandom | base64) +envsubst <${SOURCE_DIR}/tmp/motech-createdb.sql >/tmp/motech-createdb.sql +sudo -u postgres psql -f /tmp/motech-createdb.sql +rm -f /tmp/motech-createdb.sql + +# Configure ActiveMQ +cp ${SOURCE_DIR}/etc/activemq/instances-available/main/activemq.xml /etc/activemq/instances-available/main/activemq.xml +ln -s /etc/activemq/instances-available/main /etc/activemq/instances-enabled/main +systemctl restart activemq + +# Configure Motech bootstrap +mkdir -p /srv/motech/.motech/config/org.motechproject.motech-platform-email +envsubst <${SOURCE_DIR}/srv/motech/.motech/config/bootstrap.properties >/srv/motech/.motech/config/bootstrap.properties +cp ${SOURCE_DIR}/srv/motech/.motech/config-locations.properties /srv/motech/.motech/config-locations.properties +cp ${SOURCE_DIR}/srv/motech/.motech/config/motech-settings.properties /srv/motech/.motech/config/motech-settings.properties +cp ${SOURCE_DIR}/srv/motech/.motech/config/org.motechproject.motech-platform-email/motech-email.properties /srv/motech/.motech/config/org.motechproject.motech-platform-email/motech-email.properties + +# Create Motech OS user +adduser --system --group --home /srv/motech --shell /bin/false motech +chown -R motech:motech /srv/motech/ + +# Configure Tomcat +cp ${SOURCE_DIR}/srv/motech/conf/server.xml /srv/motech/conf/server.xml +cp ${SOURCE_DIR}/lib/systemd/system/motech.service /lib/systemd/system/motech.service +systemctl daemon-reload +systemctl enable motech +systemctl start motech + +# Configure Motech admin +export MOTECH_ADMIN_USER="admin" +export MOTECH_ADMIN_EMAIL="admin@example.com" +export MOTECH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) +until $(curl -s http://127.0.0.1:9081/motech/module/server/startup/ | grep -q adminLogin); do + sleep 1 +done +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:9081/motech/module/server/startup/ + +# Create nginx site definition +cp ${SOURCE_DIR}/etc/nginx/apps-available/motech /etc/nginx/apps-available/motech +ln -s /etc/nginx/apps-available/motech /etc/nginx/apps-enabled/motech + +# Restart services +systemctl restart nginx + +# Add portal application definition +portal-app-manager motech "/motech/" "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}" diff --git a/motech/etc/activemq/instances-available/main/activemq.xml b/motech/etc/activemq/instances-available/main/activemq.xml new file mode 100644 index 0000000..32286ee --- /dev/null +++ b/motech/etc/activemq/instances-available/main/activemq.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/motech/etc/nginx/apps-available/motech b/motech/etc/nginx/apps-available/motech new file mode 100644 index 0000000..0c98b6a --- /dev/null +++ b/motech/etc/nginx/apps-available/motech @@ -0,0 +1,11 @@ +location /motech { + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header Host $http_host; + proxy_set_header Proxy ""; + proxy_redirect off; + proxy_buffering off; + proxy_read_timeout 90; + proxy_connect_timeout 90; + proxy_pass http://127.0.0.1:9081/motech; +} diff --git a/motech/lib/systemd/system/motech.service b/motech/lib/systemd/system/motech.service new file mode 100644 index 0000000..d5bf666 --- /dev/null +++ b/motech/lib/systemd/system/motech.service @@ -0,0 +1,12 @@ +[Unit] +Description=Motech Tomcat 8.0 +After=network.target + +[Service] +Type=forking +ExecStart=/srv/motech/bin/startup.sh +ExecStop=/srv/motech/bin/shutdown.sh +User=motech + +[Install] +WantedBy=multi-user.target diff --git a/motech/srv/motech/.motech/config-locations.properties b/motech/srv/motech/.motech/config-locations.properties new file mode 100644 index 0000000..9871a51 --- /dev/null +++ b/motech/srv/motech/.motech/config-locations.properties @@ -0,0 +1 @@ +config.location = /srv/motech/.motech/config diff --git a/motech/srv/motech/.motech/config/bootstrap.properties b/motech/srv/motech/.motech/config/bootstrap.properties new file mode 100644 index 0000000..8836f06 --- /dev/null +++ b/motech/srv/motech/.motech/config/bootstrap.properties @@ -0,0 +1,19 @@ +jms.cache.producers=false +jms.queue.for.scheduler=QueueForScheduler +sql.url=jdbc\:postgresql\://localhost\:5432/ +jms.maxConcurrentConsumers=10 +sql.user=motech +jms.queue.for.events=QueueForEvents +jms.password= +jms.session.cache.size=10 +org.osgi.framework.storage=/srv/motech/.motech/felix-cache +motech.message.redelivery.delay=1 +jms.username= +config.source=FILE +motech.dir=/srv/motech/.motech +sql.password=${MOTECH_PWD} +sql.driver=org.postgresql.Driver +jms.concurrentConsumers=1 +jms.broker.url=tcp\://localhost\:61616 +motech.message.max.redelivery.count=3 +jms.topic.for.events=TopicForEvents diff --git a/motech/srv/motech/.motech/config/motech-settings.properties b/motech/srv/motech/.motech/config/motech-settings.properties new file mode 100644 index 0000000..61167ad --- /dev/null +++ b/motech/srv/motech/.motech/config/motech-settings.properties @@ -0,0 +1,2 @@ +system.language=en +login.mode=repository diff --git a/motech/srv/motech/.motech/config/org.motechproject.motech-platform-email/motech-email.properties b/motech/srv/motech/.motech/config/org.motechproject.motech-platform-email/motech-email.properties new file mode 100644 index 0000000..73ebdec --- /dev/null +++ b/motech/srv/motech/.motech/config/org.motechproject.motech-platform-email/motech-email.properties @@ -0,0 +1 @@ +mail.port=25 diff --git a/motech/srv/motech/conf/server.xml b/motech/srv/motech/conf/server.xml new file mode 100644 index 0000000..50d2a3a --- /dev/null +++ b/motech/srv/motech/conf/server.xml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/motech/tmp/motech-createdb.sql b/motech/tmp/motech-createdb.sql new file mode 100644 index 0000000..cc3dbfe --- /dev/null +++ b/motech/tmp/motech-createdb.sql @@ -0,0 +1,16 @@ +CREATE ROLE motech NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN ENCRYPTED PASSWORD '${MOTECH_PWD}'; +CREATE DATABASE motech; +REVOKE ALL ON DATABASE motech FROM public; +ALTER DATABASE motech OWNER TO motech; + +CREATE DATABASE motechschema; +REVOKE ALL ON DATABASE motechschema FROM public; +ALTER DATABASE motechschema OWNER TO motech; + +CREATE DATABASE motechdata; +REVOKE ALL ON DATABASE motechdata FROM public; +ALTER DATABASE motechdata OWNER TO motech; + +CREATE DATABASE motechquartz; +REVOKE ALL ON DATABASE motechquartz FROM public; +ALTER DATABASE motechquartz OWNER TO motech;