#!/bin/sh
#
ID=`id | cut -d"(" -f 2|cut -d")" -f1`
HOST=`hostname`
if [ "$1" != "install" ]; then
cat <<EOF

	Edit this file first to insure the binaries are installed where
	you want them.

	NOTE: the sendmail binary expects to find it's sendmail.cf
	file in the  /etc/ directory - all other file positions are
	defined inside sendmail.cf

	This will install sendmail with the following file protections:

-rwsr-x--x   1 root     root       231192 Jan 30 13:56 /usr/lib/sendmail
-rwx--x--x   1 root     root        50180 May 15 12:10 /usr/lib/makemap
-rwx------   1 root     root        17124 Feb 20 20:05 /etc/sendmail.cf


EOF

echo -n "Hit RETURN to continue"
read ans
cat<<EOF

The following files/directories are also required - as their position depends 
on how you define them in the sendmail.cf file, these positions are just a
suggestion, you will have to install them yourself.

-rwx------   1 root     root         2009 Sep  3 04:03 /usr/lib/sendmail.hf
-rw-r--r--   1 root     root          534 Jan 30 14:31 /etc/aliases

And the directories:

drwx------   2 root     mail         1024 Feb 26 14:38 /var/spool/mqueue/
drwx-wx--x   2 root     mail         1024 Feb 26 14:44 /var/spool/mail/

Note: This works for me using procmail (setuid root) as my local
delivery agent. As you can see, this is a very strong directory
protection. If it doesn't work for your local delivery agent (perhaps 
mail.local), try opening it up a little at a time until it does -
don't just set it 777!!!

	Type "$0 install" to actually do the installation.

EOF

else

if [ $ID != root ]; then
	cat<<EOF
	Sorry, installation must be done by root
EOF
	exit
fi

if [ "./${HOST}.cf" = "" ]; then
	cat<<EOF

	You will need to read the documentation and create a sendmail
	configuration file called "./${HOST}.cf" in this directory before 
	running this script.

EOF
exit
fi
cp sendmail /usr/lib/sendmail
chown root.root /usr/lib/sendmail
chmod 4711 /usr/lib/sendmail
cp ${HOST}.cf /etc/sendmail.cf
chmod 700  /etc/sendmail.cf
cp makemap /usr/lib/makemap
chmod 0755 /usr/lib/makemap
cp sendmail.hf /usr/lib/sendmail.hf
chmod 444 /usr/lib/sendmail.hf
if [ ! -x /bin/mail.local ]; then
	cp mail.local /bin/mail.local
	chown root.mail /bin/mail.local
	chmod 4751 /bin/mail.local
fi
# These are commented out - they may not be appropriate to your configuration
#touch /etc/sendmail.st
#mkdir /var/spool/mail /var/spool/mqueue
#chown root.mail /var/spool/mail /var/spool/mqueue
#chmod 0700 /var/spool/mqueue
#chmod 0711 /var/spool/mail
#cp sendmail.hf /usr/lib/sendmail.hf
#if [ ! -r /etc/aliases ]; then
#	cp aliases /etc/aliases
#fi

fi


