2018-01-24 15:18:55 +01:00
|
|
|
#!/bin/sh
|
2018-10-28 16:04:11 +01:00
|
|
|
set -ev
|
2017-10-26 22:50:04 +02:00
|
|
|
|
2020-03-24 15:15:26 +01:00
|
|
|
# Volumes
|
|
|
|
MARIADB_CONF="${VOLUMES_DIR}/ushahidi/mariadb_conf"
|
|
|
|
MARIADB_DATA="${VOLUMES_DIR}/ushahidi/mariadb_data"
|
|
|
|
USHAHIDI_CONF="${VOLUMES_DIR}/ushahidi/ushahidi_conf"
|
|
|
|
USHAHIDI_DATA="${VOLUMES_DIR}/ushahidi/ushahidi_data"
|
|
|
|
|
2019-10-05 15:40:27 +02:00
|
|
|
# Create MariaDB instance
|
2020-03-24 15:15:26 +01:00
|
|
|
install -o 100000 -g 100000 -m 755 -d ${MARIADB_CONF}
|
|
|
|
install -o 103306 -g 103306 -m 750 -d ${MARIADB_DATA}
|
|
|
|
install -o 100000 -g 100000 -m 644 mariadb_conf/my.cnf ${MARIADB_CONF}/my.cnf
|
|
|
|
spoc-container exec mifosx-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --skip-test-db
|
2017-10-26 22:50:04 +02:00
|
|
|
|
|
|
|
# Create database
|
2019-06-05 18:55:15 +02:00
|
|
|
export USHAHIDI_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
2020-03-24 15:15:26 +01:00
|
|
|
spoc-container start ushahidi-mariadb
|
|
|
|
envsubst <createdb.sql | spoc-container exec ushahidi-mariadb -- mysql
|
|
|
|
|
|
|
|
# Configure Redis
|
|
|
|
install -o 100000 -g 106379 -m 750 -d ${REDIS_CONF}
|
|
|
|
install -o 106379 -g 106379 -m 750 -d ${REDIS_DATA}
|
|
|
|
install -o 100000 -g 106379 -m 640 redis_conf/redis.conf ${REDIS_CONF}/redis.conf
|
|
|
|
spoc-container start ushahidi-redis
|
2017-10-26 22:50:04 +02:00
|
|
|
|
|
|
|
# Configure Ushahidi
|
2020-03-24 15:15:26 +01:00
|
|
|
USHAHIDI_APPKEY=$(spoc-container exec ushahidi -- sh -c 'cd /srv/ushahidi/platform; php artisan key:generate')
|
|
|
|
install -o 108080 -g 100000 -m 750 -d ${USHAHIDI_CONF}
|
|
|
|
install -o 108080 -g 108080 -m 755 -d ${USHAHIDI_DATA}
|
|
|
|
envsubst <ushahidi_conf/env | install -o 108080 -g 100000 -m 640 /dev/stdin ${USHAHIDI_CONF}/env
|
|
|
|
install -o 108080 -g 108080 -m 640 ushahidi_conf/config.json ${USHAHIDI_CONF}/config.json
|
2017-10-26 22:50:04 +02:00
|
|
|
|
|
|
|
# Populate database
|
2020-03-24 15:15:26 +01:00
|
|
|
spoc-container exec ushahidi -- sh -c 'cd /srv/ushahidi/platform; php artisan migrate'
|
2017-10-26 22:50:04 +02:00
|
|
|
|
|
|
|
# Create admin account
|
|
|
|
export USHAHIDI_ADMIN_USER=admin@example.com
|
2019-06-05 18:55:15 +02:00
|
|
|
export USHAHIDI_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
2018-09-16 17:19:13 +02:00
|
|
|
export USHAHIDI_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${USHAHIDI_ADMIN_PWD}'.encode(), bcrypt.gensalt()).decode().replace('2b', '2y'))")
|
2020-03-24 15:15:26 +01:00
|
|
|
envsubst <adminpwd.sql | spoc-container exec ushahidi-mariadb -- mysql ushahidi
|
2018-07-15 21:55:35 +02:00
|
|
|
|
2019-10-05 15:40:27 +02:00
|
|
|
# Stop services required for setup
|
2020-03-24 15:15:26 +01:00
|
|
|
spoc-container stop ushahidi-redis
|
|
|
|
spoc-container stop ushahidi-mariadb
|
2018-10-28 19:50:35 +01:00
|
|
|
|
2018-11-03 15:53:51 +01:00
|
|
|
# Register application
|
2019-02-26 21:12:41 +01:00
|
|
|
vmmgr register-app ushahidi ush "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}"
|