44 lines
1.6 KiB
Bash
Executable File
44 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/ushahidi
|
|
|
|
# Check prerequisites
|
|
docker image ls | grep -q mariadb || $(realpath $(dirname "${0}"))/mariadb.sh
|
|
|
|
# Build Docker container
|
|
docker build -t ushahidi ${SOURCE_DIR}
|
|
|
|
# Create database
|
|
export USHAHIDI_PWD=$(head -c 18 /dev/urandom | base64)
|
|
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i mariadb mysql
|
|
|
|
# Configure Ushahidi
|
|
mkdir -p /srv/ushahidi/conf /srv/ushahidi/data
|
|
chown 8014:8014 /srv/ushahidi/data
|
|
envsubst <${SOURCE_DIR}/srv/ushahidi/conf/env >/srv/ushahidi/conf/env
|
|
|
|
# Populate database
|
|
docker run --rm -h ushahidi --link mariadb -v /srv/ushahidi/conf/env:/srv/ushahidi/platform/.env 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=$(docker run --rm ushahidi php -r "echo password_hash('${USHAHIDI_ADMIN_PWD}', PASSWORD_BCRYPT);")
|
|
envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i mariadb mysql ushahidi
|
|
|
|
# Create Ushahidi service
|
|
cp ${SOURCE_DIR}/etc/init.d/ushahidi /etc/init.d/ushahidi
|
|
rc-update add ushahidi boot
|
|
service ushahidi start
|
|
|
|
# Create nginx app definition
|
|
cp ${SOURCE_DIR}/etc/nginx/conf.d/ushahidi.conf /etc/nginx/conf.d/ushahidi.conf
|
|
service nginx reload
|
|
|
|
# Install cron job
|
|
cp ${SOURCE_DIR}/etc/periodic/15min/ushahidi /etc/periodic/15min/ushahidi
|
|
|
|
# Add portal application definition
|
|
portal-app-manager ushahidi "https://{host}:8414/" "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}"
|
|
portal-app-manager ushahidi-mobile
|