#!/usr/bin/perl

#First check whether the cron is already runnin
$cronpresent=`pidof -x updatecheck`;
chomp($cronpresent);
if ($cronpresent)
{
	exit;
}

#Check whether the status file is present, if yes check whether an update is in progress, else restart the update 
if (-e "/etc/multiconf/autostatusindex")
{
	$autoscriptid=`pidof -x autoscript`; 	
	$autoupdateid=`pidof -x autoupdate`; 	
	$autoupid=`pidof -x autoup`; 	
	chomp($autoscriptid);
	chomp($autoupdateid);
	chomp($autoupid);

	if(($autoscriptid) || ($autoupdateid) || ($autoupid))
	{
		exit;
	}
	else
	{
		`echo 1 > /etc/multiconf/autostatusindex`;
		system("/etc/multiconf/scripts/autoscript");
	}	
}
else
{
	exit;
}
