#!/bin/sh
#
# Start the local Meta-HTML Web Servers running.
#
dir=`echo $0 | sed -e 's@/[^/]*$@@'`
if [ "$dir" = "" ]; then dir=`pwd`; fi
PATH=$dir:$PATH
export PATH
export LD_LIBRARY_PATH
LD_LIBRARY_PATH="`echo $dir | sed -e 's@/[^/]*$@@'`/lib:/lib:/usr/lib:$LD_LIBRARY_PATH"
# List of hostnames that should start their own copy of Mhttpd.
MHTTPD_HOSTS=`cat $dir/LOCAL-SITES`

# Start the mhttpd servers.
for site in $MHTTPD_HOSTS; do
  confdir=/www/$site/conf
  if [ -r $confdir/mhttpd.conf ]; then
    echo "Starting server for $site."
    (mhttpd --config $confdir/mhttpd.conf)
    sleep 1
  else
     confdir=/www/$site/mhttpd/conf
     if [ -r $confdir/mhttpd.conf ]; then
	echo "Starting server for $site."
	(mhttpd --config $confdir/mhttpd.conf)
	sleep 1
     else
	echo "Cannot start server for $site: No file $confdir/mhttpd.conf."
     fi
  fi
done
