#!/bin/bash

function die {
	(>&2 echo "$@")
	exit 1
}

sed -i 's/^change_replication_type = .*/change_replication_type = yes/' /etc/pgsync.conf || die "Can't update pgsync.conf"
service pgsync restart || die "Can't restart pgsync"
sleep 2
sudo -u monitor monrun -r pg_replication_sync
