#!/bin/bash

# @file clearwater-prov-tools
#
# Copyright (C) Metaswitch Networks 2015
# If license terms are provided to you in a COPYING file in the root directory
# of the source code repository by which you are accessing this code, then
# the license outlined in that COPYING file applies to your use.
# Otherwise no rights are granted except for those provided to you by
# Metaswitch Networks in a separate written agreement.

. /etc/clearwater/config

function escape { echo $1 | sed -e 's/\//\\\//g' ; }
sed -e 's/^LOCAL_IP = .*$/LOCAL_IP = "'$(escape "$local_ip")'"/g' \
  -e 's/^\(SIP_DIGEST_REALM\) = .*$/\1 = "'$(escape "$home_domain")'"/g' \
  -e 's/^\(HOMESTEAD_URL\) = .*$/\1 = "'$(escape "$hs_provisioning_hostname")'"/g' \
  -e 's/^\(XDM_URL\) = .*$/\1 = "'$(escape "$xdms_hostname")'"/g' \
  -e 's/^\(LOGS_DIR\) = .*$/\1 = "\/var\/log\/clearwater-prov-tools"/g' \
  </usr/share/clearwater/clearwater-prov-tools/local_settings.py >/tmp/local_settings.py.$$

mv /tmp/local_settings.py.$$ /usr/share/clearwater/clearwater-prov-tools/env/lib/python2.7/site-packages/metaswitch/ellis/local_settings.py
