#!/usr/bin/perl
# $Id: prontolock,v 1.1.1.1 2001/01/16 10:25:48 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) { 
		printf("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 $!;

 	}
