Spotter-VM/lxc-apps/ushahidi/install.sh

40 lines
1.6 KiB
Bash
Raw Normal View History

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
lxc-execute ushahidi-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 '+/=')
2019-11-30 22:11:38 +01:00
service lxc-ushahidi-mariadb start
2019-10-05 15:40:27 +02:00
envsubst <createdb.sql | lxc-attach ushahidi-mariadb -- 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
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 '+/=')
export USHAHIDI_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${USHAHIDI_ADMIN_PWD}'.encode(), bcrypt.gensalt()).decode().replace('2b', '2y'))")
2019-10-05 15:40:27 +02:00
envsubst <adminpwd.sql | lxc-attach ushahidi-mariadb -- mysql ushahidi
2018-09-14 09:43:54 +02:00
# Install config update script
2019-10-05 15:40:27 +02:00
cp update-conf.sh /srv/ushahidi/update-conf.sh
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
# Register application
2019-02-26 21:12:41 +01:00
vmmgr register-app ushahidi ush "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}"