#!/bin/bash

# This script aims to install all the agents supported by the Ubuntu community
# into resource-agents-supported binary package.

set -x

readonly SUPPORTED_AGENTS="debian/resource-agents-supported"
readonly RESOURCE_AGENTS="debian/resource-agents"

mkdir -p $SUPPORTED_AGENTS/usr/share/resource-agents/ocft/configs/ \
	 $SUPPORTED_AGENTS/usr/share/man/man7/ \
	 $SUPPORTED_AGENTS/usr/lib/ocf/resource.d/heartbeat/

for agent in $(cat debian/supported-agents); do
  mv $RESOURCE_AGENTS/usr/lib/ocf/resource.d/heartbeat/$agent \
     $SUPPORTED_AGENTS/usr/lib/ocf/resource.d/heartbeat/
  mv $RESOURCE_AGENTS/usr/share/man/man7/ocf_heartbeat_$agent.7 \
     $SUPPORTED_AGENTS/usr/share/man/man7/
  mv $RESOURCE_AGENTS/usr/share/resource-agents/ocft/configs/$agent \
     $SUPPORTED_AGENTS/usr/share/resource-agents/ocft/configs/
done
