#!/bin/bash

set -e

HACRM=$(ngcp-ha-crm)
case "${HACRM}" in
  pacemaker)
    maintmode=""
    if crm configure show type:property | grep -q maintenance-mode=true; then
      maintmode="maintenance on"
    fi
    /usr/libexec/ngcp-crm-helper <<-CRM
	cib new ngcp-reload-config withstatus force empty
	configure load push /etc/pacemaker/cluster.crm
	$maintmode
	cib commit
	cib use live
	cib delete ngcp-reload-config
CRM
    ;;
  *)
    # Nothing to do
    ;;
esac

exit 0
