#!/bin/sh

. /etc/athena/rc.conf

#  If $SENDMAILCF is not set, or if /etc/sendmail.cf is not a symlink,
#  then do nothing.
#
if [ -z "$SENDMAILCF" -o ! -L /etc/sendmail.cf ]; then
	exit 0
fi

case "$SENDMAILCF" in
athena)
	dest=athena/sendmail.cf
	;;
outgoing)
	dest=athena/outgoing.cf
	;;
direct)
	dest=athena/direct.cf
	;;
auto)
	. /etc/sysconfig/network
	case "$GATEWAY" in
	18.*)
		dest=athena/sendmail.cf
		;;
	*)
		dest=athena/outgoing.cf
		;;
	esac
	;;
*)
	echo "Error: Invalid SENDMAILCF value of ${SENDMAILCF}."
	exit 1
	;;
esac

if [ ! -r /etc/${dest} ]; then
	echo "Error: /etc/${dest} does not exist."
	exit 1
fi

rm -f /etc/sendmail.cf
ln -s "$dest" /etc/sendmail.cf
exit 0
