## OpenCA - Public Web-Gateway Command
## (c) 1999-2009 by Massimiliano Pala and OpenCA Group
## All Rights Reserved
##
##   File Name: stopAutoCRL
##       Brief: stop Auto (On-Line) CRL Daemon
##     Version: $Revision: 1.2 $
## Description: this script stops the On-Line CRL Daemon
##  Parameters: 

use strict;

sub cmdStopAutoCRL {

	my $pidfile = undef;
	my $pid = undef;

	$pidfile = $AUTOCONF{"var_prefix"}."/tmp/openca_autocrl.pid";

	if( -f "$pidfile" ) {
		my $result = undef;
		my $FD = undef;

		if( not open ( FD, "<$pidfile" )) {
			generalError("Can not open $pidfile!");
		} else {
			$pid = <FD>;
			close( FD );
		}

		$result = POSIX::kill( $pid, 0);
		if( $result gt 0 ) {
			## The process is active!
			$result = POSIX::kill( $pid, 1);
		#	success( 400, "The On-Line CRL Daemon is now disabled!");
		#} else {
		#	success( 400, "The On-Line CRL Daemon is now disabled!");
		}
		$query->param ('cmd', 'statusAutoCRL' );
        	libExecuteCommand ();

	} else {
		cmdStatusAutoCRL();
	}

}

1;
