#!/bin/sh

CAT=/bin/cat
SYNC=/bin/sync
HOME=/home/mail/#tmp

Usage()
{
	echo "Usage: mltran_del domain mlname"
	exit 1
}
if [ $# -ne 2 ]
then
	Usage
	exit 1
fi

fid=`date +%H%M%S`

user=`awk ' {
        if (/^userid=/) {
                split($1, array, "=");
                print array[2];
        }
                }'  /opt/nec/mail/ums.conf`

if [ "$user" = "" ]
then
	exit 1
fi

# $7 $8 in rulefile match??
crontab -u $user -l >$HOME/rulefile.$fid

awk ' {  if (($7 != "'$1'" || $8 != "'$2'") && $1 != "#")
		print $0 }'  $HOME/rulefile.$fid > $HOME/tmpfile.$fid

crontab -u $user $HOME/tmpfile.$fid
rm $HOME/tmpfile.$fid
rm $HOME/rulefile.$fid

if [ ! -d /home/mail/#failover/cron ]
then
    mkdir -p /home/mail/#failover/cron
fi
cp /var/spool/cron/$user /home/mail/#failover/cron

$SYNC
