Rewrite spotter-appmgr (partial squashmerge)

This commit is contained in:
Disassembler 2018-04-29 20:48:57 +02:00
parent 19ec74de4d
commit c5e55e7f2e
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
73 changed files with 773 additions and 539 deletions

View File

@ -7,12 +7,9 @@ docker image ls | grep -q java || $(realpath $(dirname "${0}"))/java.sh
# Build Docker container
docker build -t activemq ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/activemq /etc/init.d/activemq
rc-update -u
# Configure ActiveMQ
mkdir -p /srv/activemq/data
chown -R 61616:61616 /srv/activemq/data
# Configure Solr service
cp ${SOURCE_DIR}/etc/init.d/activemq /etc/init.d/activemq
rc-update add activemq
service activemq start

View File

@ -3,8 +3,7 @@
description="ActiveMQ docker container"
depend() {
need docker net
use dns logger netmount
need docker
}
start() {

View File

@ -27,20 +27,23 @@ cp ${SOURCE_DIR}/etc/conf.d/ntpd /etc/conf.d/ntpd
# Create a self-signed certificate
mkdir /etc/ssl/private
openssl req -x509 -new -out /etc/ssl/certs/services.pem -keyout /etc/ssl/private/services.key -nodes -days 3654 -subj "/CN=$(hostname)"
openssl req -x509 -new -out /etc/ssl/certs/services.pem -keyout /etc/ssl/private/services.key -nodes -days 7305 -subj "/CN=$(hostname)"
chmod 640 /etc/ssl/private/services.key
# Configure acme.sh
cp ${SOURCE_DIR}/usr/local/bin/update-acme.sh /usr/local/bin/update-acme.sh
/usr/local/bin/update-acme.sh
# Configure nginx
cp ${SOURCE_DIR}/etc/nginx/nginx.conf /etc/nginx/nginx.conf
# Download and configure acme.sh
mkdir /etc/acme.sh.d
wget https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh -O /usr/bin/acme.sh
sed -i 's|$HOME/.$PROJECT_NAME|/etc/acme.sh.d|' /usr/bin/acme.sh
cp ${SOURCE_DIR}/etc/periodic/daily/acme-sh /etc/periodic/daily/acme-sh
chmod +x /usr/bin/acme.sh
# Copy Spotter resources
mkdir /etc/spotter
cp ${SOURCE_DIR}/etc/spotter/apps.json /etc/spotter/apps.json
cp ${SOURCE_DIR}/usr/local/bin/spotter-appmgr /usr/local/bin/spotter-appmgr
cp ${SOURCE_DIR}/srv/config.json /srv/config.json
cp ${SOURCE_DIR}/usr/bin/spotter-appmgr /usr/bin/spotter-appmgr
cp -r ${SOURCE_DIR}/srv/portal /srv/portal
# Configure services

View File

@ -36,7 +36,5 @@ start_pre() {
}
start_post() {
until [ -e /var/run/docker.sock ]; do
usleep 100000
done
ewaitfile 1 /var/run/docker.sock
}

View File

@ -0,0 +1,3 @@
#!/bin/sh
[ -x /usr/bin/acme.sh ] && /usr/bin/acme.sh --cron >/dev/null

View File

@ -1 +0,0 @@
{"_": {"domain": "spotter.vm", "port": "443"}, "cluster-spotter": {}}

134
basic/srv/config.json Normal file
View File

@ -0,0 +1,134 @@
{
"apps":{
"ckan":{
"host":"ckan",
"login":"N/A",
"password":"N/A",
"tiles":[],
"tiles-shown":false
},
"crisiscleanup":{
"host":"cc",
"login":"N/A",
"password":"N/A",
"tiles":[],
"tiles-shown":false
},
"cts":{
"host":"cts",
"login":"N/A",
"password":"N/A",
"tiles":[],
"tiles-shown":false
},
"frontlinesms":{
"host":"sms",
"login":"N/A",
"password":"N/A",
"tiles":[],
"tiles-shown":false
},
"gnuhealth":{
"host":"gh",
"login":"N/A",
"password":"N/A",
"tiles":["gnuhealth-clients"],
"tiles-shown":false
},
"kanboard":{
"host":"kb",
"login":"N/A",
"password":"N/A",
"tiles":["kanboard-mobile"],
"tiles-shown":false
},
"mifosx":{
"host":"mifosx",
"login":"N/A",
"password":"N/A",
"tiles":["mifosx-mobile"],
"tiles-shown":false
},
"motech":{
"host":"motech",
"login":"N/A",
"password":"N/A",
"tiles":[],
"tiles-shown":false
},
"opendatakit":{
"host":"odk",
"login":"N/A",
"password":"N/A",
"tiles":["opendatakit-clients"],
"tiles-shown":false
},
"opendatakit-build":{
"host":"odkbuild",
"login":"N/A",
"password":"N/A",
"tiles":[],
"tiles-shown":false
},
"openmapkit":{
"host":"omk",
"login":"N/A",
"password":"N/A",
"tiles":["geoodk-clients", "openmapkit-clients"],
"tiles-shown":false
},
"pandora":{
"host":"pandora",
"login":"N/A",
"password":"N/A",
"tiles":[],
"tiles-shown":false
},
"sahana":{
"host":"sahana",
"login":"N/A",
"password":"N/A",
"tiles":[],
"tiles-shown":false
},
"sahana-demo":{
"host":"sahana-demo",
"login":"N/A",
"password":"N/A",
"tiles":[],
"tiles-shown":false
},
"sambro":{
"host":"sambro",
"login":"N/A",
"password":"N/A",
"tiles":["sambro-mobile"],
"tiles-shown":false
},
"seeddms":{
"host":"dms",
"login":"N/A",
"password":"N/A",
"tiles":[],
"tiles-shown":false
},
"sigmah":{
"host":"sigmah",
"login":"N/A",
"password":"N/A",
"tiles":[],
"tiles-shown":false
},
"ushahidi":{
"host":"ush",
"login":"N/A",
"password":"N/A",
"tiles":["ushahidi-mobile"],
"tiles-shown":false
}
},
"host":{
"domain":"spotter.vm",
"port": "443"
}
}

View File

@ -50,7 +50,7 @@ header p {
margin: 0px;
}
.c, .c2 {
.c {
background-color: white;
position: relative;
min-width: 365px;
@ -62,9 +62,6 @@ header p {
margin-right: 13px;
border: solid 1px black;
padding: 10px;
}
.c {
display: none;
}
@ -73,6 +70,10 @@ header p {
width: 95%;
}
.visible {
display: initial;
}
.ico {
margin-right: 5px;
width: 20px;

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="utf-8">
<meta name="author" content="TS">
<meta name="copyright" content="page is under CC BY-NC-ND 3.0 CZ">
<meta name="generator" content="Spotter.ngo">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Chyba</title>
</head>
<body>
<h1>Chyba spojení</h1>
<p>Aplikace, ke které se pokoušíte připojit, není dostupná. Nejspíše byla vypnuta správcem serveru.</p>
</body>
</html>

View File

@ -19,7 +19,7 @@
</header>
<div class="c c2" id="sahana">
<h2><a href="#"><img src="img/EDEN.png" alt="Sahana EDEN" title="Sahana EDEN">Sahana EDEN</a></h2>
<h2><a href="https://sahana.{host}"><img src="img/EDEN.png" alt="Sahana EDEN" title="Sahana EDEN">Sahana EDEN</a></h2>
<p><strong>Registr kontaktů</strong> asociací, organizací, jednotek zaměstnanců, dobrovolníků, <strong>Registr prostředků</strong>, materiálních zdrojů určených pro činnost v krizových situacích, <strong>logistika</strong> krizového zboží ve skladištích, úkrytech, <strong>organizace lidských zdrojů</strong>, diobrovolníků, <strong>mapová vizualizace</strong> pro lokalizaci a popis krizové události a <strong>mnoho dalších funkcí</strong>.</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -28,7 +28,7 @@
</div>
<div class="c" id="sahana-demo">
<h2><a href="#"><img src="img/EDEN.png" alt="Sahana EDEN DEMO" title="Sahana EDEN DEMO">Sahana EDEN DEMO</a></h2>
<h2><a href="https://sahana-demo.{host}"><img src="img/EDEN.png" alt="Sahana EDEN DEMO" title="Sahana EDEN DEMO">Sahana EDEN DEMO</a></h2>
<p>Přístup určený k bezpečnému vyzkoušení aplikace. Zde můžete přidávat i mazat testovací data.</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -37,7 +37,7 @@
</div>
<div class="c" id="sambro">
<h2><a href="#"><img src="img/EDEN.png" alt="Sahana EDEN SAMBRO" title="Sahana EDEN SAMBRO">Sahana EDEN SAMBRO</a></h2>
<h2><a href="https://sambro.{host}"><img src="img/EDEN.png" alt="Sahana EDEN SAMBRO" title="Sahana EDEN SAMBRO">Sahana EDEN SAMBRO</a></h2>
<p>Samostatná instance Sahana EDEN s šablonou SAMBRO.</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -52,12 +52,12 @@
<a href="https://play.google.com/store/apps/details?id=io.sahana.sambro.mobile"><img src="img/android.png" class="ico" alt="Android">Android 4.0 a vyšší</a>
</p>
<ul>
<li><strong>URL:</strong> <span class="clienturl"></span></li>
<li><strong>URL:</strong> <span class="clienturl">https://sambro.{host}/eden/</span></li>
</ul>
</div>
<div class="c" id="ccleanup">
<h2><a href="#"><img src="img/Crisis_Cleanup.png" alt="Crisis Cleanup" title="Crisis Cleanup">Crisis Cleanup</a></h2>
<div class="c" id="crisiscleanup">
<h2><a href="https://cc.{host}"><img src="img/Crisis_Cleanup.png" alt="Crisis Cleanup" title="Crisis Cleanup">Crisis Cleanup</a></h2>
<p><strong>Mapování krizové pomoci</strong> při odstraňování následků katastrof a koordinaci práce. Jde o majetek, ne o lidi.</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -66,7 +66,7 @@
</div>
<div class="c" id="ckan">
<h2><a href="#"><img src="img/CKAN.png" alt="CKAN" title="CKAN">CKAN</a></h2>
<h2><a href="https://ckan.{host}"><img src="img/CKAN.png" alt="CKAN" title="CKAN">CKAN</a></h2>
<p><strong>Repository</strong> management a datová analýza pro vytváření otevřených dat.</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -74,27 +74,27 @@
</ul>
</div>
<div class="c" id="odkbuild">
<h2><a href="#"><img src="img/ODK.png" alt="Open Data Kit" title="Open Data Kit">ODK Build</a></h2>
<div class="c" id="opendatakit-build">
<h2><a href="https://odkbuild.{host}"><img src="img/ODK.png" alt="Open Data Kit" title="Open Data Kit">ODK Build</a></h2>
<p><strong>Sběr dat s pomocí smartphone</strong>.<br>Aplikace pro návrh formulářů<br>
<p><a href="http://opendatakit.org/xiframe/">XLSForm</a> - online konverter XLS.<br>
<a href="https://opendatakit.org/downloads/download-info/odk-formuploader/"><img src="img/java.png" class="ico" alt="ODK Form Uploader">ODK Form Uploader</a><br>
<a href="https://opendatakit.org/downloads/download-info/odk-validate-2/"><img src="img/java.png" class="ico" alt="ODK Validate">ODK Validate</a></p>
</div>
<div class="c" id="odk-clients">
<div class="c" id="opendatakit-clients">
<h2><a href="#"><img src="img/ODK_Collect.png" alt="Open Data Kit" title="Open Data Kit">ODK Collect</a></h2>
<p>Mobilní aplikace<br>
<a href="https://play.google.com/store/apps/details?id=org.odk.collect.android"><img src="img/android.png" class="ico" alt="ODK Collect">ODK Collect pro Android</a><br>
<a href="https://opendatakit.org/downloads/download-info/odk-briefcase/"><img src="img/java.png" class="ico" alt="ODK Briefcase">ODK Briefcase</a><br>
</p>
<ul>
<li><strong>URL:</strong> <span class="clienturl"></span></li>
<li><strong>URL:</strong> <span class="clienturl">https://odk.{host}/aggregate</span></li>
</ul>
</div>
<div class="c" id="odk">
<h2><a href="#"><img src="img/ODK.png" alt="Open Data Kit" title="Open Data Kit">ODK Aggregate</a></h2>
<div class="c" id="opendatakit">
<h2><a href="https://odk.{host}"><img src="img/ODK.png" alt="Open Data Kit" title="Open Data Kit">ODK Aggregate</a></h2>
<p><strong>Sběr dat s pomocí smartphone</strong>.<br>
<a href="http://geoodk.com">GeoODK Collect</a> - náhrada papírových dotazníků smartphonem.
</p>
@ -104,8 +104,8 @@
</ul>
</div>
<div class="c" id="omk">
<h2><a href="#"><img src="img/OMK.png" alt="Open Map Kit" title="Open Map Kit">OpenMapKit Server</a></h2>
<div class="c" id="openmapkit">
<h2><a href="https://omk.{host}"><img src="img/OMK.png" alt="Open Map Kit" title="Open Map Kit">OpenMapKit Server</a></h2>
<p><strong>Sběr dat s pomocí smartphone</strong>.<br>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -119,23 +119,23 @@
<a href="https://play.google.com/store/apps/details?id=com.geoodk.collect.android"><img src="img/android.png" class="ico" alt="GeoODK Collect">GeoODK Collect pro Android</a>
</p>
<ul>
<li><strong>URL:</strong> <span class="clienturl"></span></li>
<li><strong>URL:</strong> <span class="clienturl">https://omk.{host}</span></li>
</ul>
</div>
<div class="c" id="omk-clients">
<div class="c" id="openmapkit-clients">
<h2><a href="#"><img src="img/OMK.png" alt="Open Map Kit" title="Open Map Kit">OpenMapKit</a></h2>
<p>Mobilní aplikace<br>
<a href="https://play.google.com/store/apps/details?id=org.odk.collect.android"><img src="img/android.png" class="ico" alt="ODK Collect">ODK Collect pro Android</a><br>
<a href="https://play.google.com/store/apps/details?id=org.redcross.openmapkit"><img src="img/android.png" class="ico" alt="Android">OpenMapKit pro Android 4.1 a vyšší</a>
</p>
<ul>
<li><strong>URL:</strong> <span class="clienturl"></span></li>
<li><strong>URL:</strong> <span class="clienturl">https://omk.{host}</span></li>
</ul>
</div>
<div class="c" id="flsms">
<h2><a href="#"><img src="img/FrontlineSMS.png" alt="FrontlineSMS" title="FrontlineSMS">FrontlineSMS</a></h2>
<div class="c" id="frontlinesms">
<h2><a href="https://sms.{host}"><img src="img/FrontlineSMS.png" alt="FrontlineSMS" title="FrontlineSMS">FrontlineSMS</a></h2>
<p><strong>SMS messaging</strong> přes veřejné datové brány</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -144,7 +144,7 @@
</div>
<div class="c" id="seeddms">
<h2><a href="#"><img src="img/SeedDMS.png" alt="SeedDMS" title="SeedDMS">SeedDMS</a></h2>
<h2><a href="https://dms.{host}"><img src="img/SeedDMS.png" alt="SeedDMS" title="SeedDMS">SeedDMS</a></h2>
<p><strong>Dokument management</strong> na dokumentaci a projektovou dokumentaci</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -153,7 +153,7 @@
</div>
<div class="c" id="pandora">
<h2><a href="#"><img src="img/Pandora.png" alt="Pan.do/ra" title="Pan.do/ra">Pan.do/ra</a></h2>
<h2><a href="https://pandora.{host}"><img src="img/Pandora.png" alt="Pan.do/ra" title="Pan.do/ra">Pan.do/ra</a></h2>
<p><strong>Media management</strong> na foto a video z krizové události. Tvorba metadat, komentářů, lokalizace v čase a na mapě.</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -162,7 +162,7 @@
</div>
<div class="c" id="ushahidi">
<h2><a href="#"><img src="img/Ushahidi.png" alt="Ushahidi" title="Ushahidi">Ushahidi</a></h2>
<h2><a href="https://ush.{host}"><img src="img/Ushahidi.png" alt="Ushahidi" title="Ushahidi">Ushahidi</a></h2>
<p>Reakce na krizovou událost. Shromažďujte zprávy od obětí a pracovníků v terénu prostřednictvím SMS, e-mailu, webu, Twitteru.</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -177,7 +177,7 @@
<a href="https://play.google.com/store/apps/details?id=com.ushahidi.mobile"><img src="img/android.png" class="ico" alt="Android">Android 4.4 a vyšší</a>
</p>
<ul>
<li><strong>URL:</strong> <span class="clienturl"></span></li>
<li><strong>URL:</strong> <span class="clienturl">ushahidi.{host}</span></li>
</ul>
</div>
@ -189,7 +189,7 @@
</div>
<div class="c" id="kanboard">
<h2><a href="#"><img src="img/Kanboard.png" alt="Kanboard" title="Kanboard">Kanboard</a></h2>
<h2><a href="https://kb.{host}"><img src="img/Kanboard.png" alt="Kanboard" title="Kanboard">Kanboard</a></h2>
<p>Usnadňuje tvorbu a řízení projektů s pomocí Kanban metodiky.</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -204,12 +204,12 @@
<a href="https://f-droid.org/packages/in.andres.kandroid/"><img src="img/android.png" class="ico" alt="Android">Kandroid pro Android 4.2 a vyšší</a>
</p>
<ul>
<li><strong>URL:</strong> <span class="clienturl"></span></li>
<li><strong>URL:</strong> <span class="clienturl">https://kb.{host}</span></li>
</ul>
</div>
<div class="c" id="cts">
<h2><a href="#"><img src="img/CTS.png" alt="CTS" title="CTS">CTS</a></h2>
<h2><a href="https://cts.{host}"><img src="img/CTS.png" alt="CTS" title="CTS">CTS</a></h2>
<p>Logistika hmotné pomoci pro humanitární potřeby.</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -218,7 +218,7 @@
</div>
<div class="c" id="gnuhealth">
<h2><a href="#"><img src="img/GNU_Health.png" alt="GNU Health" title="GNU Health">GNU Health</a></h2>
<h2><a href="https://gh.{host}"><img src="img/GNU_Health.png" alt="GNU Health" title="GNU Health">GNU Health</a></h2>
<p>Zdravotní a nemocniční informační systém.</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -235,12 +235,12 @@
<a href="https://downloads.tryton.org/4.2/tryton-last.tar.gz"><img src="img/Linux.png" class="ico" alt="Linux">Linux</a>
</p>
<ul>
<li><strong>URL:</strong> <span class="clienturl"></span></li>
<li><strong>URL:</strong> <span class="clienturl">gh.{host}</span></li>
</ul>
</div>
<div class="c" id="sigmah">
<h2><a href="#"><img src="img/Sigmah.png" alt="Sigmah" title="Sigmah">Sigmah</a></h2>
<h2><a href="https://sigmah.{host}"><img src="img/Sigmah.png" alt="Sigmah" title="Sigmah">Sigmah</a></h2>
<p>Rozpočtování získávání finančních prostředků.</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -249,7 +249,7 @@
</div>
<div class="c" id="motech">
<h2><a href="#"><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>
@ -258,7 +258,7 @@
</div>
<div class="c" id="mifosx">
<h2><a href="#"><img src="img/MifosX.png" alt="Mifos X" title="Mifos X">Mifos X</a></h2>
<h2><a href="https://mifosx.{host}"><img src="img/MifosX.png" alt="Mifos X" title="Mifos X">Mifos X</a></h2>
<p>Nástroj na rozvojovou, humanitární pomoc a mikrofinancování.</p>
<ul>
<li><strong>Login:</strong> <span class="login"></span></li>
@ -272,7 +272,7 @@
<a href="https://play.google.com/store/apps/details?id=com.mifos.mifosxdroid"><img src="img/android.png" class="ico" alt="KanBoard">Mifos X client pro Android 3.0 a vyšší</a><br>
</p>
<ul>
<li><strong>URL:</strong> <span class="clienturl"></span></li>
<li><strong>URL:</strong> <span class="clienturl">mifosx.{host}</span></li>
<li><strong>Tenant ID:</strong> <span>default</span></li>
</ul>
</div>
@ -296,7 +296,7 @@
<p><strong>Portable Open Street Map</strong> - softwarový balík na offline používání OpenStreet Map v samostatné virtuální image.</p>
</div>
<div class="c" id="cluster-spotter">
<div class="c visible" id="cluster-spotter">
<h2><a href="http://spotter.ngo"><img src="img/cluster_spotter.png" alt="Cluster Spotter" title="Cluster Spotter">Cluster Spotter</a></h2>
<p>Info o Misi a Vizi projektu, včetně kontaktu. Zachovejte data bezpečná a neposkytujte je nepovolaným osobám.<br>
<small>CC 4.0 CZ by <a href="http://trendspotter.cz">TS</a>. Content is based on PD, CC, GNU/GPL. Brand names, trademarks belong to their respective holders.</small>

View File

@ -1,13 +1,21 @@
$(function() {
$.getJSON('apps.json', function(data) {
var host = data._.domain + (data._.port != '443' ? ':'+data._.port : '')
$.each(data, function(id, props) {
var div = $('#'+id).show();
if (props.hasOwnProperty('url'))
div.find('h2 a').attr('href', props.url.replace('{host}', host));
$.each(props, function(key, value) {
div.find('.'+key).text(value.replace('{host}', host));
});
$.getJSON('config.json', function(data) {
$.each(data.apps, function(app, appdata) {
if (!appdata['tiles-shown'])
return true;
var div = $('#'+app).show();
div.find('.login').text(appdata.login);
div.find('.password').text(appdata.password);
$.each(appdata.tiles, function(tile) {
$('#'+tile).show();
});
});
var host = data.host.domain + (data.host.port != '443' ? ':'+data.host.port : '')
$('a').each(function(){
$(this).attr('href', $(this).attr('href').replace('{host}', host));
});
$('span').each(function(){
$(this).text($(this).text().replace('{host}', host));
});
});
});

317
basic/usr/bin/spotter-appmgr Executable file
View File

@ -0,0 +1,317 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import argparse
import json
import os
import subprocess
CONF_FILE = '/srv/config.json'
ISSUE_FILE = '/etc/issue'
NGINX_DIR = '/etc/nginx/conf.d'
NGINX_TEMPLATE = '''server {{
listen [::]:{port} ssl http2;
server_name {host}.{domain};
access_log /var/log/nginx/{app}.access.log;
error_log /var/log/nginx/{app}.error.log;
location / {{
proxy_pass http://{ip}:8080;
}}
error_page 502 /errror.html;
location /error.html {{
root /srv/portal;
}}
}}
'''
NGINX_DEFAULT_TEMPLATE = '''server {{
listen [::]:80 default_server ipv6only=off;
location / {{
return 301 https://$host:{port}$request_uri;
}}
location /.well-known/acme-challenge/ {{
root /etc/acme.sh.d;
}}
}}
server {{
listen [::]:{port} ssl http2 default_server ipv6only=off;
root /srv/portal;
index index.html;
location / {{
try_files $uri $uri/ =404;
}}
location /config.json {{
alias /srv/config.json;
}}
error_page 404 /error.html;
}}
'''
ISSUE_TEMPLATE = '''
\x1b[1;32m _____ _ _ __ ____ __
/ ____| | | | | \\\\ \\\\ / / \\\\/ |
| (___ _ __ ___ | |_| |_ ___ _ _\\\\ \\\\ / /| \\\\ / |
\\\\___ \\\\| '_ \\\\ / _ \\\\| __| __/ _ \\\\ '__\\\\ \\\\/ / | |\\\\/| |
____) | |_) | (_) | |_| || __/ | \\\\ / | | | |
|_____/| .__/ \\\\___/ \\\\__|\\\\__\\\\___|_| \\\\/ |_| |_|
| |
|_|\x1b[0m
\x1b[1;33mUPOZORNĚNÍ:\x1b[0m Neoprávněný přístup k tomuto zařízení je zakázán.
Musíte mít výslovné oprávnění k přístupu nebo konfiguraci tohoto zařízení.
Neoprávněné pokusy a kroky k přístupu nebo používání tohoto systému mohou mít
za následek občanské nebo trestní sankce.
\x1b[1;33mCAUTION:\x1b[0m Unauthozired access to this device is prohibited.
You must have explicit, authorized permission to access or configure this
device. Unauthorized attempts and actions to access or use this system may
result in civil or criminal penalties.
Pro přístup k aplikacím otevřete URL \x1b[1mhttps://{host}\x1b[0m ve Vašem
internetovém prohlížeči.
\x1b[0;30m
'''
class SpotterManager:
def __init__(self):
# Load JSON configuration
with open(CONF_FILE, 'r') as f:
self.conf = json.load(f)
self.domain = self.conf['host']['domain']
self.port = self.conf['host']['port']
def save_conf(self):
# Save a sorted JSON configuration object with indentation
with open(CONF_FILE, 'w') as f:
json.dump(self.conf, f, sort_keys=True, indent=4)
def update_login(self, app, login, password):
# Update login and password for an app in the configuration
if login is not None:
self.conf['apps'][app]['login'] = login
if password is not None:
self.conf['apps'][app]['password'] = password
self.save_conf()
def show_tiles(self, app):
# Update tiles-shown for the app in the configuration
self.conf['apps'][app]['tiles-shown'] = True
self.save_conf()
def hide_tiles(self, app):
# Update tiles-shown for the app in the configuration
self.conf['apps'][app]['tiles-shown'] = False
self.save_conf()
def start_app(self, app):
# Start the actual app service
subprocess.call(['/sbin/service', app, 'start'])
def stop_app(self, app):
# Stop the actual app service
subprocess.call(['/sbin/service', app, 'stop'])
# Stop the app service's dependencies if they are not used by any other running app
deps = self.build_deps_tree()
for dep in self.get_app_deps(app):
if False not in [self.is_app_started(d) for d in deps[dep]]:
subprocess.call(['/sbin/service', dep, 'stop'])
def build_deps_tree(self):
# Fisrt, build a dictionary of {app: [needs]}
needs = {}
for app in self.conf['apps']:
needs[app] = self.get_app_deps(app)
# Then reverse it to {need: [apps]}
deps = {}
for app, need in needs.iteritems():
for n in need:
deps.setdefault(n, []).append(app)
return deps
def get_app_deps(self, app):
# Get "needs" line from init script and split it to list, skipping first two elements (docker, net)
try:
with open(os.path.join('/etc/init.d', app), 'r') as f:
return [l.split()[2:] for l in f.readlines() if l.startswith('\tneed')][0]
except:
return []
def is_app_started(self, app):
# Check OpenRC service status without calling any binary
return os.path.exists(os.path.join('/run/openrc/started', app))
def enable_autostart(self, app):
# Add the app to OpenRC default runlevel
subprocess.call(['/sbin/rc-update', 'add', app])
def disable_autostart(self, app):
# Remove the app from OpenRC default runlevel
subprocess.call(['/sbin/rc-update', 'del', app])
def register_proxy(self, app):
# Rebuild nginx configuration using an actual IP of referenced app container
with open(os.path.join(NGINX_DIR, '{}.conf'.format(app)), 'w') as f:
f.write(NGINX_TEMPLATE.format(app=app, host=self.conf['apps'][app]['host'], ip=self.get_container_ip(app), domain=self.domain, port=self.port))
subprocess.call(['/sbin/service', 'nginx', 'reload'])
def unregister_proxy(self, app):
# Remove nginx configuration to prevent proxy mismatch when the container IP is reassigned to another container
nginx_conf = os.path.join(NGINX_DIR, '{}.conf'.format(app))
if os.path.exists(nginx_conf):
os.unlink(nginx_conf)
subprocess.call(['/sbin/service', 'nginx', 'reload'])
def get_container_ip(self, app):
# Return an IP address of a container. If the container is not running, return localhost address instead
try:
return subprocess.check_output(['/usr/bin/docker', 'inspect', '-f', '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}', app]).strip()
except:
return '127.0.0.1'
def update_domain(self, domain, port):
self.domain = self.conf['host']['domain'] = domain
self.port = self.conf['host']['port'] = port
self.save_conf()
self.rebuild_nginx()
self.rebuild_issue()
self.restart_apps()
def rebuild_nginx(self):
# Remove all nginx config files to prevent errors during reloads invoked by app restarts
for f in os.listdir(NGINX_DIR):
os.unlink(os.path.join(NGINX_DIR, f))
# Rebuild nginx config for the portal app and restart nginx to properly bind the new listen port
with open(os.path.join(NGINX_DIR, 'default.conf'), 'w') as f:
f.write(NGINX_DEFAULT_TEMPLATE.format(port=self.port))
subprocess.call(['/sbin/service', 'nginx', 'restart'])
def rebuild_issue(self):
# Compile the HTTPS host displayed in terminal banner
host = self.domain
# If the dummy host is used, take an IP address of a primary interface instead
if self.domain == 'spotter.vm':
host = subprocess.check_output(['ip', 'route', 'get', '1']).split()[-1]
# Show port number only when using the non-default HTTPS port
if self.port != '443':
host = ':{}'.format(self.port)
# Rebuild the terminal banner
with open(ISSUE_FILE, 'w') as f:
f.write(ISSUE_TEMPLATE.format(host=host))
def restart_apps(self):
for app in self.conf['apps']:
# Check if a script for internal update of URL in the app exists and is executable and run it
script_path = os.path.join('/srv', app, 'update-url.sh')
if os.path.exists(script_path) and os.access(script_path, os.X_OK):
subprocess.call([script_path, '{}.{}'.format(self.conf['apps'][app]['host'], self.domain), self.port])
# If the app is currently running, restart the app service
if self.is_app_started(app):
subprocess.call(['/sbin/service', app, 'restart'])
def request_cert(self, email):
# Compile an acme.sh command for certificate requisition
cmd = ['/usr/bin/acme.sh', '--issue', '-d', self.domain]
for app in self.conf['apps']:
cmd += ['-d', '{}.{}'.format(self.conf['apps'][app]['host'], self.domain)]
cmd += ['-w', '/etc/acme.sh.d', '--accountemail', email]
# Request the certificate. If the requisition command fails, CalledProcessError will be raised
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
# Install the issued certificate
subprocess.call(['/usr/bin/acme.sh', '--installcert', '-d', self.domain, '--keypath', '/etc/ssl/private/services.key', '--fullchainpath', '/etc/ssl/certs/services.pem', '--reloadcmd', 'service nginx reload'])
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Spotter VM application manager')
subparsers = parser.add_subparsers()
parser_update_login = subparsers.add_parser('update-login', help='Updates application login')
parser_update_login.set_defaults(action='update-login')
parser_update_login.add_argument('app', help='Application name')
parser_update_login.add_argument('login', help='Administrative login')
parser_update_login.add_argument('password', help='Administrative password')
parser_show_tiles = subparsers.add_parser('show-tiles', help='Shows application tiles in Portal')
parser_show_tiles.set_defaults(action='show-tiles')
parser_show_tiles.add_argument('app', help='Application name')
parser_hide_tiles = subparsers.add_parser('hide-tiles', help='Hides application tiles in Portal')
parser_hide_tiles.set_defaults(action='hide-tiles')
parser_hide_tiles.add_argument('app', help='Application name')
parser_start_app = subparsers.add_parser('start-app', help='Start application including it\'s dependencies')
parser_start_app.set_defaults(action='start-app')
parser_start_app.add_argument('app', help='Application name')
parser_stop_app = subparsers.add_parser('stop-app', help='Stops application including it\'s dependencies if they are not used by another running application')
parser_stop_app.set_defaults(action='stop-app')
parser_stop_app.add_argument('app', help='Application name')
parser_enable_autostart = subparsers.add_parser('enable-autostart', help='Enables application autostart')
parser_enable_autostart.set_defaults(action='enable-autostart')
parser_enable_autostart.add_argument('app', help='Application name')
parser_disable_autostart = subparsers.add_parser('disable-autostart', help='Disables application autostart')
parser_disable_autostart.set_defaults(action='disable-autostart')
parser_disable_autostart.add_argument('app', help='Application name')
parser_register_proxy = subparsers.add_parser('register-proxy', help='Rebuilds nginx proxy target for an application container')
parser_register_proxy.set_defaults(action='register-proxy')
parser_register_proxy.add_argument('app', help='Application name')
parser_unregister_proxy = subparsers.add_parser('unregister-proxy', help='Removes nginx proxy target for an application container')
parser_unregister_proxy.set_defaults(action='unregister-proxy')
parser_unregister_proxy.add_argument('app', help='Application name')
parser_update_domain = subparsers.add_parser('update-domain', help='Rebuilds domain structure of VM with new domain name and new HTTPS port')
parser_update_domain.set_defaults(action='update-domain')
parser_update_domain.add_argument('domain', help='Domain name')
parser_update_domain.add_argument('port', help='HTTPS port')
parser_request_cert = subparsers.add_parser('request-cert', help='Requests and installs Let\'s Encrypt certificate for currently set domain')
parser_request_cert.set_defaults(action='request-cert')
parser_request_cert.add_argument('email', help='Email address to receive certificate notifications')
args = parser.parse_args()
sm = SpotterManager()
if args.action == 'update-login':
sm.update_login(args.app, args.login, args.password)
elif args.action == 'show-tiles':
sm.show_tiles(args.app)
elif args.action == 'hide-tiles':
sm.hide_tiles(args.app)
elif args.action == 'start-app':
sm.start_app(args.app)
elif args.action == 'stop-app':
sm.stop_app(args.app)
elif args.action == 'enable-autostart':
sm.enable_autostart(args.app)
elif args.action == 'disable-autostart':
sm.disable_autostart(args.app)
elif args.action == 'register-proxy':
sm.register_proxy(args.app)
elif args.action == 'unregister-proxy':
sm.unregister_proxy(args.app)
elif args.action == 'update-domain':
sm.update_domain(args.domain, args.port)
elif args.action == 'request-cert':
sm.request_cert(args.email)

View File

@ -1,197 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import argparse
import json
import os
import subprocess
CONF_FILE = '/etc/spotter/apps.json'
ISSUE_FILE = '/etc/issue'
NGINX_DIR = '/etc/nginx/conf.d'
NGINX_TEMPLATE = '''server {{
listen [::]:{port} ssl http2;
server_name {app}.{domain};
access_log /var/log/nginx/{app}.access.log;
error_log /var/log/nginx/{app}.error.log;
location / {{
proxy_pass http://{ip}:8080;
}}
}}
'''
NGINX_DEFAULT_TEMPLATE = '''server {{
listen [::]:80 default_server ipv6only=off;
location / {{
return 301 https://$host:{port}$request_uri;
}}
location /.well-known/acme-challenge/ {{
root /etc/acme.sh.d;
}}
}}
server {{
listen [::]:{port} ssl http2 default_server ipv6only=off;
root /srv/portal;
index index.html;
location / {{
try_files $uri $uri/ =404;
}}
location /apps.json {{
alias /etc/spotter/apps.json;
}}
}}
'''
ISSUE_TEMPLATE = '''
\x1b[1;32m _____ _ _ __ ____ __
/ ____| | | | | \\\\ \\\\ / / \\\\/ |
| (___ _ __ ___ | |_| |_ ___ _ _\\\\ \\\\ / /| \\\\ / |
\\\\___ \\\\| '_ \\\\ / _ \\\\| __| __/ _ \\\\ '__\\\\ \\\\/ / | |\\\\/| |
____) | |_) | (_) | |_| || __/ | \\\\ / | | | |
|_____/| .__/ \\\\___/ \\\\__|\\\\__\\\\___|_| \\\\/ |_| |_|
| |
|_|\x1b[0m
\x1b[1;33mUPOZORNĚNÍ:\x1b[0m Neoprávněný přístup k tomuto zařízení je zakázán.
Musíte mít výslovné oprávnění k přístupu nebo konfiguraci tohoto zařízení.
Neoprávněné pokusy a kroky k přístupu nebo používání tohoto systému mohou mít
za následek občanské nebo trestní sankce.
\x1b[1;33mCAUTION:\x1b[0m Unauthozired access to this device is prohibited.
You must have explicit, authorized permission to access or configure this
device. Unauthorized attempts and actions to access or use this system may
result in civil or criminal penalties.
Pro přístup k aplikacím otevřete URL \x1b[1mhttps://{host}/\x1b[0m ve Vašem
internetovém prohlížeči.
\x1b[0;30m
'''
class SpotterManager:
def __init__(self):
self.conf = {}
with open(CONF_FILE, 'r') as f:
self.conf = json.load(f)
self.domain = self.conf["_"]["domain"]
self.port = self.conf["_"]["port"]
def save_conf(self):
with open(CONF_FILE, 'w') as f:
json.dump(self.conf, f)
def add_app(self, app, args):
self.add_app_to_conf(app, args)
if args.url:
self.update_app_conf(app)
def add_app_to_conf(self, app, args):
self.conf[app] = {}
for key in ('url', 'login', 'password'):
value = getattr(args, key)
if value:
self.conf[app][key] = value
if args.property:
for key, value in args.property:
self.conf[app][key] = value
self.save_conf()
def update_app_conf(self, app):
script_path = os.path.join('/srv', app, 'update-url.sh')
if os.path.exists(script_path) and os.access(script_path, os.X_OK):
host = '{}.{}'.format(app, self.domain)
subprocess.call([script_path, host, self.port])
subprocess.call(['service', app, 'restart'])
def update_proxy(self, app):
self.add_app_to_nginx(app)
subprocess.call(['service', 'nginx', 'reload'])
def add_app_to_nginx(self, app):
ip = get_container_ip(app)
with open(os.path.join(NGINX_DIR, '{}.conf'.format(app)), 'w') as f:
f.write(NGINX_TEMPLATE.format(app=app, ip=ip, domain=self.domain, port=self.port))
def update_domain(self, domain, port):
self.domain = self.conf["_"]["domain"] = domain
self.port = self.conf["_"]["port"] = port
self.save_conf()
self.update_app_confs()
self.rebuild_nginx()
self.rebuild_issue()
subprocess.call(['service', 'nginx', 'restart'])
def update_app_confs(self):
for app in self.conf.iteritems():
if 'url' in app[1]:
self.update_app_conf(app[0])
def rebuild_nginx(self):
for f in os.listdir(NGINX_DIR):
os.unlink(os.path.join(NGINX_DIR, f))
with open(os.path.join(NGINX_DIR, 'default.conf'), 'w') as f:
f.write(NGINX_DEFAULT_TEMPLATE.format(port=self.port))
for app in self.conf.iteritems():
if 'url' in app[1]:
self.add_app_to_nginx(app[0])
def rebuild_issue(self):
host = self.domain
if self.port != '443':
host = '{}:{}'.format(host, self.port)
with open(ISSUE_FILE, 'w') as f:
f.write(ISSUE_TEMPLATE.format(host=host))
def get_container_ip(app):
try:
return subprocess.check_output(['docker', 'inspect', '-f', '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}', app]).strip()
except:
return '127.0.0.1'
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Spotter VM application manager')
subparsers = parser.add_subparsers()
parser_add_app = subparsers.add_parser('add-app', help='Registers a new application')
parser_add_app.set_defaults(action='add-app')
parser_add_app.add_argument('app', help='Application name')
parser_add_app.add_argument('url', nargs='?', help='URL to the application. Use "{host}" as a host placeholder')
parser_add_app.add_argument('login', nargs='?', help='Administrative login')
parser_add_app.add_argument('password', nargs='?', help='Administrative password')
parser_add_app.add_argument('-p', '--property', nargs=2, action='append', help='Add arbitrary key-value to the application properties')
parser_update_proxy = subparsers.add_parser('update-proxy', help='Updates nginx proxy target for an application container')
parser_update_proxy.set_defaults(action='update-proxy')
parser_update_proxy.add_argument('app', help='Application name')
parser_update_domain = subparsers.add_parser('update-domain', help='Rebuilds domain structure of VM with new domain name and new HTTPS port')
parser_update_domain.set_defaults(action='update-domain')
parser_update_domain.add_argument('domain', help='Domain name')
parser_update_domain.add_argument('port', help='HTTPS port')
args = parser.parse_args()
sm = SpotterManager()
if args.action == 'add-app':
sm.add_app(args.app, args)
elif args.action == 'update-proxy':
sm.update_proxy(args.app)
elif args.action == 'update-domain':
sm.update_domain(args.domain, args.port)

View File

@ -1,6 +0,0 @@
#!/bin/sh
mkdir -p /etc/acme.sh.d
wget https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh -O /usr/local/bin/acme.sh
sed -i 's/\$HOME\/.\$PROJECT_NAME/\/etc\/acme.sh.d/' /usr/local/bin/acme.sh
chmod +x /usr/local/bin/acme.sh

View File

@ -6,9 +6,12 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/ccleanup
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q ruby || $(realpath $(dirname "${0}"))/ruby.sh
service postgres start
# Build Docker container
docker build -t ccleanup ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/ccleanup /etc/init.d/ccleanup
rc-update -u
# Create database
export CCLEANUP_PWD=$(head -c 18 /dev/urandom | base64)
@ -28,17 +31,10 @@ envsubst <${SOURCE_DIR}/srv/ccleanup/conf/database.yml >/srv/ccleanup/conf/datab
cp ${SOURCE_DIR}/srv/ccleanup/conf/boot.rb /srv/ccleanup/conf/boot.rb
cp ${SOURCE_DIR}/srv/ccleanup/conf/initializers/devise.rb /srv/ccleanup/conf/initializers/devise.rb
cp ${SOURCE_DIR}/srv/ccleanup/conf/environments/production.rb /srv/ccleanup/conf/environments/production.rb
spotter-appmgr update-login ccleanup "${CCLEANUP_ADMIN_EMAIL}" "${CCLEANUP_ADMIN_PWD}"
# Populate database
envsubst <${SOURCE_DIR}/srv/ccleanup/db/seeds.rb >/tmp/seeds.rb
docker run --rm -h ccleanup --link postgres -v /srv/ccleanup/conf:/srv/ccleanup/config ccleanup rake db:schema:load
docker run --rm -h ccleanup --link postgres -v /srv/ccleanup/conf:/srv/ccleanup/config -v /tmp/seeds.rb:/srv/ccleanup/db/seeds.rb ccleanup rake db:seed
rm /tmp/seeds.rb
# Create CrisisCleanup service
cp ${SOURCE_DIR}/etc/init.d/ccleanup /etc/init.d/ccleanup
rc-update add ccleanup
service ccleanup start
# Add application definition
spotter-appmgr add-app ccleanup "https://ccleanup.{host}/" "${CCLEANUP_ADMIN_EMAIL}" "${CCLEANUP_ADMIN_PWD}"

View File

@ -3,8 +3,7 @@
description="Crisis Cleanup docker container"
depend() {
need docker net postgres
use dns logger netmount postfix
need docker postfix postgres
}
start() {
@ -18,7 +17,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy ccleanup
/usr/bin/spotter-appmgr register-proxy ccleanup
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy ccleanup
}
stop() {

14
ckan.sh
View File

@ -8,9 +8,14 @@ docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q redis || $(realpath $(dirname "${0}"))/redis.sh
docker image ls | grep -q solr || $(realpath $(dirname "${0}"))/solr.sh
service postgres start
service redis start
service solr start
# Build Docker container
docker build -t ckan ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/ckan /etc/init.d/ckan
rc-update -u
# Create database
export CKAN_PWD=$(head -c 18 /dev/urandom | base64)
@ -51,14 +56,7 @@ export CKAN_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
export CKAN_ADMIN_HASH=$(docker run --rm ckan python -c "from passlib.hash import pbkdf2_sha512;print pbkdf2_sha512.encrypt('${CKAN_ADMIN_PWD}')")
export CKAN_ADMIN_EMAIL="admin@example.com"
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i postgres psql ckan
# Configure CKAN service
cp ${SOURCE_DIR}/etc/init.d/ckan /etc/init.d/ckan
rc-update add ckan
service ckan start
spotter-appmgr update-login ckan "${CKAN_ADMIN_USER}" "${CKAN_ADMIN_PWD}"
# Install cron job
cp ${SOURCE_DIR}/etc/periodic/hourly/ckan /etc/periodic/hourly/ckan
# Add application definition
spotter-appmgr add-app ckan "https://ckan.{host}/" "${CKAN_ADMIN_USER}" "${CKAN_ADMIN_PWD}"

View File

@ -3,9 +3,7 @@
description="CKAN docker container"
depend() {
need docker net postgres
use dns logger netmount postfix
after ckandp redis solr
need docker ckandp postfix postgres redis solr
}
start() {
@ -23,7 +21,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy ckan
/usr/bin/spotter-appmgr register-proxy ckan
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy ckan
}
stop() {

View File

@ -56,7 +56,7 @@ ckan.datastore.default_fts_index_method = gist
## Site Settings
ckan.site_url = http://127.0.0.1
ckan.site_url = https://ckan.spotter.vm
#ckan.use_pylons_response_cleanup_middleware = true
## Authorization Settings

View File

@ -4,14 +4,11 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/ckandp
# Build Docker container
docker build -t ckandp ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/ckandp /etc/init.d/ckandp
rc-update -u
# Configure CKAN DataPusher
mkdir -p /srv/ckandp/conf /srv/ckandp/data
cp ${SOURCE_DIR}/srv/ckandp/conf/datapusher.wsgi /srv/ckandp/conf/datapusher.wsgi
cp ${SOURCE_DIR}/srv/ckandp/conf/datapusher_settings.py /srv/ckandp/conf/datapusher_settings.py
chown -R 8004:8004 /srv/ckandp/data
# Configure CKAN DataPusher service
cp ${SOURCE_DIR}/etc/init.d/ckandp /etc/init.d/ckandp
rc-update add ckandp
service ckandp start

View File

@ -3,8 +3,7 @@
description="CKAN DataPusher docker container"
depend() {
need docker net
use dns logger netmount
need docker
}
start() {

12
cts.sh
View File

@ -4,9 +4,12 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/cts
# Check prerequisites
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container
docker build -t cts ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/cts /etc/init.d/cts
rc-update -u
# Create database
export CTS_PWD=$(head -c 18 /dev/urandom | base64)
@ -35,11 +38,4 @@ export CTS_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
export CTS_ADMIN_HASH=$(docker run --rm -h cts -v /srv/cts/conf:/srv/cts/cts/settings cts python -c "from django.contrib.auth.hashers import make_password; print make_password('${CTS_ADMIN_PWD}')")
export CTS_ADMIN_SECRET=$(head -c 12 /dev/urandom | sha256sum | cut -c1-13)
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i postgres psql cts
# Create CTS service
cp ${SOURCE_DIR}/etc/init.d/cts /etc/init.d/cts
rc-update add cts
service cts start
# Add application definition
spotter-appmgr add-app cts "https://cts.{host}/" "${CTS_ADMIN_EMAIL}" "${CTS_ADMIN_PWD}"
spotter-appmgr update-login cts "${CTS_ADMIN_EMAIL}" "${CTS_ADMIN_PWD}"

View File

@ -3,8 +3,7 @@
description="CTS docker container"
depend() {
need docker net postgres
use dns logger netmount
need docker postgres
}
start() {
@ -17,7 +16,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy cts
/usr/bin/spotter-appmgr register-proxy cts
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy cts
}
stop() {

View File

@ -7,20 +7,15 @@ docker image ls | grep -q java || $(realpath $(dirname "${0}"))/java.sh
# Build Docker container
docker build -t flsms ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/flsms /etc/init.d/flsms
rc-update -u
# Configure FrontlineSMS
mkdir -p /srv/flsms/data
export FLSMS_ADMIN_USER=admin
export FLSMS_ADMIN_USER="admin"
export FLSMS_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
export FLSMS_ADMIN_USER_HASH=$(echo -n "${FLSMS_ADMIN_USER}" | base64)
export FLSMS_ADMIN_PWD_HASH=$(echo -n "${FLSMS_ADMIN_PWD}" | base64)
envsubst <${SOURCE_DIR}/srv/flsms/data/app-settings.properties >/srv/flsms/data/app-settings.properties
chown -R 8018:8018 /srv/flsms/data
# Create FrontlineSMS service
cp ${SOURCE_DIR}/etc/init.d/flsms /etc/init.d/flsms
rc-update add flsms
service flsms start
# Add application definition
spotter-appmgr add-app flsms "https://flsms.{host}/" "${FLSMS_ADMIN_USER}" "${FLSMS_ADMIN_PWD}"
spotter-appmgr update-login flsms "${FLSMS_ADMIN_USER}" "${FLSMS_ADMIN_PWD}"

View File

@ -3,8 +3,7 @@
description="FrontlineSMS docker container"
depend() {
need docker net
use dns logger netmount
need docker
}
start() {
@ -16,7 +15,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy flsms
/usr/bin/spotter-appmgr register-proxy flsms
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy flsms
}
stop() {

View File

@ -5,9 +5,12 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/gnuhealth
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container
docker build -t gnuhealth ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/gnuhealth /etc/init.d/gnuhealth
rc-update -u
# Create databases
export GNUHEALTH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '/+=')
@ -18,21 +21,14 @@ mkdir -p /srv/gnuhealth/conf/
envsubst <${SOURCE_DIR}/srv/gnuhealth/conf/trytond.conf >/srv/gnuhealth/conf/trytond.conf
# Populate database
export GNUHEALTH_ADMIN_USER="admin"
export GNUHEALTH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
echo ${GNUHEALTH_ADMIN_PWD} >/tmp/.adminpwd
docker run --rm -h gnuhealth --link postgres -v /srv/gnuhealth/conf:/srv/gnuhealth/gnuhealth/tryton/server/config -v /tmp/.adminpwd:/tmp/.adminpwd -e TRYTONPASSFILE=/tmp/.adminpwd gnuhealth /srv/gnuhealth/gnuhealth/tryton/server/trytond-4.2.10/bin/trytond-admin -d gnuhealth --all -v
rm -f /tmp/.adminpwd
spotter-appmgr update-login gnuhealth "${GNUHEALTH_ADMIN_USER}" "${GNUHEALTH_ADMIN_PWD}"
# Populate demo database
wget http://health.gnu.org/downloads/postgres_dumps/gnuhealth-32-demo.sql.gz -O /tmp/gnuhealth_demo.sql.gz
zcat /tmp/gnuhealth_demo.sql.gz | docker exec -i -e PGPASSWORD=${GNUHEALTH_PWD} postgres psql gnuhealth_demo gnuhealth
rm -f /tmp/gnuhealth_demo.sql.gz
# Create GNU Health service
cp ${SOURCE_DIR}/etc/init.d/gnuhealth /etc/init.d/gnuhealth
rc-update add gnuhealth
service gnuhealth start
# Add application definition
spotter-appmgr add-app gnuhealth "https://gnuhealth.{host}/index.html" admin "${GNUHEALTH_ADMIN_PWD}"
spotter-appmgr add-app gnuhealth-clients -p clienturl "gnuhealth.{host}"

View File

@ -3,8 +3,7 @@
description="GNU Health docker container"
depend() {
need docker net postgres
use dns logger netmount postfix
need docker postgres
}
start() {
@ -18,7 +17,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy gnuhealth
/usr/bin/spotter-appmgr register-proxy gnuhealth
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy gnuhealth
}
stop() {

View File

@ -5,9 +5,12 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/kanboard
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container
docker build -t kanboard ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/kanboard /etc/init.d/kanboard
rc-update -u
# Populate database
export KANBOARD_PWD=$(head -c 18 /dev/urandom | base64)
@ -22,15 +25,7 @@ export KANBOARD_ADMIN_USER=admin
export KANBOARD_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
export KANBOARD_ADMIN_HASH=$(docker run --rm kanboard php -r "echo password_hash('${KANBOARD_ADMIN_PWD}', PASSWORD_BCRYPT);")
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i postgres psql kanboard
# Create KanBoard service
cp ${SOURCE_DIR}/etc/init.d/kanboard /etc/init.d/kanboard
rc-update add kanboard
service kanboard start
spotter-appmgr update-login kanboard "${KANBOARD_ADMIN_USER}" "${KANBOARD_ADMIN_PWD}"
# Install cron job
cp ${SOURCE_DIR}/etc/periodic/daily/kanboard /etc/periodic/daily/kanboard
# Add application definition
spotter-appmgr add-app kanboard "https://kanboard.{host}/" "${KANBOARD_ADMIN_USER}" "${KANBOARD_ADMIN_PWD}"
spotter-appmgr add-app kanboard-mobile -p clienturl "https://kanboard.{host}"

View File

@ -3,8 +3,7 @@
description="KanBoard docker container"
depend() {
need docker net postgres
use dns logger netmount postfix
need docker postfix postgres
}
start() {
@ -19,7 +18,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy kanboard
/usr/bin/spotter-appmgr register-proxy kanboard
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy kanboard
}
stop() {

View File

@ -4,6 +4,8 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/mariadb
# Build Docker container
docker build -t mariadb ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/mariadb /etc/init.d/mariadb
rc-update -u
# Create MariaDB instance
mkdir -p /srv/mariadb/conf /srv/mariadb/data
@ -18,11 +20,6 @@ if [ ${DEBUG:-0} -eq 1 ]; then
sed -i 's/#general_log/general_log/g' /srv/mariadb/conf/my.cnf
fi
# Configure MariaDB service
cp ${SOURCE_DIR}/etc/init.d/mariadb /etc/init.d/mariadb
rc-update add mariadb
service mariadb start
# Configure MariaDB admin
docker exec -i mariadb sh -c 'until [ -x /run/mysqld/mysqld.sock ]; do usleep 100000; done'
service mariadb start
cat ${SOURCE_DIR}/adminpwd.sql | docker exec -i mariadb mysql

View File

@ -3,8 +3,7 @@
description="MariaDB docker container"
depend() {
need docker net
use dns logger netmount
need docker
}
start() {
@ -16,6 +15,10 @@ start() {
mariadb
}
start_post() {
timeout -t 3 docker exec mariadb sh -c 'until [ -e /run/mysqld/mysqld.sock ]; do usleep 50000; done'
}
stop() {
/usr/bin/docker stop mariadb
}

View File

@ -6,9 +6,12 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/mifosx
docker image ls | grep -q mariadb || $(realpath $(dirname "${0}"))/mariadb.sh
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q tomcat || $(realpath $(dirname "${0}"))/tomcat.sh
service mariadb start
# Build Docker container
docker build -t mifosx ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/mifosx /etc/init.d/mifosx
rc-update -u
# Create databases
export MIFOSX_PWD=$(head -c 18 /dev/urandom | base64)
@ -24,22 +27,17 @@ envsubst <${SOURCE_DIR}/srv/mifosx/conf/context.xml >/srv/mifosx/conf/context.xm
cp ${SOURCE_DIR}/srv/mifosx/conf/server.xml /srv/mifosx/conf/server.xml
cp ${SOURCE_DIR}/srv/mifosx/update-url.sh /srv/mifosx/update-url.sh
# Create Mifos X service
cp ${SOURCE_DIR}/etc/init.d/mifosx /etc/init.d/mifosx
rc-update add mifosx
# Populate database
service mifosx start
# Update admin account
echo `date` '- Waiting for database to be populated. This should take about a minute.'
until docker logs mifosx 2>&1 | grep -q 'Migrating schema `mifostenant-default` to version 5000'; do
sleep 1
done
# Update admin account
export MIFOSX_ADMIN_USER=admin
export MIFOSX_ADMIN_EMAIL=admin@example.com
export MIFOSX_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d "+")
export MIFOSX_ADMIN_HASH=$(echo -n "${MIFOSX_ADMIN_PWD}{1}" | sha256sum | awk '{print $1}')
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i mariadb mysql mifostenant-default
# Add application definition
spotter-appmgr add-app mifosx "https://mifosx.{host}/community-app/" "${MIFOSX_ADMIN_USER}" "${MIFOSX_ADMIN_PWD}"
spotter-appmgr add-app mifosx-mobile -p clienturl "mifosx.{host}"
spotter-appmgr update-login mifosx "${MIFOSX_ADMIN_USER}" "${MIFOSX_ADMIN_PWD}"

View File

@ -3,8 +3,7 @@
description="Mifos X docker container"
depend() {
need docker net mariadb
use dns logger netmount postfix
need docker mariadb postfix
}
start() {
@ -19,7 +18,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy mifosx
/usr/bin/spotter-appmgr register-proxy mifosx
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy mifosx
}
stop() {

View File

@ -68,7 +68,7 @@
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
proxyName="127.0.0.1"
proxyName="mifosx.spotter.vm"
proxyPort="443"
scheme="https" secure="true"
redirectPort="8443" />

View File

@ -7,9 +7,12 @@ docker image ls | grep -q activemq || $(realpath $(dirname "${0}"))/activemq.sh
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q tomcat || $(realpath $(dirname "${0}"))/tomcat.sh
service postgres start
# Build Docker container
docker build -t motech ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/motech /etc/init.d/motech
rc-update -u
# Create database
export MOTECH_PWD=$(head -c 18 /dev/urandom | base64)
@ -24,12 +27,8 @@ cp ${SOURCE_DIR}/srv/motech/conf/config/org.motechproject.motech-platform-email/
chown -R 8013:8013 /srv/motech/conf
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
rc-update add motech
# Populate database and create admin account
service motech start
# Configure Motech admin
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
@ -39,6 +38,4 @@ 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/
# Add application definition
spotter-appmgr add-app motech "https://motech.{host}/motech/" "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}"
spotter-appmgr update-login motech "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}"

View File

@ -3,8 +3,7 @@
description="Motech docker container"
depend() {
need docker net postgres activemq
use dns logger netmount postfix
need docker activemq postfix postgres
}
start() {
@ -19,7 +18,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy motech
/usr/bin/spotter-appmgr register-proxy motech
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy motech
}
stop() {

View File

@ -1,3 +1,3 @@
system.language=en
login.mode=repository
server.url=http://127.0.0.1
server.url=https://motech.spotter.vm

18
odk.sh
View File

@ -6,9 +6,12 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/odk
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q tomcat || $(realpath $(dirname "${0}"))/tomcat.sh
service postgres start
# Build Docker container
docker build -t odk ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/odk /etc/init.d/odk
rc-update -u
# Create databases
export ODK_PWD=$(head -c 18 /dev/urandom | base64)
@ -24,21 +27,16 @@ cp ${SOURCE_DIR}/srv/odk/conf/server.xml /srv/odk/conf/server.xml
cp ${SOURCE_DIR}/srv/odk/update-url.sh /srv/odk/update-url.sh
chown -R 8015:8015 /srv/odk/conf
# Create OpenDataKit service
cp ${SOURCE_DIR}/etc/init.d/odk /etc/init.d/odk
rc-update add odk
# Populate database
service odk start
until docker logs odk 2>&1 | grep -q 'org.apache.catalina.startup.Catalina.start'; do
sleep 1
done
# Update admin account
export ODK_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
export ODK_ADMIN_SALT=$(head -c 4 /dev/urandom | hexdump -e '"%x"') # Must be 8 characters
export ODK_ADMIN_BASIC_HASH=$(echo -n "${ODK_ADMIN_PWD}{${ODK_ADMIN_SALT}}" | sha1sum | tr -d " -")
export ODK_ADMIN_DIGEST_HASH=$(echo -n "${ODK_ADMIN_USER}:${ODK_ADMIN_REALM}:${ODK_ADMIN_PWD}" | md5sum | tr -d " -")
until docker logs odk 2>&1 | grep -q 'org.apache.catalina.startup.Catalina.start'; do
sleep 1
done
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i postgres psql odk
# Add application definition
spotter-appmgr add-app odk "https://odk.{host}/aggregate/" "${ODK_ADMIN_USER}" "${ODK_ADMIN_PWD}"
spotter-appmgr add-app odk-clients -p clienturl "https://odk.{host}/aggregate"
spotter-appmgr update-login odk "${ODK_ADMIN_USER}" "${ODK_ADMIN_PWD}"

View File

@ -3,8 +3,7 @@
description="OpenDataKit Aggregate docker container"
depend() {
need docker net postgres
use dns logger netmount postfix
need docker postfix postgres
}
start() {
@ -20,7 +19,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy odk
/usr/bin/spotter-appmgr register-proxy odk
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy odk
}
stop() {

View File

@ -68,7 +68,7 @@
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
proxyName="127.0.0.1"
proxyName="odk.spotter.vm"
proxyPort="443"
scheme="https" secure="true"
redirectPort="8443" />

View File

@ -5,9 +5,12 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/odkbuild
# Check prerequisites
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q ruby || $(realpath $(dirname "${0}"))/ruby.sh
service postgres start
# Build Docker container
docker build -t odkbuild ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/odkbuild /etc/init.d/odkbuild
rc-update -u
# Create databases
export ODKBUILD_PWD=$(head -c 18 /dev/urandom | base64)
@ -18,11 +21,3 @@ export ODKBUILD_COOKIE_SECRET=$(head -c 8 /dev/urandom | hexdump -e '"%x"')
mkdir -p /srv/odkbuild/conf
envsubst <${SOURCE_DIR}/srv/odkbuild/conf/config.yml >/srv/odkbuild/conf/config.yml
docker run --rm -h odkbuild --link postgres -v /srv/odkbuild/conf/config.yml:/srv/odkbuild/config.yml -w /srv/odkbuild odkbuild rake db:migrate
# Create OpenDataKit service
cp ${SOURCE_DIR}/etc/init.d/odkbuild /etc/init.d/odkbuild
rc-update add odkbuild
service odkbuild start
# Add application definition
spotter-appmgr add-app odkbuild "https://odkbuild.{host}/"

View File

@ -3,8 +3,7 @@
description="OpenDataKit Build docker container"
depend() {
need docker net postgres
use dns logger netmount
need docker postgres
}
start() {
@ -17,7 +16,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy odkbuild
/usr/bin/spotter-appmgr register-proxy odkbuild
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy odkbuild
}
stop() {

13
omk.sh
View File

@ -7,6 +7,8 @@ docker image ls | grep -q java || $(realpath $(dirname "${0}"))/java.sh
# Build Docker container
docker build -t omk ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/omk /etc/init.d/omk
rc-update -u
# Configure OpenMapKit
export OMK_ADMIN_USER="admin"
@ -15,13 +17,4 @@ mkdir -p /srv/omk/conf /srv/omk/data
chown -R 8007:8007 /srv/omk/data
docker run --rm -v /srv/omk/data:/mnt/data omk cp -rp /srv/omk/data/. /mnt/data
envsubst <${SOURCE_DIR}/srv/omk/conf/settings.js >/srv/omk/conf/settings.js
# Configure OpenMapKit service
cp ${SOURCE_DIR}/etc/init.d/omk /etc/init.d/omk
rc-update add omk
service omk start
# Add application definition
spotter-appmgr add-app omk "https://omk.{host}/" "${OMK_ADMIN_USER}" "${OMK_ADMIN_PWD}"
spotter-appmgr add-app omk-clients -p clienturl "https://omk.{host}"
spotter-appmgr add-app geoodk-clients -p clienturl "https://omk.{host}"
spotter-appmgr update-login omk "${OMK_ADMIN_USER}" "${OMK_ADMIN_PWD}"

View File

@ -3,8 +3,7 @@
description="OpenMapKit docker container"
depend() {
need docker net
use dns logger netmount
need docker
}
start() {
@ -17,7 +16,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy omk
/usr/bin/spotter-appmgr register-proxy omk
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy omk
}
stop() {

View File

@ -6,9 +6,13 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/pandora
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q rabbitmq || $(realpath $(dirname "${0}"))/rabbitmq.sh
service postgres start
service rabbitmq start
# Build Docker container
docker build -t pandora ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/pandora /etc/init.d/pandora
rc-update -u
# Create PostgreSQL user and database
export PANDORA_PWD=$(head -c 18 /dev/urandom | base64)
@ -50,11 +54,4 @@ export PANDORA_ADMIN_EMAIL=admin@example.com
export PANDORA_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
export PANDORA_ADMIN_HASH=$(docker run --rm -h pandora -e DJANGO_SETTINGS_MODULE=pandora.settings -v /srv/pandora/conf:/srv/pandora/conf pandora python3 -c "from django.contrib.auth.hashers import make_password; print(make_password('${PANDORA_ADMIN_PWD}'))")
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i postgres psql pandora
# Configure Pandora service
cp ${SOURCE_DIR}/etc/init.d/pandora /etc/init.d/pandora
rc-update add pandora
service pandora start
# Add application definition
spotter-appmgr add-app pandora "https://pandora.{host}/" "${PANDORA_ADMIN_USER}" "${PANDORA_ADMIN_PWD}"
spotter-appmgr update-login pandora "${PANDORA_ADMIN_USER}" "${PANDORA_ADMIN_PWD}"

View File

@ -3,8 +3,7 @@
description="Pan.do/ra docker container"
depend() {
need docker net postgres rabbitmq
use dns logger netmount postfix
need docker postfix postgres rabbitmq
}
start() {
@ -20,7 +19,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy pandora
/usr/bin/spotter-appmgr register-proxy pandora
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy pandora
}
stop() {

View File

@ -4,6 +4,8 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/postfix
# Build Docker container
docker build -t postfix ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/postfix /etc/init.d/postfix
rc-update -u
# Copy existing config files into persistent storage
mkdir -p /srv/postfix/conf /srv/postfix/data
@ -11,8 +13,3 @@ docker run --rm -v /srv/postfix/conf:/mnt/conf postfix cp -rp /etc/postfix/. /mn
# Configure postfix
cp ${SOURCE_DIR}/srv/postfix/conf/main.cf /srv/postfix/conf/main.cf
# Configure postfix service
cp ${SOURCE_DIR}/etc/init.d/postfix /etc/init.d/postfix
rc-update add postfix
service postfix start

View File

@ -3,8 +3,7 @@
description="Postfix docker container"
depend() {
need docker net
use dns logger netmount
need docker
}
start() {

View File

@ -4,6 +4,8 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/postgres
# Build Docker container
docker build -t postgres ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/postgres /etc/init.d/postgres
rc-update -u
# Create Postgres instance
mkdir -p /srv/postgres/data
@ -14,14 +16,8 @@ docker run --rm --name postgres -h postgres -v /srv/postgres/data:/var/lib/postg
# Configure Postgres
cp ${SOURCE_DIR}/srv/postgres/data/postgresql.conf /srv/postgres/data/postgresql.conf
cp ${SOURCE_DIR}/srv/postgres/data/pg_hba.conf /srv/postgres/data/pg_hba.conf
# Enable query logging. Only if the DEBUG environment variable is set
if [ ${DEBUG:-0} -eq 1 ]; then
sed -i 's/^#log_destination/log_destination/' /srv/postgres/data/postgresql.conf
sed -i 's/^#log_statement/log_statement/' /srv/postgres/data/postgresql.conf
fi
# Configure Postgres service
cp ${SOURCE_DIR}/etc/init.d/postgres /etc/init.d/postgres
rc-update add postgres
service postgres start

View File

@ -3,8 +3,7 @@
description="Postgres docker container"
depend() {
need docker net
use dns logger netmount
need docker
}
start() {
@ -15,6 +14,10 @@ start() {
postgres
}
start_post() {
timeout -t 3 docker exec postgres sh -c 'until [ -e /var/run/postgresql/.s.PGSQL.5432 ]; do usleep 50000; done'
}
stop() {
/usr/bin/docker stop postgres
}

View File

@ -4,12 +4,9 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/rabbitmq
# Build Docker container
docker build -t rabbitmq ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/rabbitmq /etc/init.d/rabbitmq
rc-update -u
# Create RabbitMQ directory structure
mkdir -p /srv/rabbitmq/data
chown 5672:5672 /srv/rabbitmq/data
# Configure RabbitMQ service
cp ${SOURCE_DIR}/etc/init.d/rabbitmq /etc/init.d/rabbitmq
rc-update add rabbitmq
service rabbitmq start

View File

@ -3,8 +3,7 @@
description="RabbitMQ docker container"
depend() {
need docker net
use dns logger netmount
need docker
}
start() {

View File

@ -4,13 +4,10 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/redis
# Build Docker container
docker build -t redis ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/redis /etc/init.d/redis
rc-update -u
# Configure Redis
mkdir -p /srv/redis/conf /srv/redis/data
cp ${SOURCE_DIR}/srv/redis/conf/redis.conf /srv/redis/conf/redis.conf
chown -R 6379:6379 /srv/redis/data
# Configure Redis service
cp ${SOURCE_DIR}/etc/init.d/redis /etc/init.d/redis
rc-update add redis
service redis start

View File

@ -3,8 +3,7 @@
description="Redis docker container"
depend() {
need docker net
use dns logger netmount
need docker
}
start() {

View File

@ -6,7 +6,12 @@ export TEMPLATE=${TEMPLATE:-"default"}
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q sahana || docker build -t sahana $(realpath $(dirname "${0}"))/sahana
service postgres start
# Build Docker container
docker build -t sahana ${SOURCE_DIR}
envsubst <${SOURCE_DIR}/etc/init.d/sahana-demo >/etc/init.d/sahana-demo
chmod +x /etc/init.d/sahana-demo
# Create PostgreSQL user and database
export SAHANADEMO_PWD=$(head -c 18 /dev/urandom | base64)
@ -25,16 +30,8 @@ export SAHANADEMO_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
envsubst <${SOURCE_DIR}/srv/sahana-demo/conf/000_config.py >/srv/sahana-demo/conf/000_config.py
envsubst <${SOURCE_DIR}/masterUsers.csv >/tmp/masterUsers.csv
cp ${SOURCE_DIR}/srv/sahana-demo/update-url.sh /srv/sahana-demo/update-url.sh
spotter-appmgr update-login sahana-demo "${SAHANADEMO_ADMIN_USER}" "${SAHANADEMO_ADMIN_PWD}"
# Populate database
docker run --rm -h sahana-demo --link postgres -v /srv/sahana-demo/conf:/srv/web2py/applications/eden/models -v /srv/sahana-demo/data/databases:/srv/web2py/applications/eden/databases -v /tmp/masterUsers.csv:/srv/web2py/applications/eden/modules/templates/default/users/masterUsers.csv sahana su - sahana -c "./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py"
rm /tmp/masterUsers.csv
# Create Sahana service
envsubst <${SOURCE_DIR}/etc/init.d/sahana-demo >/etc/init.d/sahana-demo
chmod +x /etc/init.d/sahana-demo
rc-update add sahana-demo
service sahana-demo start
# Add application definition
spotter-appmgr add-app sahana-demo "https://sahana-demo.{host}/eden/" "${SAHANADEMO_ADMIN_USER}" "${SAHANADEMO_ADMIN_PWD}"

View File

@ -3,8 +3,7 @@
description="Sahana Eden Demo docker container"
depend() {
need docker net postgres
use dns logger netmount postfix
need docker postfix postgres
}
start() {
@ -21,7 +20,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy sahana-demo
/usr/bin/spotter-appmgr register-proxy sahana-demo
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy sahana-demo
}
stop() {

View File

@ -50,7 +50,7 @@ settings.gis.spatialdb = True
#settings.base.system_name = T("Sahana Eden Humanitarian Management Platform")
#settings.base.system_name_short = T("Sahana Eden")
# Set this to the Public URL of the instance
settings.base.public_url = "http://127.0.0.1"
settings.base.public_url = "https://sahana-demo.spotter.vm"
# Switch to "False" in Production for a Performance gain
# (need to set to "True" again when Table definitions are changed)

View File

@ -5,9 +5,12 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/sahana
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container
docker build -t sahana ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/sahana /etc/init.d/sahana
rc-update -u
# Create PostgreSQL user and database
export SAHANA_PWD=$(head -c 18 /dev/urandom | base64)
@ -30,6 +33,7 @@ envsubst <${SOURCE_DIR}/srv/sahana/conf/000_config.py >/srv/sahana/conf/000_conf
envsubst <${SOURCE_DIR}/srv/sahana/data/Spotter/masterUsers.csv >/srv/sahana/data/Spotter/masterUsers.csv
cp ${SOURCE_DIR}/srv/sahana/conf/00_settings.py /srv/sahana/conf/00_settings.py
cp ${SOURCE_DIR}/srv/sahana/update-url.sh /srv/sahana/update-url.sh
spotter-appmgr update-login sahana "${SAHANA_ADMIN_USER}" "${SAHANA_ADMIN_PWD}"
# Populate database
docker run --rm -h sahana --link postgres -v /srv/sahana/conf:/srv/web2py/applications/eden/models -v /srv/sahana/data/Spotter:/srv/web2py/applications/eden/modules/templates/Spotter -v /srv/sahana/data/databases:/srv/web2py/applications/eden/databases sahana su - sahana -c "./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py"
@ -40,11 +44,3 @@ if [ ${DEBUG:-0} -eq 0 ]; then
sed -i 's/settings.base.debug = True/settings.base.debug = False/' /srv/sahana/conf/000_config.py
sed -i 's/#settings.base.prepopulate = 0/settings.base.prepopulate = 0/' /srv/sahana/conf/000_config.py
fi
# Create Sahana service
cp ${SOURCE_DIR}/etc/init.d/sahana /etc/init.d/sahana
rc-update add sahana
service sahana start
# Add application definition
spotter-appmgr add-app sahana "https://sahana.{host}/eden/" "${SAHANA_ADMIN_USER}" "${SAHANA_ADMIN_PWD}"

View File

@ -3,8 +3,7 @@
description="Sahana Eden docker container"
depend() {
need docker net postgres
use dns logger netmount postfix
need docker postfix postgres
}
start() {
@ -21,7 +20,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy sahana
/usr/bin/spotter-appmgr register-proxy sahana
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy sahana
}
stop() {

View File

@ -50,7 +50,7 @@ settings.gis.spatialdb = True
#settings.base.system_name = T("Sahana Eden Humanitarian Management Platform")
#settings.base.system_name_short = T("Sahana Eden")
# Set this to the Public URL of the instance
settings.base.public_url = "http://127.0.0.1"
settings.base.public_url = "https://sahana.spotter.vm"
# Switch to "False" in Production for a Performance gain
# (need to set to "True" again when Table definitions are changed)

View File

@ -5,7 +5,12 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/sambro
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q sahana || docker build -t sahana $(realpath $(dirname "${0}"))/sahana
service postgres start
# Build Docker container
docker build -t sahana ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/sambro /etc/init.d/sambro
rc-update -u
# Create PostgreSQL user and database
export SAMBRO_PWD=$(head -c 18 /dev/urandom | base64)
@ -26,6 +31,7 @@ envsubst <${SOURCE_DIR}/masterUsers.csv >/tmp/masterUsers.csv
cp ${SOURCE_DIR}/srv/sambro/conf/00_settings.py /srv/sambro/conf/00_settings.py
cp ${SOURCE_DIR}/srv/sambro/data/SAMBRO/config.py /srv/sambro/data/SAMBRO/config.py
cp ${SOURCE_DIR}/srv/sambro/update-url.sh /srv/sambro/update-url.sh
spotter-appmgr update-login sambro "${SAMBRO_ADMIN_USER}" "${SAMBRO_ADMIN_PWD}"
# Populate database
docker run --rm -h sambro --link postgres -v /srv/sambro/conf:/srv/web2py/applications/eden/models -v /srv/sambro/data/SAMBRO:/srv/web2py/applications/eden/modules/templates/SAMBRO -v /tmp/masterUsers.csv:/srv/web2py/applications/eden/modules/templates/default/users/masterUsers.csv -v /srv/sambro/data/databases:/srv/web2py/applications/eden/databases sahana su - sahana -c "./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py"
@ -37,12 +43,3 @@ if [ ${DEBUG:-0} -eq 0 ]; then
sed -i 's/settings.base.debug = True/settings.base.debug = False/' /srv/sambro/conf/000_config.py
sed -i 's/#settings.base.prepopulate = 0/settings.base.prepopulate = 0/' /srv/sambro/conf/000_config.py
fi
# Create SAMBRO service
cp ${SOURCE_DIR}/etc/init.d/sambro /etc/init.d/sambro
rc-update add sambro
service sambro start
# Add application definition
spotter-appmgr add-app sambro "https://sambro.{host}/eden/" "${SAMBRO_ADMIN_USER}" "${SAMBRO_ADMIN_PWD}"
spotter-appmgr add-app sambro-mobile -p clienturl "https://sambro.{host}/eden/"

View File

@ -3,8 +3,7 @@
description="SAMBRO docker container"
depend() {
need docker net postgres
use dns logger netmount postfix
need docker postfix postgres
}
start() {
@ -21,7 +20,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy sambro
/usr/bin/spotter-appmgr register-proxy sambro
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy sambro
}
stop() {

View File

@ -50,7 +50,7 @@ settings.gis.spatialdb = True
#settings.base.system_name = T("Sahana Eden Humanitarian Management Platform")
#settings.base.system_name_short = T("Sahana Eden")
# Set this to the Public URL of the instance
settings.base.public_url = "http://127.0.0.1"
settings.base.public_url = "https://sambro.spotter.vm"
# Switch to "False" in Production for a Performance gain
# (need to set to "True" again when Table definitions are changed)

View File

@ -5,9 +5,12 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/seeddms
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container
docker build -t seeddms ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/seeddms /etc/init.d/seeddms
rc-update -u
# Populate database
export SEEDDMS_PWD=$(head -c 18 /dev/urandom | base64)
@ -27,14 +30,7 @@ export SEEDDMS_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
export SEEDDMS_ADMIN_EMAIL=admin@example.com
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i postgres psql seeddms
chown -R 8010:8010 /srv/seeddms/conf
# Create SeedDMS service
cp ${SOURCE_DIR}/etc/init.d/seeddms /etc/init.d/seeddms
rc-update add seeddms
service seeddms start
spotter-appmgr update-login seeddms "${SEEDDMS_ADMIN_USER}" "${SEEDDMS_ADMIN_PWD}"
# Install cron job
cp ${SOURCE_DIR}/etc/periodic/hourly/seeddms /etc/periodic/hourly/seeddms
# Add application definition
spotter-appmgr add-app seeddms "https://seeddms.{host}/" "${SEEDDMS_ADMIN_USER}" "${SEEDDMS_ADMIN_PWD}"

View File

@ -3,8 +3,7 @@
description="SeedDMS docker container"
depend() {
need docker net postgres
use dns logger netmount postfix
need docker postfix postgres
}
start() {
@ -19,7 +18,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy seeddms
/usr/bin/spotter-appmgr register-proxy seeddms
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy seeddms
}
stop() {

View File

@ -6,9 +6,12 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/sigmah
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q tomcat || $(realpath $(dirname "${0}"))/tomcat.sh
service postgres start
# Build Docker container
docker build -t sigmah ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/sigmah /etc/init.d/sigmah
rc-update -u
# Create database
export SIGMAH_PWD=$(head -c 18 /dev/urandom | base64)
@ -41,11 +44,4 @@ sed -i "s|\$2a\$10\$pMcTA1p9fefR8U9NoOPei.H0eq/TbbdSF27M0tn9iDWBrA4JHeCDC|${SIGM
cat /tmp/sigmah-MinimumDataKit.sql | docker exec -i -e PGPASSWORD=${SIGMAH_PWD} postgres psql -U sigmah sigmah
cat /tmp/sigmah-newOrganizationLaunchScript.sql | docker exec -i -e PGPASSWORD=${SIGMAH_PWD} postgres psql -U sigmah sigmah
rm -f /tmp/sigmah-MinimumDataKit.sql /tmp/sigmah-newOrganizationLaunchScript.sql
# Create Sigmah service
cp ${SOURCE_DIR}/etc/init.d/sigmah /etc/init.d/sigmah
rc-update add sigmah
service sigmah start
# Add application definition
spotter-appmgr add-app sigmah "https://sigmah.{host}/sigmah/" "${SIGMAH_ADMIN_EMAIL}" "${SIGMAH_ADMIN_PWD}"
spotter-appmgr update-login sigmah "${SIGMAH_ADMIN_EMAIL}" "${SIGMAH_ADMIN_PWD}"

View File

@ -3,8 +3,7 @@
description="Sigmah docker container"
depend() {
need docker net postgres
use dns logger netmount postfix
need docker postfix postgres
}
start() {
@ -20,7 +19,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy sigmah
/usr/bin/spotter-appmgr register-proxy sigmah
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy sigmah
}
stop() {

View File

@ -7,14 +7,11 @@ docker image ls | grep -q java || $(realpath $(dirname "${0}"))/java.sh
# Build Docker container
docker build -t solr ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/solr /etc/init.d/solr
rc-update -u
# Configure Solr
mkdir -p /srv/solr/data
cp ${SOURCE_DIR}/srv/solr/data/solr.xml /srv/solr/data/solr.xml
cp ${SOURCE_DIR}/srv/solr/data/.solr.in.sh /srv/solr/data/.solr.in.sh
chown -R 8983:8983 /srv/solr/data
# Configure Solr service
cp ${SOURCE_DIR}/etc/init.d/solr /etc/init.d/solr
rc-update add solr
service solr start

View File

@ -3,8 +3,7 @@
description="Solr docker container"
depend() {
need docker net
use dns logger netmount
need docker
}
start() {

View File

@ -5,9 +5,12 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/ushahidi
# Check prerequisites
docker image ls | grep -q mariadb || $(realpath $(dirname "${0}"))/mariadb.sh
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
service mariadb start
# Build Docker container
docker build -t ushahidi ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/ushahidi /etc/init.d/ushahidi
rc-update -u
# Create database
export USHAHIDI_PWD=$(head -c 18 /dev/urandom | base64)
@ -28,15 +31,7 @@ export USHAHIDI_ADMIN_USER=admin@example.com
export USHAHIDI_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
export USHAHIDI_ADMIN_HASH=$(docker run --rm ushahidi php -r "echo password_hash('${USHAHIDI_ADMIN_PWD}', PASSWORD_BCRYPT);")
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i mariadb mysql ushahidi
# Create Ushahidi service
cp ${SOURCE_DIR}/etc/init.d/ushahidi /etc/init.d/ushahidi
rc-update add ushahidi
service ushahidi start
spotter-appmgr update-login ushahidi "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}"
# Install cron job
cp ${SOURCE_DIR}/etc/periodic/15min/ushahidi /etc/periodic/15min/ushahidi
# 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}"

View File

@ -2,4 +2,4 @@ UPDATE users SET email = '${USHAHIDI_ADMIN_USER}', password = '${USHAHIDI_ADMIN_
INSERT INTO `config` (`group_name`, `config_key`, `config_value`) VALUES
('data-provider','email','{\"incoming_type\":\"IMAP\",\"incoming_server\":\"localhost\",\"incoming_port\":143,\"incoming_security\":\"None\",\"incoming_username\":\"ushahidi@spotter.ngo\",\"incoming_password\":\"password\",\"outgoing_type\":\"SMTP\",\"outgoing_server\":\"postfix\",\"outgoing_port\":25,\"outgoing_security\":\"None\",\"outgoing_username\":\"ushahidi@spotter.ngo\",\"outgoing_password\":\"password\",\"from\":\"ushahidi@spotter.ngo\",\"from_name\":\"Ushahidi\"}'),
('data-provider','url','\"http:\\/\\/127.0.0.1\\/platform\\/api\\/v3\\/config\\/data-provider\"');
('data-provider','url','\"https:\\/\\/ush.spotter.vm\\/platform\\/api\\/v3\\/config\\/data-provider\"');

View File

@ -3,8 +3,7 @@
description="Ushahidi docker container"
depend() {
need docker net mariadb
use dns logger netmount postfix
need docker mariadb postfix
}
start() {
@ -20,7 +19,11 @@ start() {
}
start_post() {
/usr/local/bin/spotter-appmgr update-proxy ushahidi
/usr/bin/spotter-appmgr register-proxy ushahidi
}
stop_pre() {
/usr/bin/spotter-appmgr unregister-proxy ushahidi
}
stop() {

View File

@ -1,5 +1,5 @@
{
"backend_url": "http://127.0.0.1/platform",
"backend_url": "https://ush.spotter.vm/platform",
"client_id": "ushahidiui",
"client_secret": "35e7f0bca957836d05ca0492211b0ac707671261",
"google_analytics_id": "AIzaSyBvIF3D550tlpL6o1xRrDurGo-81VhHlOw"