#! /sbin/sh
########
#  Product: InternetSrvcs
#  Fileset: INETSVCS-RUN
#  configure
#  @(#) $Revision: 1.3.212.6 $
########
#
#  (c) Copyright Hewlett-Packard Company  1993, 1994
#
#######
#
# Standard initialization
#

exitval=0				# Anticipate success


UTILS="/usr/lbin/sw/control_utils"
if [[ ! -f $UTILS ]]
then
       echo "ERROR:   Cannot find $UTILS"
       exit 1
fi
. $UTILS

#
#
#######
#
# Start of INETSVCS-RUN configure process
#

if [ ! -d /etc/mail ]; then
	mkdir -p /etc/mail
	chmog 0555 bin bin /etc/mail
fi

#
#        Files created by this INETSVCS-RUN configure script
#

newfiles="/etc/rc.config.d/mailservs /etc/mail/sendmail.cf /etc/mail/service.switch /etc/mail/sendmail.cw /etc/mail/aliases /etc/mrouted.conf"

#
#        Update configuration files in /etc from /usr/newconfig
#        only if the scripts do not contain user modifications.
#

if [ -f /etc/mail/sendmail.cf ]; then
	Newcf=`/usr/bin/grep -c "^V6/Berkeley" /etc/mail/sendmail.cf`
	if [ $Newcf -ne 1 ]; then
		echo "NOTE:	Sendmail has been updated to Version 8."
		echo "		Sendmail.cf Version 6 is now required."
		echo "		The old Version 1 sendmail.cf file has been"
		echo "		moved to /etc/mail/#sendmail.cf and a new"
		echo "		Version 6 sendmail.cf has been installed."
		rm /etc/mail/#sendmail.cf
		mv /etc/mail/sendmail.cf /etc/mail/#sendmail.cf
	fi	
fi

if [ ! -f /etc/mail/sendmail.cw ]; then
	echo "NOTE:    The sendmail server now requires a sendmail.cw file"
	echo "         which must contain a list of local host names."
	echo "         A sample /etc/mail/sendmail.cw is being installed"
	echo "         that contains extensive comments on the format."
	echo "         You MUST edit this file before sendmail can be run"
        echo "         as a server."
fi

for file in \
	/etc/rc.config.d/mailservs \
	/etc/mail/sendmail.cf \
	/etc/mail/sendmail.cw \
	/etc/mail/service.switch \
	/etc/mail/aliases \
	/etc/mrouted.conf
do
	newconfig_cp $file
	case  $? in
	  100)
		# 	Original not present, but working copy is present
		newconfig_msgs 100
	    ;;
	  103)
		# 	Original is present and differs from working copy and
		#       from the new file
		newconfig_msgs 103
	    ;;
	esac
done

if [ -f /etc/gated.conf ]
then
	echo "NOTE:    GateD has been updated to Version 3. Minor changes"
	echo "         in the configuration file may be necessary. See the"
	echo "         gated-config(4) man page for new format details."
	echo "         GateD is being left unconfigured for this release."
fi

#
# Remove any existing sendmail frozen configuration, old aliases db files.
# These no longer apply for sendmail v8.
#

rm -f /etc/mail/sendmail.fc
rm -f /etc/mail/aliases.pag
rm -f /etc/mail/aliases.dir

#
# Create any directories needed at run or configure time
#
if [ ! -d /var/spool ]; then
	mkdir -p /var/spool
	chmog 0555 bin bin /var/spool
fi
if [ ! -d /var/spool/mqueue ]; then
	mkdir -p /var/spool/mqueue
	chmog 0755 bin bin /var/spool/mqueue
fi
if [ ! -d /var/spool/rwho ]; then
	mkdir -p /var/spool/rwho
	chmog 0755 bin bin /var/spool/rwho
fi
if [ ! -d /var/run ]; then
	mkdir -p /var/run
	chmog 0555 bin bin /var/run
fi
if [ ! -d /var/mail ]; then
	mkdir -p /var/mail
	chmog 0775 bin mail /var/mail
fi
if [ ! -d /var/tmp ]; then
	mkdir -p /var/tmp
	chmog 0777 /var/tmp
fi

#
#######
# Update the live_files for INETSVCS-RUN
#
#   Add new files to the list.
#

#NOTYET for file in $newfiles
#NOTYET do
#NOTYET		swmodify add $file
#NOTYET done


exit $exitval
