#!/bin/bash

progname=$0

source ../../bin/script/test-setup.bash
source ../../lib/cascade-lib.bash

prefix=$GEXTVIDEO_INSTALLED/server


# Ensure that the necessary directories exist within the 'installed' area


for d in logs htdocs conf ; do
  if [ ! -e $prefix/$d ] ; then
    echo "Creating $prefix/$d"
    mkdir $prefix/$d
  fi
done

# Install necessary config files to work with Greenstone

gsvidinstalled=$prefix

( cd gslighttpd ; \
  cat lighttpd.conf.in \
  | sed "s%@GSVIDINSTALLED@%$gsvidinstalled%g" \
  > $prefix/conf/lighttpd.conf )

if [ $? != 0 ] ; then
    echo "      Error encountered running *customise install* stage of GSLIGHTTPD.sh"
    exit 1
fi


( cd gslighttpd ; \
  /bin/cp index.html $prefix/htdocs/. )

if [ $? != 0 ] ; then
    echo "      Error encountered running *customise install* stage of GSLIGHTTPD.sh"
    exit 1
fi

