Introduce Ushahidi app
This commit is contained in:
parent
4fedd99752
commit
20c5161dc5
53
20-ushahidi.sh
Executable file
53
20-ushahidi.sh
Executable file
@ -0,0 +1,53 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SOURCE_DIR=$(realpath $(dirname "${0}"))
|
||||||
|
|
||||||
|
# Install dependencies for Ushahidi
|
||||||
|
apt-get -y --no-install-recommends install php7.0-curl php7.0-gd php7.0-fpm php7.0-json php7.0-imap php7.0-mcrypt php7.0-mysql
|
||||||
|
|
||||||
|
# Install Ushahidi
|
||||||
|
wget https://github.com/ushahidi/platform-release/releases/download/v3.7.1/ushahidi-platform-release-v3.7.1.tar.gz -O /tmp/ushahidi.tar.gz
|
||||||
|
tar xzf /tmp/ushahidi.tar.gz -C /tmp
|
||||||
|
mv /tmp/ushahidi-platform-release-v3.7.1/html /srv/ushahidi
|
||||||
|
rm -f /tmp/ushahidi.tar.gz
|
||||||
|
rm -rf /tmp/ushahidi-platform-release-v3.7.1
|
||||||
|
|
||||||
|
# Create database
|
||||||
|
export USHAHIDI_PWD=$(head -c 18 /dev/urandom | base64)
|
||||||
|
envsubst <${SOURCE_DIR}/ushahidi/tmp/ushahidi-createdb.sql >/tmp/ushahidi-createdb.sql
|
||||||
|
mysql </tmp/ushahidi-createdb.sql
|
||||||
|
|
||||||
|
# Configure Ushahidi
|
||||||
|
envsubst <${SOURCE_DIR}/ushahidi/srv/ushahidi/platform/.env >/srv/ushahidi/platform/.env
|
||||||
|
|
||||||
|
# Populate database
|
||||||
|
cd /srv/ushahidi/platform
|
||||||
|
./bin/phinx migrate -c 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=$(php -r "echo password_hash('${USHAHIDI_ADMIN_PWD}', PASSWORD_BCRYPT);")
|
||||||
|
envsubst <${SOURCE_DIR}/ushahidi/tmp/ushahidi-adminpwd.sql >/tmp/ushahidi-adminpwd.sql
|
||||||
|
mysql ushahidi </tmp/ushahidi-adminpwd.sql
|
||||||
|
rm -f /tmp/ushahidi-adminpwd.sql
|
||||||
|
|
||||||
|
# Create OS user
|
||||||
|
adduser --system --group --home /srv/ushahidi --shell /bin/false ushahidi
|
||||||
|
chown -R ushahidi:www-data /srv/ushahidi/
|
||||||
|
|
||||||
|
# Create PHP and nginx app definition
|
||||||
|
cp ${SOURCE_DIR}/ushahidi/etc/php/7.0/fpm/pool.d/ushahidi.conf /etc/php/7.0/fpm/pool.d/ushahidi.conf
|
||||||
|
cp ${SOURCE_DIR}/ushahidi/etc/nginx/sites-available/ushahidi /etc/nginx/sites-available/ushahidi
|
||||||
|
ln -s /etc/nginx/sites-available/ushahidi /etc/nginx/sites-enabled/ushahidi
|
||||||
|
|
||||||
|
# Restart services
|
||||||
|
systemctl restart php7.0-fpm
|
||||||
|
systemctl restart nginx
|
||||||
|
|
||||||
|
# Install cron job
|
||||||
|
cp ${SOURCE_DIR}/ushahidi/etc/cron.d/ushahidi /etc/cron.d/ushahidi
|
||||||
|
|
||||||
|
# Add portal application definition
|
||||||
|
${SOURCE_DIR}/basic/portal-app-manager.py ushahidi "https://{host}:8002/" "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}"
|
||||||
|
${SOURCE_DIR}/basic/portal-app-manager.py ushahidi-mobile
|
4
ushahidi/etc/cron.d/ushahidi
Normal file
4
ushahidi/etc/cron.d/ushahidi
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
*/5 * * * * ushahidi cd /srv/ushahidi/platform && ./bin/ushahidi dataprovider outgoing >/dev/null
|
||||||
|
*/5 * * * * ushahidi cd /srv/ushahidi/platform && ./bin/ushahidi dataprovider incoming >/dev/null
|
||||||
|
*/5 * * * * ushahidi cd /srv/ushahidi/platform && ./bin/ushahidi savedsearch >/dev/null
|
||||||
|
*/5 * * * * ushahidi cd /srv/ushahidi/platform && ./bin/ushahidi notification queue >/dev/null
|
23
ushahidi/etc/nginx/sites-available/ushahidi
Normal file
23
ushahidi/etc/nginx/sites-available/ushahidi
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
server {
|
||||||
|
listen 8002 ssl http2;
|
||||||
|
listen [::]:8002 ssl http2;
|
||||||
|
|
||||||
|
access_log /var/log/nginx/ushahidi.access.log;
|
||||||
|
error_log /var/log/nginx/ushahidi.error.log;
|
||||||
|
|
||||||
|
root /srv/ushahidi;
|
||||||
|
|
||||||
|
location /platform {
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi.conf;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root/platform/httpdocs/index.php;
|
||||||
|
fastcgi_split_path_info ^(/platform/)(.*)$;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
|
||||||
|
fastcgi_pass unix:/run/php/ushahidi.sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri /index.html;
|
||||||
|
}
|
||||||
|
}
|
12
ushahidi/etc/php/7.0/fpm/pool.d/ushahidi.conf
Normal file
12
ushahidi/etc/php/7.0/fpm/pool.d/ushahidi.conf
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[ushahidi]
|
||||||
|
user = ushahidi
|
||||||
|
group = ushahidi
|
||||||
|
|
||||||
|
listen = /run/php/ushahidi.sock
|
||||||
|
listen.owner = www-data
|
||||||
|
listen.group = www-data
|
||||||
|
|
||||||
|
pm = ondemand
|
||||||
|
pm.max_children = 8
|
||||||
|
|
||||||
|
php_admin_value[open_basedir] = /srv/ushahidi:/tmp
|
5
ushahidi/srv/ushahidi/platform/.env
Normal file
5
ushahidi/srv/ushahidi/platform/.env
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
DB_HOST=localhost
|
||||||
|
DB_NAME=ushahidi
|
||||||
|
DB_USER=ushahidi
|
||||||
|
DB_PASS=${USHAHIDI_PWD}
|
||||||
|
DB_TYPE=MySQLi
|
1
ushahidi/tmp/ushahidi-adminpwd.sql
Normal file
1
ushahidi/tmp/ushahidi-adminpwd.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
UPDATE users SET email = '${USHAHIDI_ADMIN_USER}', password = '${USHAHIDI_ADMIN_HASH}', updated = created WHERE realname = 'admin';
|
2
ushahidi/tmp/ushahidi-createdb.sql
Normal file
2
ushahidi/tmp/ushahidi-createdb.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
CREATE DATABASE ushahidi;
|
||||||
|
GRANT ALL PRIVILEGES ON ushahidi.* To 'ushahidi'@'%' IDENTIFIED BY '${USHAHIDI_PWD}';
|
Loading…
Reference in New Issue
Block a user