From 0d2b1158f2a59f16d6846bc46f5361a2b350ea8a Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sun, 25 Mar 2018 23:21:54 +0200 Subject: [PATCH] Unify Ushahidi naming and nginx configuration for spotter-appmgr --- ushahidi.sh | 12 ++++-------- ushahidi/Dockerfile | 2 +- ushahidi/docker/etc/nginx/nginx.conf | 2 +- ushahidi/etc/init.d/ushahidi | 9 ++++----- ushahidi/etc/nginx/conf.d/ushahidi.conf | 14 -------------- ushahidi/srv/ushahidi/update-ip.sh | 8 -------- ushahidi/srv/ushahidi/update-url.sh | 9 +++++++++ 7 files changed, 19 insertions(+), 37 deletions(-) delete mode 100644 ushahidi/etc/nginx/conf.d/ushahidi.conf delete mode 100755 ushahidi/srv/ushahidi/update-ip.sh create mode 100644 ushahidi/srv/ushahidi/update-url.sh diff --git a/ushahidi.sh b/ushahidi.sh index 8f36294..0af79c9 100755 --- a/ushahidi.sh +++ b/ushahidi.sh @@ -18,7 +18,7 @@ mkdir -p /srv/ushahidi/conf /srv/ushahidi/data chown 8014:8014 /srv/ushahidi/data envsubst <${SOURCE_DIR}/srv/ushahidi/conf/env >/srv/ushahidi/conf/env cp ${SOURCE_DIR}/srv/ushahidi/conf/config.json /srv/ushahidi/conf/config.json -cp ${SOURCE_DIR}/srv/ushahidi/update-ip.sh /srv/ushahidi/update-ip.sh +cp ${SOURCE_DIR}/srv/ushahidi/update-url.sh /srv/ushahidi/update-url.sh # Populate database docker run --rm -h ushahidi --link mariadb -v /srv/ushahidi/conf/env:/srv/ushahidi/platform/.env ushahidi /srv/ushahidi/platform/bin/phinx migrate -c /srv/ushahidi/platform/application/phinx.php @@ -34,13 +34,9 @@ cp ${SOURCE_DIR}/etc/init.d/ushahidi /etc/init.d/ushahidi rc-update add ushahidi service ushahidi start -# Create nginx app definition -cp ${SOURCE_DIR}/etc/nginx/conf.d/ushahidi.conf /etc/nginx/conf.d/ushahidi.conf -service nginx reload - # Install cron job cp ${SOURCE_DIR}/etc/periodic/15min/ushahidi /etc/periodic/15min/ushahidi -# Add portal application definition -portal-app-manager ushahidi "https://{host}:8414/" "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}" -portal-app-manager ushahidi-mobile -p clienturl "{host}:8814" +# Add application definition +spotter-appmgr add-app ushahidi "https://ushahidi.{host}/" "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}" +spotter-appmgr add-app ushahidi-mobile -p clienturl "ushahidi.{host}" diff --git a/ushahidi/Dockerfile b/ushahidi/Dockerfile index a4e3f3d..57e4d66 100644 --- a/ushahidi/Dockerfile +++ b/ushahidi/Dockerfile @@ -24,6 +24,6 @@ RUN \ COPY docker/ / VOLUME ["/srv/ushahidi/platform/application/media/uploads"] -EXPOSE 8014 +EXPOSE 8080 CMD ["s6-svscan", "/etc/services.d"] diff --git a/ushahidi/docker/etc/nginx/nginx.conf b/ushahidi/docker/etc/nginx/nginx.conf index 31a799c..03997a3 100644 --- a/ushahidi/docker/etc/nginx/nginx.conf +++ b/ushahidi/docker/etc/nginx/nginx.conf @@ -17,7 +17,7 @@ http { sendfile on; server { - listen 8014; + listen 8080; server_name localhost; root /srv/ushahidi; diff --git a/ushahidi/etc/init.d/ushahidi b/ushahidi/etc/init.d/ushahidi index db070c7..3a3ec1c 100755 --- a/ushahidi/etc/init.d/ushahidi +++ b/ushahidi/etc/init.d/ushahidi @@ -7,23 +7,22 @@ depend() { use dns logger netmount postfix } -start_pre() { - /srv/ushahidi/update-ip.sh -} - start() { /usr/bin/docker run -d --rm \ --name ushahidi \ -h ushahidi \ --link mariadb \ --link postfix \ - -p 127.0.0.1:8014:8014 \ -v /srv/ushahidi/conf/env:/srv/ushahidi/platform/.env \ -v /srv/ushahidi/conf/config.json:/srv/ushahidi/config.json \ -v /srv/ushahidi/data:/srv/ushahidi/platform/application/media/uploads \ ushahidi } +start_post() { + /usr/local/bin/spotter-appmgr update-hosts ushahidi +} + stop() { /usr/bin/docker stop ushahidi } diff --git a/ushahidi/etc/nginx/conf.d/ushahidi.conf b/ushahidi/etc/nginx/conf.d/ushahidi.conf deleted file mode 100644 index 1c83afd..0000000 --- a/ushahidi/etc/nginx/conf.d/ushahidi.conf +++ /dev/null @@ -1,14 +0,0 @@ -server { - listen [::]:8814 ipv6only=off; - listen [::]:8414 ssl http2 ipv6only=off; - - access_log /var/log/nginx/ushahidi.access.log; - error_log /var/log/nginx/ushahidi.error.log; - - location / { - proxy_set_header X-Forwarded-HTTPS $https; - proxy_set_header X-Forwarded-Server-Name $host; - proxy_set_header X-Forwarded-Server-Port $server_port; - proxy_pass http://127.0.0.1:8014; - } -} diff --git a/ushahidi/srv/ushahidi/update-ip.sh b/ushahidi/srv/ushahidi/update-ip.sh deleted file mode 100755 index 4ff60a0..0000000 --- a/ushahidi/srv/ushahidi/update-ip.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -URL=$(ip route get 1 | awk '{print $NF;exit}') - -sed -i "s|^ \"backend_url\".*| \"backend_url\": \"http://${URL}:8814/platform\",|" /srv/ushahidi/conf/config.json - -FULL_URL='\\\"https:\\\\/\\\\/'${URL}:8414'\\\\/platform\\\\/api\\\\/v3\\\\/config\\\\/data-provider\\\"' -echo 'UPDATE `config` SET `config_value` = "'${FULL_URL}'" WHERE `group_name` LIKE "data-provider" AND `config_key` LIKE "url";' | docker exec -i mariadb mysql ushahidi diff --git a/ushahidi/srv/ushahidi/update-url.sh b/ushahidi/srv/ushahidi/update-url.sh new file mode 100644 index 0000000..11df8e4 --- /dev/null +++ b/ushahidi/srv/ushahidi/update-url.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +HOST="${1}" +[ "${2}" != "443" ] && HOST="${1}:${2}" + +sed -i "s|^ \"backend_url\".*| \"backend_url\": \"https://${HOST}/platform\",|" /srv/ushahidi/conf/config.json + +API_URL='\\\"https:\\\\/\\\\/'${HOST}'\\\\/platform\\\\/api\\\\/v3\\\\/config\\\\/data-provider\\\"' +echo 'UPDATE `config` SET `config_value` = "'${API_URL}'" WHERE `group_name` LIKE "data-provider" AND `config_key` LIKE "url";' | docker exec -i mariadb mysql ushahidi