#!/bin/sh
#
#

if [ "$HTTPPORT" = "" ]
 then
 HTTPPORT=80
 fi

if [ "$FTPPORT" = "" ]
 then
 FTPPORT=21
 fi

if [ "$PROCESSPORT" = "" ]
 then
 PROCESSPORT=8000
 fi

if [ "$HTTPUSERSPASSWD" = "" ]
 then
 HTTPUSERSPASSWD="/etc/passwd.http_users"
 fi

if [ "$HTTP_ROOT" = "" ]
 then
 HTTP_ROOT="/home/ftp"
 fi

if [ "$USER" = "" ]
 then
 USER="root"
 fi

if [ "$COMMENT_WINDOWS_FILTER" = "" ]
 then
 COMMENT_WINDOWS_FILTER="#"
 fi

if [ "$BINDIR" = "" ]
 then
 BINDIR="/usr/local/sbin"
 fi

if [ "$HTTP_USER" = "" ]
 then
 HTTP_USER="ftp"
 fi

if [ "$CONFIGFILENAME" = "" ]
 then
 CONFIGFILENAME="/usr/local/etc/fhttpd.conf"
 fi

if [ -f "${CONFIGFILENAME}.tmpl" ]
 then
 sed -e s' __HTTPPORT__ '"$HTTPPORT"' g' -e 's __FTPPORT__ '"$FTPPORT"' g' \
	-e 's __PROCESSPORT__ '"$PROCESSPORT"' g' \
	-e 's __HTTP_USERS_PASSWD__ '"$HTTPUSERSPASSWD"' g' \
	-e 's __USER__ '"$USER"' g' -e 's __HTTP_ROOT__ '"$HTTP_ROOT"' g'\
	-e 's __COMMENT_WINDOWS_FILTER__ '"$COMMENT_WINDOWS_FILTER"' g' \
  -e 's __HTTP_USER__ '"$HTTP_USER"' g' \
	-e 's __BINDIR__ '"$BINDIR"' g' \
  -e 's __CONFIG_FILE_NAME__ '"$CONFIGFILENAME"' g' \
	< "${CONFIGFILENAME}.tmpl" > "$CONFIGFILENAME"
 else
 echo "No template file ${CONFIGFILENAME}.tmpl"
 fi
