#!/usr/bin/env bash

set -e

eval `ultrapossum-config init`
trap "eval `ultrapossum-config term`" 0

read host

if ! include $host $SLAVES; then
  echo "E: No such slave: $host" 1>&2
  exit 1
fi

ldiffile="$DIRECTORY/$host.ldif"
if ! test -f $ldiffile; then
  echo "E: $host not configured yet.. try later" 1>&2
  exit 1
fi
if ! test -s $ldiffile; then
  echo "E: Initial LDIF file already fetched." 1>&2
  exit 1
fi

cat $ldiffile && /bin/cp /dev/null $ldiffile

exit 0

