#!/bin/bash

# Copyright (C) Metaswitch Networks 2016
# 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.

set -ue

. /etc/clearwater/config

# Check we can contact `etcd`
if ! nc -z ${management_local_ip:-$local_ip} 4000
then
  echo "The Clearwater Configuration store (etcd) is not running"
  echo "Start it and then try again"
  exit 1
fi

# Run the recreate_cluster.py script twice, once for each of Chronos and Memcached

/usr/share/clearwater/clearwater-cluster-manager/env/bin/python /usr/share/clearwater/clearwater-cluster-manager/scripts/recreate_cluster.py sprout vellum memcached

/usr/share/clearwater/clearwater-cluster-manager/env/bin/python /usr/share/clearwater/clearwater-cluster-manager/scripts/recreate_cluster.py sprout vellum chronos

