#!/usr/bin/perl
# $Id: prontolock,v 1.2 2001/05/28 00:37:25 muhri Exp $
#This script will lock in /var/spool/mail so that freaking sendmail respects it
#and doesn't append anything to the spoolfile while Pronto is reading it - it
#was a pain to find out that sendmail doesn't respect flock() therefore this 
#script has to be installed setgid just like movemail, however at least its 
#our code.
#Maher <muhri@muhri.net>


$action = $ARGV[0];
$path = $ARGV[1];

if (!$action) { 
	print("This is a script to lock/unlock the mail spool file\n
		for use with Pronto, You shouldn't be running it.\n");

}

if ($action eq "lock") {

	$tmp=">$path.lock";
	if ($tmp=~/(.*)/){$tmp=$1;}
	open LOCK, $tmp or die $!;

}

if ($action eq "unlock") {

	$tmp="$path.lock";
 	if ($tmp=~/(.*)/){$tmp=$1;}
 	unlink $tmp or die $!;

}
