#/bin/sh
#BLURB="Choose a sendmail config file."
TMP=/var/log/setup/tmp
if [ -r $TMP/SeTT_PX ]; then
 T_PX="`cat $TMP/SeTT_PX`"
elif [ ! "$1" = "" ]; then
 T_PX=$1
else
 T_PX=/
fi
#if [ -r $T_PX/etc/mail/sendmail.cf ]; then
#  cp -a $T_PX/etc/mail/sendmail.cf $T_PX/etc/mail/sendmail.cf.orig
#fi
if [ -d /mnt/usr/share/sendmail ]; then
 CONFIGDIR=/mnt/usr/share/sendmail
elif [ -d /usr/share/sendmail ]; then
 CONFIGDIR=/usr/share/sendmail
elif [ -d /mnt/cdrom/live/usr/share/sendmail ]; then
 CONFIGDIR=/mnt/cdrom/live/usr/share/sendmail
elif [ -d /cdrom/live/usr/share/sendmail ]; then
 CONFIGDIR=/cdrom/live/usr/share/sendmail
elif [ -d /mnt/linux/usr/share/sendmail ]; then
 CONFIGDIR=/mnt/linux/usr/share/sendmail
elif [ -d /mnt/linux/cdrom/live/usr/share/sendmail ]; then
 CONFIGDIR=/mnt/linux/cdrom/live/usr/share/sendmail
else
 echo "The directory that is supposed to contain your sendmail"
 echo "config files is missing. (something like /usr/share/sendmail...)"
 echo "Sorry :^)"
 exit # where the #$^* are the files??
fi
if [ "$COLOR" = "on" -o -r $TMP/SeTcolor ]; then # use color menus
 dialog --title "SENDMAIL CONFIGURATION" --menu "Sendmail requires a \
configuration file (/etc/mail/sendmail.cf). \
Standard TCP/IP and UUCP versions are provided. \
If none of these proves suitable, you can make \
your own later. (look in \
/usr/share/sendmail)." \
13 72 3 \
"SMTP" "Standard TCP/IP config" \
"SMTP+ACCESS" "TCP/IP with /etc/mail/access control" \
"UUCP" "Use UUCP for mail transmission through a smarthost" \
2> $TMP/reply
 if [ ! $? = 0 ]; then
  rm -f $TMP/reply
  exit
 fi
 SYSTYPE="`cat $TMP/reply`"
 rm -f $TMP/reply
 if [ "$SYSTYPE" = "SMTP" ]; then
  cp $CONFIGDIR/linux.smtp.cf $T_PX/etc/mail/sendmail.cf
 elif [ "$SYSTYPE" = "SMTP+ACCESS" ]; then
  cp $CONFIGDIR/linux.smtp.access.cf $T_PX/etc/mail/sendmail.cf
  if [ ! -r $T_PX/etc/mail/access ]; then
    touch $T_PX/etc/mail/access
    chmod 644 $T_PX/etc/mail/access
  fi
 elif [ "$SYSTYPE" = "UUCP" ]; then
  cp $CONFIGDIR/linux.uucp.cf $T_PX/etc/mail/sendmail.cf
 fi
else # no color!
 echo
 echo "SENDMAIL CONFIG FILE (/etc/mail/sendmail.cf) SELECTION"
 echo
 cat << EOF
1 - Systems actually on the Internet (including SLIP/CSLIP/PPP) that use
    a nameserver.

2 - Machines that use UUCP. In this case, you'll have to edit the name of
    the machine you connect to into the /etc/mail/sendmail.cf file manually
    later.

    You can read README.linux in /usr/share/sendmail for more information.

EOF
 echo -n "Which choice would you like (1/2)? "
 read SYSTYPE;
 while [ 0 ] ; do
  if [ "$SYSTYPE" = "1" ]; then
   echo
   echo "Configuring sendmail..."
   cp $CONFIGDIR/linux.smtp.cf $T_PX/etc/mail/sendmail.cf
   break;
  elif [ "$SYSTYPE" = "2" ]; then
   echo
   echo "Configuring sendmail (remember to edit in the remote machine name later)..."
   cp $CONFIGDIR/linux.uucp.cf $T_PX/etc/mail/sendmail.cf
   break;
  fi
 done
fi
