#!/bin/sh
#
# Configuration script for lightbar.
#
#
case $TERM in
vt*|ansi*|con*|xterm*|linux*|screen*)
     S=[1m
     E=[m
     ;;
*)
     S=
     E=
     ;;
esac

if test "`/bin/echo 'blah\c'`" = "blah\c"
then
	EFLAG="-n"
	ENDER=""
else
	EFLAG=""
	ENDER="\c"
fi
ECHO="/bin/echo ${EFLAG}"

${ECHO} "System type (linux, sunos, generic, bsd) [] ${ENDER}"
read SYSTEM_TYPE

${ECHO} "Mailbox type (path) (sendmail, qmail, other) [] ${ENDER}"
read MAIL_TYPE

if test -z "$MAIL_TYPE"; then
  echo "This is the type of Mail smtp server your using."
  echo "Qmail stores its mail in /home/foobar/Mailbox."
  echo "Sendmail stores its mail to /var/spool/mail/foobar."
  echo "Please specify what type of mailbox your using."
  exit
fi

if [ $MAIL_TYPE = "sendmail" ] || [ $MAIL_TYPE = "S" ] || [ $MAIL_TYPE = "s" ]; then
  MAILV="NOP"
  PCKG="PCKG=-DSENDMAIL"
fi

if [ $MAIL_TYPE = "qmail" ] || [ $MAIL_TYPE = "q" ] || [ $MAIL_TYPE = "Q" ]; then
  MAILV="NOP"
  PCKG="PCKG=-DQMAIL"
fi

if [ $MAIL_TYPE = "other" ] || [ $MAIL_TYPE = "O" ] || [ $MAIL_TYPE = "o" ]; then
  MAILV="NOP"
  echo "Please specify the alternative mailbox."
  echo -n "Mailbox [] "
  read MAILBOX_TYPE
  PCKG="PCKG=-DMAILBOX=\\\"$MAILBOX_TYPE\\\""
fi

tput clear
if [ $SYSTEM_TYPE = "sunos" ]; then
 echo "Please note! Telnetd will not be built! The version distributed"
 echo "with lightbar is NOT compatible with anything except linux. Please"
 echo "obtain the SunOS version from http://www.gnu.net/lightbar. Lightbar"
 echo "will built as usual but note you *have* to have the lightbar"
 echo "in.telnetd daemon."
 echo
 ${ECHO} "Press any key to continue... ${ENDER}"
 read WAIT_DUMB_BASTARD

 LIBS="$LIBS -lsocket -lnsl"
fi

echo
echo "Build ${S}$MACHTYPE${E} binary for ${S}$HOSTTYPE${E} running ${S}$SYSTEM_TYPE${E}"
echo "targets for lightbar will be ${S}dynamiclly${E} linked."
echo "targets for in.telnetd will be ${S}staticlly${E} linked."
echo "Using encryption type ${S}$CRYPT_TYPE${E}"
echo "Using smtp server mailbox ${S}$MAIL_TYPE${E}"
echo
${ECHO} "Values correct (N/y) [] ${ENDER}"
read ANS

if test -z "$ANS"; then
 exit
fi

rm -rf ./source/MConfig
${ECHO} "creating MConfig file... ${ENDER}"
echo $PCKG >> source/MConfig
echo $LIBS >> source/MConfig
echo " done"
echo
echo "Edit 'include/config.h' then compile lightbar with 'make' command"
echo "after that you can execute 'make install' to install lightbar."
echo
	
