#!/bin/sh

HOST="${1}"
[ "${2}" != "443" ] && HOST="${1}:${2}"

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

API_URL='\\\"https:\\\\/\\\\/'${HOST}'\\\\/platform\\\\/api\\\\/v3\\\\/config\\\\/data-provider\\\"'
echo 'UPDATE `config` SET `config_value` = "'${API_URL}'" WHERE `group_name` LIKE "data-provider" AND `config_key` LIKE "url";' | docker exec -i mariadb mysql ushahidi
