From 0f093a1087e44db97623eb43baf82c689dff3df9 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sat, 5 Oct 2019 15:40:27 +0200 Subject: [PATCH] Rework Ushahidi --- lxc-apps/ushahidi/install.sh | 37 ++++++++++--------- lxc-apps/ushahidi/install/etc/init.d/ushahidi | 23 ------------ .../install/etc/periodic/15min/ushahidi | 9 ----- lxc-apps/ushahidi/install/mariadb_conf/my.cnf | 24 ++++++++++++ .../install/{srv/ushahidi => }/update-conf.sh | 0 .../conf => ushahidi_conf}/config.json | 0 .../{srv/ushahidi/conf => ushahidi_conf}/env | 0 lxc-apps/ushahidi/lxcfile | 4 -- lxc-apps/ushahidi/meta | 29 +++++++++++++++ lxc-apps/ushahidi/uninstall.sh | 13 +------ 10 files changed, 74 insertions(+), 65 deletions(-) delete mode 100755 lxc-apps/ushahidi/install/etc/init.d/ushahidi delete mode 100755 lxc-apps/ushahidi/install/etc/periodic/15min/ushahidi create mode 100644 lxc-apps/ushahidi/install/mariadb_conf/my.cnf rename lxc-apps/ushahidi/install/{srv/ushahidi => }/update-conf.sh (100%) mode change 100755 => 100644 rename lxc-apps/ushahidi/install/{srv/ushahidi/conf => ushahidi_conf}/config.json (100%) rename lxc-apps/ushahidi/install/{srv/ushahidi/conf => ushahidi_conf}/env (100%) create mode 100644 lxc-apps/ushahidi/meta diff --git a/lxc-apps/ushahidi/install.sh b/lxc-apps/ushahidi/install.sh index f75df25..627d8f2 100755 --- a/lxc-apps/ushahidi/install.sh +++ b/lxc-apps/ushahidi/install.sh @@ -3,18 +3,24 @@ set -ev cd $(realpath $(dirname "${0}"))/install -# Check prerequisites -[ ! -e /run/openrc/started/mariadb ] && service mariadb start && STOP_MARIADB=1 +# Create MariaDB instance +mkdir -p /srv/ushahidi/mariadb_conf /srv/ushahidi/mariadb_data +chown 103306:103306 /srv/ushahidi/mariadb_data +cp mariadb_conf/my.cnf /srv/ushahidi/mariadb_conf/my.cnf +chown -R 100000:100000 /srv/ushahidi/mariadb_conf +lxc-execute ushahidi-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --skip-test-db # Create database export USHAHIDI_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') -envsubst /srv/ushahidi/conf/env -cp srv/ushahidi/conf/config.json /srv/ushahidi/conf/config.json +mkdir -p /srv/ushahidi/ushahidi_conf /srv/ushahidi/ushahidi_data +chown 108014:108014 /srv/ushahidi/ushahidi_data +envsubst /srv/ushahidi/ushahidi_conf/env +cp ushahidi_conf/config.json /srv/ushahidi/ushahidi_conf/config.json +chown -R 100000:100000 /srv/ushahidi/ushahidi_conf # Populate database lxc-execute ushahidi -- /srv/ushahidi/platform/bin/phinx migrate -c /srv/ushahidi/platform/application/phinx.php @@ -23,20 +29,15 @@ lxc-execute ushahidi -- /srv/ushahidi/platform/bin/phinx migrate -c /srv/ushahid export USHAHIDI_ADMIN_USER=admin@example.com export USHAHIDI_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=') export USHAHIDI_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${USHAHIDI_ADMIN_PWD}'.encode(), bcrypt.gensalt()).decode().replace('2b', '2y'))") -envsubst /dev/null - lxc-attach -u 8014 -g 8014 ushahidi -- sh -c 'cd /srv/ushahidi/platform; bin/ushahidi dataprovider incoming' >/dev/null - lxc-attach -u 8014 -g 8014 ushahidi -- sh -c 'cd /srv/ushahidi/platform; bin/ushahidi savedsearch' >/dev/null - lxc-attach -u 8014 -g 8014 ushahidi -- sh -c 'cd /srv/ushahidi/platform; bin/ushahidi notification queue' >/dev/null - lxc-attach -u 8014 -g 8014 ushahidi -- sh -c 'cd /srv/ushahidi/platform; bin/ushahidi webhook send' >/dev/null -fi diff --git a/lxc-apps/ushahidi/install/mariadb_conf/my.cnf b/lxc-apps/ushahidi/install/mariadb_conf/my.cnf new file mode 100644 index 0000000..5740333 --- /dev/null +++ b/lxc-apps/ushahidi/install/mariadb_conf/my.cnf @@ -0,0 +1,24 @@ +[mysqld] +skip-external-locking +skip-name-resolve +key_buffer_size = 16M +max_allowed_packet = 1M +table_open_cache = 64 +sort_buffer_size = 512K +net_buffer_length = 8K +read_buffer_size = 256K +read_rnd_buffer_size = 512K +myisam_sort_buffer_size = 8M + +[mysqldump] +quick +max_allowed_packet = 1M + +[mysql] +no-auto-rehash + +[myisamchk] +key_buffer_size = 20M +sort_buffer_size = 20M +read_buffer = 2M +write_buffer = 2M diff --git a/lxc-apps/ushahidi/install/srv/ushahidi/update-conf.sh b/lxc-apps/ushahidi/install/update-conf.sh old mode 100755 new mode 100644 similarity index 100% rename from lxc-apps/ushahidi/install/srv/ushahidi/update-conf.sh rename to lxc-apps/ushahidi/install/update-conf.sh diff --git a/lxc-apps/ushahidi/install/srv/ushahidi/conf/config.json b/lxc-apps/ushahidi/install/ushahidi_conf/config.json similarity index 100% rename from lxc-apps/ushahidi/install/srv/ushahidi/conf/config.json rename to lxc-apps/ushahidi/install/ushahidi_conf/config.json diff --git a/lxc-apps/ushahidi/install/srv/ushahidi/conf/env b/lxc-apps/ushahidi/install/ushahidi_conf/env similarity index 100% rename from lxc-apps/ushahidi/install/srv/ushahidi/conf/env rename to lxc-apps/ushahidi/install/ushahidi_conf/env diff --git a/lxc-apps/ushahidi/lxcfile b/lxc-apps/ushahidi/lxcfile index 5572cca..3100047 100644 --- a/lxc-apps/ushahidi/lxcfile +++ b/lxc-apps/ushahidi/lxcfile @@ -33,8 +33,4 @@ RUN EOF rm aura.patch EOF -MOUNT FILE /srv/ushahidi/conf/env srv/ushahidi/platform/.env -MOUNT FILE /srv/ushahidi/conf/config.json srv/ushahidi/config.json -MOUNT DIR /srv/ushahidi/data srv/ushahidi/platform/application/media/uploads - CMD s6-svscan /etc/services.d diff --git a/lxc-apps/ushahidi/meta b/lxc-apps/ushahidi/meta new file mode 100644 index 0000000..153351a --- /dev/null +++ b/lxc-apps/ushahidi/meta @@ -0,0 +1,29 @@ +{ + "version": "3.12.3-190620", + "meta": { + "title": "Ushahidi", + "desc-cs": "Skupinová reakce na události", + "desc-en": "Group reaction to events", + "license": "GPL", + }, + "containers": { + "ushahidi": { + "image": "ushahidi_3.12.3-190620", + "depends": [ + "ushahidi-mariadb" + ], + "mounts": [ + ["FILE", "/srv/ushahidi/ushahidi_conf/env", "/srv/ushahidi/platform/.env"], + ["FILE", "/srv/ushahidi/ushahidi_conf/config.json", "/srv/ushahidi/config.json"], + ["DIR", "/srv/ushahidi/ushahidi_data", "/srv/ushahidi/platform/application/media/uploads"] + ] + }, + "ushahidi-mariadb": { + "image": "mariadb_10.3.15-190620", + "mounts": [ + ["FILE", "/srv/ushahidi/mariadb_conf/my.cnf", "/etc/my.cnf"], + ["DIR", "/srv/ushahidi/mariadb_data", "/var/lib/mysql"] + ] + } + } +} diff --git a/lxc-apps/ushahidi/uninstall.sh b/lxc-apps/ushahidi/uninstall.sh index 1890160..19a7339 100755 --- a/lxc-apps/ushahidi/uninstall.sh +++ b/lxc-apps/ushahidi/uninstall.sh @@ -1,17 +1,8 @@ #!/bin/sh set -ev -# Remove cronjob -rm -f /etc/periodic/15min/ushahidi - -# Remove service -rm -f /etc/init.d/ushahidi -rc-update -u - -# Drop database and user -[ ! -e /run/openrc/started/mariadb ] && service mariadb start && STOP_MARIADB=1 -echo 'DROP DATABASE IF EXISTS ushahidi; DROP USER IF EXISTS ushahidi;' | lxc-attach mariadb -- mysql -[ ! -z ${STOP_MARIADB} ] && service mariadb stop +# Remove persistent data +rm -rf /srv/ushahidi # Unregister application vmmgr unregister-app ushahidi