Rework Ushahidi
This commit is contained in:
parent
4ac414c691
commit
0f093a1087
@ -3,18 +3,24 @@ set -ev
|
|||||||
|
|
||||||
cd $(realpath $(dirname "${0}"))/install
|
cd $(realpath $(dirname "${0}"))/install
|
||||||
|
|
||||||
# Check prerequisites
|
# Create MariaDB instance
|
||||||
[ ! -e /run/openrc/started/mariadb ] && service mariadb start && STOP_MARIADB=1
|
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
|
# Create database
|
||||||
export USHAHIDI_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
export USHAHIDI_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
||||||
envsubst <createdb.sql | lxc-attach mariadb -- mysql
|
service ushahidi-mariadb start
|
||||||
|
envsubst <createdb.sql | lxc-attach ushahidi-mariadb -- mysql
|
||||||
|
|
||||||
# Configure Ushahidi
|
# Configure Ushahidi
|
||||||
mkdir -p /srv/ushahidi/conf /srv/ushahidi/data
|
mkdir -p /srv/ushahidi/ushahidi_conf /srv/ushahidi/ushahidi_data
|
||||||
chown 8014:8014 /srv/ushahidi/data
|
chown 108014:108014 /srv/ushahidi/ushahidi_data
|
||||||
envsubst <srv/ushahidi/conf/env >/srv/ushahidi/conf/env
|
envsubst <ushahidi_conf/env >/srv/ushahidi/ushahidi_conf/env
|
||||||
cp srv/ushahidi/conf/config.json /srv/ushahidi/conf/config.json
|
cp ushahidi_conf/config.json /srv/ushahidi/ushahidi_conf/config.json
|
||||||
|
chown -R 100000:100000 /srv/ushahidi/ushahidi_conf
|
||||||
|
|
||||||
# Populate database
|
# Populate database
|
||||||
lxc-execute ushahidi -- /srv/ushahidi/platform/bin/phinx migrate -c /srv/ushahidi/platform/application/phinx.php
|
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_USER=admin@example.com
|
||||||
export USHAHIDI_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
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'))")
|
export USHAHIDI_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${USHAHIDI_ADMIN_PWD}'.encode(), bcrypt.gensalt()).decode().replace('2b', '2y'))")
|
||||||
envsubst <adminpwd.sql | lxc-attach mariadb -- mysql ushahidi
|
envsubst <adminpwd.sql | lxc-attach ushahidi-mariadb -- mysql ushahidi
|
||||||
|
|
||||||
# Install cron job
|
|
||||||
cp etc/periodic/15min/ushahidi /etc/periodic/15min/ushahidi
|
|
||||||
|
|
||||||
# Install service
|
|
||||||
cp etc/init.d/ushahidi /etc/init.d/ushahidi
|
|
||||||
rc-update -u
|
|
||||||
|
|
||||||
# Install config update script
|
# Install config update script
|
||||||
cp srv/ushahidi/update-conf.sh /srv/ushahidi/update-conf.sh
|
cp update-conf.sh /srv/ushahidi/update-conf.sh
|
||||||
|
|
||||||
# Stop services required for build
|
# Stop services required for setup
|
||||||
[ ! -z ${STOP_MARIADB} ] && service mariadb stop
|
service ushahidi-mariadb stop
|
||||||
|
|
||||||
# Register application
|
# Register application
|
||||||
vmmgr register-app ushahidi ush "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}"
|
vmmgr register-app ushahidi ush "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}"
|
||||||
|
|
||||||
|
# TODO: cron
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
#!/sbin/openrc-run
|
|
||||||
|
|
||||||
description="Ushahidi container"
|
|
||||||
|
|
||||||
depend() {
|
|
||||||
need mariadb
|
|
||||||
}
|
|
||||||
|
|
||||||
start() {
|
|
||||||
lxc-start ushahidi
|
|
||||||
}
|
|
||||||
|
|
||||||
start_post() {
|
|
||||||
vmmgr register-proxy ushahidi
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_pre() {
|
|
||||||
vmmgr unregister-proxy ushahidi
|
|
||||||
}
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
lxc-stop ushahidi
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
if [ -e /run/openrc/started/ushahidi ]; then
|
|
||||||
lxc-attach -u 8014 -g 8014 ushahidi -- sh -c 'cd /srv/ushahidi/platform; bin/ushahidi dataprovider outgoing' >/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
|
|
24
lxc-apps/ushahidi/install/mariadb_conf/my.cnf
Normal file
24
lxc-apps/ushahidi/install/mariadb_conf/my.cnf
Normal file
@ -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
|
0
lxc-apps/ushahidi/install/srv/ushahidi/update-conf.sh → lxc-apps/ushahidi/install/update-conf.sh
Executable file → Normal file
0
lxc-apps/ushahidi/install/srv/ushahidi/update-conf.sh → lxc-apps/ushahidi/install/update-conf.sh
Executable file → Normal file
@ -33,8 +33,4 @@ RUN EOF
|
|||||||
rm aura.patch
|
rm aura.patch
|
||||||
EOF
|
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
|
CMD s6-svscan /etc/services.d
|
||||||
|
29
lxc-apps/ushahidi/meta
Normal file
29
lxc-apps/ushahidi/meta
Normal file
@ -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"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -ev
|
set -ev
|
||||||
|
|
||||||
# Remove cronjob
|
# Remove persistent data
|
||||||
rm -f /etc/periodic/15min/ushahidi
|
rm -rf /srv/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
|
|
||||||
|
|
||||||
# Unregister application
|
# Unregister application
|
||||||
vmmgr unregister-app ushahidi
|
vmmgr unregister-app ushahidi
|
||||||
|
Loading…
Reference in New Issue
Block a user