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
|
|
|
|
2019-10-05 15:40:27 +02:00
|
|
|
# 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
|
2019-12-13 21:28:55 +01:00
|
|
|
lxc-execute ushahidi-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --auth-root-socket-user=mysql --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 '+/=')
|
2019-11-30 22:11:38 +01:00
|
|
|
service lxc-ushahidi-mariadb start
|
2019-12-13 21:28:55 +01:00
|
|
|
envsubst <createdb.sql | lxc-attach ushahidi-mariadb -- mysql -u mysql
|
2017-10-26 22:50:04 +02:00
|
|
|
|
|
|
|
# Configure Ushahidi
|
2019-10-05 15:40:27 +02:00
|
|
|
mkdir -p /srv/ushahidi/ushahidi_conf /srv/ushahidi/ushahidi_data
|
2019-10-14 07:59:06 +02:00
|
|
|
chown 108080:108080 /srv/ushahidi/ushahidi_data
|
2019-10-05 15:40:27 +02:00
|
|
|
envsubst <ushahidi_conf/env >/srv/ushahidi/ushahidi_conf/env
|
|
|
|
cp ushahidi_conf/config.json /srv/ushahidi/ushahidi_conf/config.json
|
|
|
|
chown -R 100000:100000 /srv/ushahidi/ushahidi_conf
|
2017-10-26 22:50:04 +02:00
|
|
|
|
|
|
|
# Populate database
|
2018-09-14 09:43:54 +02:00
|
|
|
lxc-execute ushahidi -- /srv/ushahidi/platform/bin/phinx migrate -c /srv/ushahidi/platform/application/phinx.php
|
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'))")
|
2019-12-13 21:28:55 +01:00
|
|
|
envsubst <adminpwd.sql | lxc-attach ushahidi-mariadb -- mysql -u mysql ushahidi
|
2018-09-14 09:43:54 +02:00
|
|
|
|
2018-09-20 15:45:00 +02:00
|
|
|
# Install config update script
|
2019-10-05 15:40:27 +02:00
|
|
|
cp update-conf.sh /srv/ushahidi/update-conf.sh
|
2018-07-15 21:55:35 +02:00
|
|
|
|
2019-10-05 15:40:27 +02:00
|
|
|
# Stop services required for setup
|
2019-11-30 22:11:38 +01:00
|
|
|
service lxc-ushahidi-mariadb stop
|
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}"
|