#!/bin/sh

URL=$(ip route get 1 | awk '{print $NF;exit}')

sed -i "s|^    \"backend_url\".*|    \"backend_url\": \"http://${URL}:8814/platform\",|" /srv/ushahidi/conf/config.json

FULL_URL='\\\"https:\\\\/\\\\/'${URL}:8414'\\\\/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
