From c44951bc72b946302a53a9a511e646e57ff9603b Mon Sep 17 00:00:00 2001 From: Disassembler Date: Tue, 6 Feb 2018 09:18:59 +0100 Subject: [PATCH] Add Ushahidi IP refresh script --- ushahidi.sh | 1 + ushahidi/etc/init.d/ushahidi | 4 ++++ ushahidi/srv/ushahidi/update-ip.sh | 5 +++++ 3 files changed, 10 insertions(+) create mode 100755 ushahidi/srv/ushahidi/update-ip.sh diff --git a/ushahidi.sh b/ushahidi.sh index e0177a6..15c2f89 100755 --- a/ushahidi.sh +++ b/ushahidi.sh @@ -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 diff --git a/ushahidi/etc/init.d/ushahidi b/ushahidi/etc/init.d/ushahidi index cf31c08..b0de0f3 100755 --- a/ushahidi/etc/init.d/ushahidi +++ b/ushahidi/etc/init.d/ushahidi @@ -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 \ diff --git a/ushahidi/srv/ushahidi/update-ip.sh b/ushahidi/srv/ushahidi/update-ip.sh new file mode 100755 index 0000000..d3d4f24 --- /dev/null +++ b/ushahidi/srv/ushahidi/update-ip.sh @@ -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