#!/bin/sh
## init_debian_2_x
## changes debian's sendmail.conf in /etc/mail
##
## 20041115-0953:PLD:  Checked and working on 2.2R6

. ./ansi.sh

xamimepath=$1
rcfile="/etc/init.d/sendmail"

# Is this Debian?
if [ -f /etc/debian_version ]; then
	isright=1
	else
	exit 1
	fi


if [ -f $rcfile ]; then
	isright=1
	else 
	exit 1
	fi

alreadydone=`grep xamime $rcfile | wc -l`
if [ $alreadydone -gt 0 ]; then
	printf "Debian init files have already been altered to start Xamime\n"
	exit 0
fi

if [ -e $rcfile ]; then
	printf "$dg Altering init.d sendmail file.. $doff"
	./replaceit --input=$rcfile "- -bd -q" "- -C $xamimepath/xamime.cf -bd -q"
	sleep 2
	count=`grep "xamime.cf" $rcfile | wc -l`
	if [ $count -gt 0 ]
		then
		printf "${don}Success.. $doff\n"
		else
			printf "${dr}Update did not succeed, please add '-C $xamimepath/xamime.cf' manually\n\
			to your $conf_file sendmail startup routine...$doff"
			fi
	else
	printf "$dr Sorry, could not find sendmail startup file\n\
	You have to manually find out how sendmail is started and append\n\n
		$dg -C $xamimepath/xamime.cf$doff\n\n
	${dr}to it.$doff\n"
	fi

