#!/bin/sh

echo "INFO: Updating configurations..." 1>&2
cd /usr/share/ymc-cluster-mgm-core/cli
if [ $? -ne 0 ]; then
  echo "ERROR: Failed to change into directory '/usr/share/ymc-cluster-mgm-core/cli'" 1>&2
  exit 1
fi

for cfg in dnsmasq \
           admin_access \
           keepalived \
           ymc_only_one_running \
           ymc_drbd \
           ymc_simple_heartbeat \
           virtualization \
           monitoring
do
  ymc-config-update-fliwi-config-links 2>/dev/null 1>&2 || true
  echo "INFO: Updating configurations for '$cfg'" 1>&2
  php mgm-$cfg.php --action="make_config"
  if [ $? -ne 0 ]; then
    echo "ERROR: Failed to generate config '$cfg'" 1>&2
    exit 1
  fi
done

echo "INFO: Configurations successfully updated" 1>&2
