2018-01-24 15:18:55 +01:00
|
|
|
#!/bin/sh
|
2017-10-26 22:50:04 +02:00
|
|
|
|
2017-12-04 17:48:37 +01:00
|
|
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/ushahidi
|
2017-10-26 22:50:04 +02:00
|
|
|
|
2018-01-24 15:18:55 +01:00
|
|
|
# Check prerequisites
|
|
|
|
docker image ls | grep -q mariadb || $(realpath $(dirname "${0}"))/mariadb.sh
|
2018-02-03 10:06:16 +01:00
|
|
|
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
|
2017-10-26 22:50:04 +02:00
|
|
|
|
2018-01-24 15:18:55 +01:00
|
|
|
# Build Docker container
|
|
|
|
docker build -t ushahidi ${SOURCE_DIR}
|
2017-10-26 22:50:04 +02:00
|
|
|
|
|
|
|
# Create database
|
|
|
|
export USHAHIDI_PWD=$(head -c 18 /dev/urandom | base64)
|
2018-01-24 15:18:55 +01:00
|
|
|
envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i mariadb mysql
|
2017-10-26 22:50:04 +02:00
|
|
|
|
|
|
|
# Configure Ushahidi
|
2018-02-02 20:16:26 +01:00
|
|
|
mkdir -p /srv/ushahidi/conf /srv/ushahidi/data
|
|
|
|
chown 8014:8014 /srv/ushahidi/data
|
2018-01-27 14:35:16 +01:00
|
|
|
envsubst <${SOURCE_DIR}/srv/ushahidi/conf/env >/srv/ushahidi/conf/env
|
2018-02-06 09:18:59 +01:00
|
|
|
cp ${SOURCE_DIR}/srv/ushahidi/update-ip.sh /srv/ushahidi/update-ip.sh
|
2017-10-26 22:50:04 +02:00
|
|
|
|
|
|
|
# Populate database
|
2018-01-27 14:35:16 +01:00
|
|
|
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
|
2017-10-26 22:50:04 +02:00
|
|
|
|
|
|
|
# Create admin account
|
|
|
|
export USHAHIDI_ADMIN_USER=admin@example.com
|
|
|
|
export USHAHIDI_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
|
2018-01-24 15:18:55 +01:00
|
|
|
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
|
2017-10-26 22:50:04 +02:00
|
|
|
|
2018-01-24 15:18:55 +01:00
|
|
|
# Create Ushahidi service
|
|
|
|
cp ${SOURCE_DIR}/etc/init.d/ushahidi /etc/init.d/ushahidi
|
2018-02-06 21:54:11 +01:00
|
|
|
rc-update add ushahidi
|
2018-01-24 15:18:55 +01:00
|
|
|
service ushahidi start
|
2017-10-26 22:50:04 +02:00
|
|
|
|
2018-01-24 15:18:55 +01:00
|
|
|
# Create nginx app definition
|
|
|
|
cp ${SOURCE_DIR}/etc/nginx/conf.d/ushahidi.conf /etc/nginx/conf.d/ushahidi.conf
|
|
|
|
service nginx reload
|
2017-10-26 22:50:04 +02:00
|
|
|
|
|
|
|
# Install cron job
|
2018-01-24 15:18:55 +01:00
|
|
|
cp ${SOURCE_DIR}/etc/periodic/15min/ushahidi /etc/periodic/15min/ushahidi
|
2017-10-26 22:50:04 +02:00
|
|
|
|
|
|
|
# Add portal application definition
|
2018-01-24 15:18:55 +01:00
|
|
|
portal-app-manager ushahidi "https://{host}:8414/" "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}"
|
2017-12-04 17:38:48 +01:00
|
|
|
portal-app-manager ushahidi-mobile
|