Spotter-VM/ushahidi/install.sh
Disassembler ce325cf3d0
Squashed commit of the following:
- Bump basic OS to Alpine 3.9
 - Restructure repo and add layer versioning
 - Use JSON for all metadata
 - Merge abuild branch (but without abuild)
2019-02-26 20:24:02 +01:00

43 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
set -ev
cd $(realpath $(dirname "${0}"))/install
# Check prerequisites
[ ! -e /run/openrc/started/mariadb ] && service mariadb start && STOP_MARIADB=1
# Create database
export USHAHIDI_PWD=$(head -c 18 /dev/urandom | base64)
envsubst <createdb.sql | lxc-attach mariadb -- mysql
# Configure Ushahidi
mkdir -p /srv/ushahidi/conf /srv/ushahidi/data
chown 8014:8014 /srv/ushahidi/data
envsubst <srv/ushahidi/conf/env >/srv/ushahidi/conf/env
cp srv/ushahidi/conf/config.json /srv/ushahidi/conf/config.json
# Populate database
lxc-execute ushahidi -- /srv/ushahidi/platform/bin/phinx migrate -c /srv/ushahidi/platform/application/phinx.php
# Create admin account
export USHAHIDI_ADMIN_USER=admin@example.com
export USHAHIDI_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
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
# 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
cp srv/ushahidi/update-conf.sh /srv/ushahidi/update-conf.sh
# Stop services required for build
[ ! -z ${STOP_MARIADB} ] && service mariadb stop
# Register application
vmmgr register-app ushahidi "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}"