Add Ushahidi IP refresh script

This commit is contained in:
Disassembler 2018-02-06 09:18:59 +01:00
parent d9f00fe35f
commit c44951bc72
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
3 changed files with 10 additions and 0 deletions

View File

@ -17,6 +17,7 @@ envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i mariadb mysql
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
cp ${SOURCE_DIR}/srv/ushahidi/update-ip.sh /srv/ushahidi/update-ip.sh
# 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

View File

@ -7,6 +7,10 @@ depend() {
use dns logger netmount postfix
}
start_pre() {
/srv/ushahidi/update-ip.sh
}
start() {
/usr/bin/docker run -d --rm \
--name ushahidi \

View File

@ -0,0 +1,5 @@
#!/bin/sh
URL=$(ip route get 1 | awk '{print $NF;exit}')
FULL_URL='\\\"https:\\\\/\\\\/'${URL}:8413'\\\\/platform\\\\/api\\\\/v3\\\\/config\\\\/data-provider\\\"'
echo 'UPDATE `config` SET `config_value` = "'${FULL_URL}'" WHERE `group_name` LIKE "data-provider" AND `config_key` LIKE "url";' | docker exec -i mariadb mysql ushahidi