#!/bin/bash


if [ "x$GEXTAMP_INSTALLED" = "x" ] ; then
  echo "Environment variable GEXTAMP_INSTALLED not set" >&2
  echo "Have you sourced the extensions setup file?" >&2
  exit
fi


if [ "x$GEXT_AFREPO" = "x" ] ; then
  echo "Environment variable GEXT_AFREPO not set" >&2
  echo "Have you sourced the extensions setup file?" >&2
  exit
fi

if [ ! -f $GEXT_AFREPO/AFR-SETUP.sh ] ; then
  echo "Generating AFR-SETUP.sh from AFR-SETUP.sh.in"
  /bin/cp $GEXT_AFREPO/AFR-SETUP.sh.in $GEXT_AFREPO/AFR-SETUP.sh
fi

source $GEXT_AFREPO/AFR-SETUP.sh

##echo "*** port = $port"

cat $GEXT_AFREPO/src/DONE.txt \
  | sed "s%@GEXTAMP_INSTALLED@%$GEXTAMP_INSTALLED%g" \
  | sed "s%@4store-port@%$f4store_port%g" \
  | sed "s%@afrepo-http-prefix@%$protocol://$hostname:$port%g" 

