[vhffs-dev] [svn] commit: r102 - in /trunk: vhffs-api/src/Vhffs/ vhffs-api/src/Vhffs/Robots/ vhffs-panel/mailinglist/ vhffs-robots/src/

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Author: soda
Date: Fri Dec  9 17:25:15 2005
New Revision: 102

Log:
- Ajout de fichiers de lock sur la moitié des robots
- Amélioration de la page spécifique aux projets
- Création d'un fichier de log et de la fonction vhffs_log( "str" )
- La moitié des robots savent logguer maintenant


Modified:
    trunk/vhffs-api/src/Vhffs/Robots.pm
    trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm
    trunk/vhffs-api/src/Vhffs/Robots/Postgres.pm
    trunk/vhffs-api/src/Vhffs/Robots/User.pm
    trunk/vhffs-api/src/Vhffs/Robots/Web.pm
    trunk/vhffs-panel/mailinglist/prefs.pl
    trunk/vhffs-robots/src/create_cvs.pl
    trunk/vhffs-robots/src/create_dns.pl
    trunk/vhffs-robots/src/create_groups.pl
    trunk/vhffs-robots/src/create_homes.pl
    trunk/vhffs-robots/src/create_mail.pl
    trunk/vhffs-robots/src/create_ml.pl
    trunk/vhffs-robots/src/create_mysql.pl
    trunk/vhffs-robots/src/create_pgsql.pl
    trunk/vhffs-robots/src/create_svn.pl
    trunk/vhffs-robots/src/create_web.pl
    trunk/vhffs-robots/src/cvs_fixperms.pl
    trunk/vhffs-robots/src/cvsanonymous.pl
    trunk/vhffs-robots/src/delete_cvs.pl
    trunk/vhffs-robots/src/delete_dns.pl
    trunk/vhffs-robots/src/delete_group.pl
    trunk/vhffs-robots/src/mailing.pl

Modified: trunk/vhffs-api/src/Vhffs/Robots.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Robots.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Robots.pm Fri Dec  9 17:25:15 2005
@@ -1,8 +1,36 @@
 #!/usr/bin/perl
 
 use Vhffs::Functions;
+use LockFile::Simple qw(lock trylock unlock);
+use constant
+{
+	LOCKFILE => "/tmp/vhffslock",
+	LOGFILE  => "/var/log/vhffs"
+};
 
 package Vhffs::Robots;
+
+sub lock
+{
+	LockFile::Simple::lock( "/tmp/vhffslock" ) or exit( 1 );
+	return 0;
+}
+
+sub unlock
+{
+	LockFile::Simple::unlock( "/tmp/vhffslock" );
+	return 0;
+}
+
+sub vhffs_log
+{
+	my $sent = shift;
+	if( open( FILE , ">>".LOGFILE ) )
+	{
+		print FILE $sent."\n";
+		close FILE ;
+	}
+}
 
 sub link_to_group
 {

Modified: trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm Fri Dec  9 17:25:15 2005
@@ -119,9 +119,9 @@
 
 sub create_db
 {       
-        my ( $main , $dbname ) = @_;
-
-        my $db = new Vhffs::Services::Mysql( $main , $dbname );
+		my $main = shift;
+		my $db = shift;
+
         my $query;
                 
         if( ( defined $db ) && ( $db->fetch > 0 ) )

Modified: trunk/vhffs-api/src/Vhffs/Robots/Postgres.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Postgres.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Robots/Postgres.pm Fri Dec  9 17:25:15 2005
@@ -80,9 +80,9 @@
 
 sub create_db
 {
-	my ( $main , $dbname ) = @_;
+	my $main = shift;
+	my $pg = shift;
 
-	my $pg = new Vhffs::Services::Postgres( $main , $dbname );
 	my $db = pgsql_admin_db_connect( $main );
 	
 	if( $pg->fetch > 0 )

Modified: trunk/vhffs-api/src/Vhffs/Robots/User.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/User.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Robots/User.pm Fri Dec  9 17:25:15 2005
@@ -88,8 +88,8 @@
 sub create_home
 {
 	my( $main , $username , $user , $homedir , @subdirs , $path , $value );
-
-	( $main , $username ) = @_;
+	$main = shift;
+	$user = shift;
 
 	$user = new Vhffs::User( $main , $username , '401');
 	

Modified: trunk/vhffs-api/src/Vhffs/Robots/Web.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Web.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Robots/Web.pm Fri Dec  9 17:25:15 2005
@@ -38,11 +38,9 @@
 {
 	use Vhffs::Group;
 
-	my( $main , $servername );
+	my $main = shift;
+	my $web = shift;
 
-	( $main , $servername ) = @_;
-
-	$web = new Vhffs::Services::Httpd( $main , $servername , '401');
 	if( ( defined $web ) && ( $web->fetch > 0 ) ) 
 	{
 		$web->add_history( "Ok, the robot take the creation of this object. Web directory will be created");

Modified: trunk/vhffs-panel/mailinglist/prefs.pl
==============================================================================
--- trunk/vhffs-panel/mailinglist/prefs.pl (original)
+++ trunk/vhffs-panel/mailinglist/prefs.pl Fri Dec  9 17:25:15 2005
@@ -31,10 +31,18 @@
 my $cgi = $panel->{'cgi'};
 my $domain = $cgi->param("domain");
 my $lpart = $cgi->param("local");
+my $name = $cgi->param("name");
 my $template;
 my $subtemplate;
 
 my $templatedir = $vhffs->get_config->get_templatedir;
+
+#defined name in CGI overwrite lpart and domain cgi
+if( defined $name )
+{
+	( $lpart , $domain ) =  ( $name =~ /(.+)\@(.+)/ );
+
+}
 
 my $list = new Vhffs::Services::Mailing( $vhffs , $lpart , $domain , $user , $group );
 
@@ -43,7 +51,7 @@
 {
 
 	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
-	my $message = gettext( "Cannot get informations on this object");
+	my $message = gettext( "Cannot get informations on this object".$lpart."/".$domain);
 	$template->param( MESSAGE => $message );
 
 }

Modified: trunk/vhffs-robots/src/create_cvs.pl
==============================================================================
--- trunk/vhffs-robots/src/create_cvs.pl (original)
+++ trunk/vhffs-robots/src/create_cvs.pl Fri Dec  9 17:25:15 2005
@@ -2,22 +2,28 @@
 
 
 use Vhffs::Robots::Cvs;
+use Vhffs::Robots;
 use Vhffs::Main;
+
+lock;
 
 
 my $main = init Vhffs::Main;
-my $lol = Vhffs::Robots::Cvs::get_all_cvs_to_create( $main );
-my $cvs;
+my $cvs = Vhffs::Services::Cvs::getall( $main , Vhffs::Constants::WAITING_FOR_CREATION , undef , undef  );
+my $c;
 
-foreach( keys %{$lol} )
+foreach $c ( @{$cvs} )
 {
-	my $cvs = new Vhffs::Services::Cvs( $main , $_ );
-
-
-	if( ( defined $cvs ) && ( $cvs->fetch > 0 ))
-	{
-		Vhffs::Robots::Cvs::create_cvs( $cvs );
-	}
+		if( Vhffs::Robots::Cvs::create_cvs( $cvs ) > 0 )
+		{
+			vhffs_log( sprintf( "CVS %s is created" , $c->get_cvsroot ) );
+		}
+		else
+		{
+			vhffs_log( sprintf( "cannot create %s CVS repository" , $c->get_cvsroot ) );
+		}
 }
 
+unlock;
 
+exit 0;

Modified: trunk/vhffs-robots/src/create_dns.pl
==============================================================================
--- trunk/vhffs-robots/src/create_dns.pl (original)
+++ trunk/vhffs-robots/src/create_dns.pl Fri Dec  9 17:25:15 2005
@@ -2,9 +2,12 @@
 
 
 use Vhffs::Robots::DNS;
+use Vhffs::Robots;
 use Vhffs::Main;
 
 use strict;
+
+lock;
 
 my $main = init Vhffs::Main;
 my $tocreate = Vhffs::Services::DNS::getall( $main , Vhffs::Constants::WAITING_FOR_CREATION );
@@ -16,9 +19,18 @@
 	{
         $dns->set_status( Vhffs::Constants::ACTIVATED );
         $dns->activate;
-        $dns->commit;
+        if( $dns->commit > 0 )
+		{
+			vhffs_log( sprintf( "Create domain %s" , $dns->get_domain  ) );
+		}
+		else
+		{
+			vhffs_log( sprintf( "Cannot create domain %s" , $dns->get_domain  ) );
+		}
 
 	}
 }
 
+unlock;
 
+exit 0;

Modified: trunk/vhffs-robots/src/create_groups.pl
==============================================================================
--- trunk/vhffs-robots/src/create_groups.pl (original)
+++ trunk/vhffs-robots/src/create_groups.pl Fri Dec  9 17:25:15 2005
@@ -3,7 +3,10 @@
 
 use Vhffs::Main;
 use Vhffs::Group;
+use Vhffs::Robots;
 use Vhffs::Robots::Group;
+
+lock;
 
 my $main = init Vhffs::Main;
 my $groups = Vhffs::Group::getall( $main , Vhffs::Constants::WAITING_FOR_CREATION );
@@ -11,6 +14,16 @@
 
 foreach $group ( @{$groups} )
 {
-	Vhffs::Robots::Group::create_groupdir( $main , $group );
+	if( Vhffs::Robots::Group::create_groupdir( $main , $group ) < 0 )
+	{
+		vhffs_log( sprintf( "cannot create group %s " , $group->get_groupname ) );
+	}
+	else
+	{
+		vhffs_log( sprintf( "create group %s " , $group->get_groupname ) );
+	}
 }
 
+unlock;
+
+exit 0;

Modified: trunk/vhffs-robots/src/create_homes.pl
==============================================================================
--- trunk/vhffs-robots/src/create_homes.pl (original)
+++ trunk/vhffs-robots/src/create_homes.pl Fri Dec  9 17:25:15 2005
@@ -1,20 +1,26 @@
 #!/usr/bin/perl
 
+#This robot creates home directory of each users
 
 use Vhffs::Robots::User;
+use Vhffs::Robots;
 use Vhffs::Main;
-use Data::Dumper;
 
+lock;
 
 my $main = init Vhffs::Main;
-my $homes = Vhffs::Robots::User::get_all_home_to_create( $main );
+my $users = Vhffs::User::getall( $main , Vhffs::Constants::WAITING_FOR_CREATION , undef );
 my $user;
 
-foreach( keys %{$homes} )
+foreach $user ( @{$users} )
 {
-	if( Vhffs::Robots::User::create_home( $main , $_ ) < 0 )
+	if( Vhffs::Robots::User::create_home( $main , $user ) < 0 )
 	{
-		print "Error while creating home for $_\n";
+		print sprintf( "Error while creating home for %s\n" , $user->get_username);
 	}
 }
 
+unlock();
+
+exit 0;
+

Modified: trunk/vhffs-robots/src/create_mail.pl
==============================================================================
--- trunk/vhffs-robots/src/create_mail.pl (original)
+++ trunk/vhffs-robots/src/create_mail.pl Fri Dec  9 17:25:15 2005
@@ -1,17 +1,34 @@
 #!/usr/bin/perl
 
+#This robot create mail domain
+#It actives it
 
 use Vhffs::Robots::Mail;
+use Vhffs::Robots;
 use Vhffs::Main;
-use Data::Dumper;
+
+lock;
+
+my $main = init Vhffs::Main;
+my $mails = Vhffs::Services::Mail::getall( $main , Vhffs::Constants::WAITING_FOR_CREATION );
+my $m;
 
 
-my $main = init Vhffs::Main;
-my $mails = Vhffs::Robots::Mail::get_all_mail_to_create( $main );
+foreach $m ( @{$mails} )
+{
+	$mail->add_history( "Robots will activated this mail domain" );
+	$mail->set_status( Vhffs::Constants::ACTIVATED );
+	if( $mail->commit > 0 )
+	{
+		vhffs_log( sprintf( "Create mail domain %s" , $m->get_domain ) );
+	}
+	else
+	{
+		vhffs_log( sprintf( "cannot create mail domain %s" , $m->get_domain ) );
+	}
+}
+
+unlock;
 
 
-foreach( keys %{$mails} )
-{
-	Vhffs::Robots::Mail::create_mail( $main , $_ );
-}
-
+exit 0;

Modified: trunk/vhffs-robots/src/create_ml.pl
==============================================================================
--- trunk/vhffs-robots/src/create_ml.pl (original)
+++ trunk/vhffs-robots/src/create_ml.pl Fri Dec  9 17:25:15 2005
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 
-
 use Vhffs::Main;
+use Vhffs::Robots;
 use Vhffs::Constants;
 use Vhffs::Services::Mailing;
 
@@ -12,6 +12,15 @@
 foreach $ml ( @{$mls} )
 {
 	$ml->set_status( Vhffs::Constants::ACTIVATED );
-	$ml->commit;
+	if( $ml->commit < 0 )
+	{
+		vhffs_log( sprintf( "Cannot create list %s", $ml->get_title ));
+	}
+	else
+	{
+		vhffs_log( sprintf( "Create list %s", $ml->get_title ));
+	}
 }
 
+exit 0;
+

Modified: trunk/vhffs-robots/src/create_mysql.pl
==============================================================================
--- trunk/vhffs-robots/src/create_mysql.pl (original)
+++ trunk/vhffs-robots/src/create_mysql.pl Fri Dec  9 17:25:15 2005
@@ -1,21 +1,34 @@
 #!/usr/bin/perl
 
-require 5.004;
 use strict;
 use POSIX;
 use locale;
-use Locale::gettext;
+use Vhffs::Robots;
+use Vhffs::Services::Mysql;
 use Vhffs::Robots::Mysql;
+use Vhffs::Constants;
 use Vhffs::Main;
-use Data::Dumper;
+
+lock();
+
+my $main = init Vhffs::Main;
+my $dbs = Vhffs::Services::Mysql::getall( $main , Vhffs::Constants::WAITING_FOR_CREATION , undef , undef );
+my $db;
 
 
-my $main = init Vhffs::Main;
-my $dbs = Vhffs::Robots::Mysql::get_all_db_to_create( $main );
+foreach $db ( @{$dbs} )
+{
+	if( Vhffs::Robots::Mysql::create_db( $main , $db ) < 0 )
+	{
+		vhffs_log( sprintf("Cannot create MySQL database %s",$db->get_dbname) );
+
+	}
+	else
+	{
+		vhffs_log( sprintf("Create MySQL database %s",$db->get_dbname) );
+	}
+}
 
 
-foreach( keys %{$dbs} )
-{
-	Vhffs::Robots::Mysql::create_db( $main , $_ );
-}
-
+unlock();
+exit 0;

Modified: trunk/vhffs-robots/src/create_pgsql.pl
==============================================================================
--- trunk/vhffs-robots/src/create_pgsql.pl (original)
+++ trunk/vhffs-robots/src/create_pgsql.pl Fri Dec  9 17:25:15 2005
@@ -3,15 +3,26 @@
 
 use Vhffs::Robots::Postgres;
 use Vhffs::Main;
-use Data::Dumper;
+use Vhffs::Robots;
+
+lock();
+
+my $main = init Vhffs::Main;
+my $dbs = Vhffs::Services::Postgres::getall( $main );
+my $db;
+
+foreach $db ( @{$dbs} )
+{
+	if( Vhffs::Robots::Postgres::create_db( $main , $db ) < 0 )
+	{
+		vhffs_log( sprintf("Cannot create PostgreSQL database %s",$db->get_dbname) );
+	}
+	else
+	{
+		vhffs_log( sprintf("Create PostgreSQL database %s",$db->get_dbname) );
+	}
+}
 
 
-my $main = init Vhffs::Main;
-my $dbs = Vhffs::Robots::Postgres::get_all_db_to_create( $main );
-
-
-foreach( keys %{$dbs} )
-{
-	Vhffs::Robots::Postgres::create_db( $main , $_ );
-}
-
+unlock();
+exit( 0 );

Modified: trunk/vhffs-robots/src/create_svn.pl
==============================================================================
--- trunk/vhffs-robots/src/create_svn.pl (original)
+++ trunk/vhffs-robots/src/create_svn.pl Fri Dec  9 17:25:15 2005
@@ -1,9 +1,12 @@
 #!/usr/bin/perl
 
 use Vhffs::Main;
+use Vhffs::Robots;
 use Vhffs::Robots::Svn;
 use Vhffs::Services::Svn;
 use Vhffs::Constants;
+
+lock;
 
 my $vhffs = init Vhffs::Main;
 my $repos = Vhffs::Services::Svn::getall( $vhffs , Vhffs::Constants::WAITING_FOR_CREATION);
@@ -12,7 +15,18 @@
 {
 	if( $svn->fetch >= 0)
 	{
-		Vhffs::Robots::Svn::create_repo( $vhffs , $svn );
+		
+		if( Vhffs::Robots::Svn::create_repo( $vhffs , $svn ) < 0 )
+		{
+			vhffs_log( sprintf( "Cannot create SVN %s" , $svn->get_reponame ));
+		}
+		else
+		{
+			vhffs_log( sprintf( "Create SVN %s" , $svn->get_reponame ));
+		}
 	}
 }
 
+
+unlock;
+exit 0;

Modified: trunk/vhffs-robots/src/create_web.pl
==============================================================================
--- trunk/vhffs-robots/src/create_web.pl (original)
+++ trunk/vhffs-robots/src/create_web.pl Fri Dec  9 17:25:15 2005
@@ -2,16 +2,27 @@
 
 
 use Vhffs::Robots::Web;
+use Vhffs::Services::Httpd;
+use Vhffs::Robots;
 use Vhffs::Main;
-use Data::Dumper;
 
+Vhffs::Robots::lock();
 
 my $main = init Vhffs::Main;
-my $webs = Vhffs::Robots::Web::get_all_web_to_create( $main );
+my $webs = Vhffs::Services::Httpd::getall( $main , Vhffs::Constants::WAITING_FOR_CREATION , undef, undef );
+my $web;
 
-
-foreach( keys %{$webs} )
+foreach $web ( @{$webs} )
 {
-	Vhffs::Robots::Web::create_web( $main , $_ );
+	if( Vhffs::Robots::Web::create_web( $main , $web ) < 0 )
+	{
+		vhffs_log( sprintf( "Cannot create web %s" , $web->get_servername ) );
+	}
+	else
+	{
+		vhffs_log( sprintf( "Create web %s" , $web->get_servername ) );
+	}
 }
 
+Vhffs::Robots::unlock();
+

Modified: trunk/vhffs-robots/src/cvs_fixperms.pl
==============================================================================
--- trunk/vhffs-robots/src/cvs_fixperms.pl (original)
+++ trunk/vhffs-robots/src/cvs_fixperms.pl Fri Dec  9 17:25:15 2005
@@ -10,9 +10,12 @@
 
 
 use Vhffs::Main;
+use Vhffs::Robots;
 use Vhffs::Functions;
 use Vhffs::Constants;
 use Vhffs::Services::Cvs;
+
+lock;
 
 my $main = init Vhffs::Main;
 my $cvss = Vhffs::Services::Cvs::getall( $main , Vhffs::Constants::WAITING_FOR_MODIFICATION );
@@ -24,14 +27,20 @@
 {
 	if( $cvs->is_public == 0 )
 	{
+		vhffs_log( sprintf( "CVS fixperm (private) for %s", $cvs->get_cvsroot ));
 		$cvs->add_history("CVS is now private");
 		Vhffs::Functions::chmod_recur( $cvs->get_dir , 0660 , 02770 );
 	}
 	else
 	{
+		vhffs_log( sprintf( "CVS fixperm (public) for %s", $cvs->get_cvsroot ));
 		$cvs->add_history("CVS is now public");
 		Vhffs::Functions::chmod_recur( $cvs->get_dir , 0664 , 02775 );
 	}
 	$cvs->set_status( Vhffs::Constants::ACTIVATED );
 	$cvs->commit;
 }
+
+unlock;
+
+exit 0;

Modified: trunk/vhffs-robots/src/cvsanonymous.pl
==============================================================================
--- trunk/vhffs-robots/src/cvsanonymous.pl (original)
+++ trunk/vhffs-robots/src/cvsanonymous.pl Fri Dec  9 17:25:15 2005
@@ -14,8 +14,10 @@
 use Vhffs::User;
 use Vhffs::Group;
 
+Vhffs::Robots::lock;
+
 my $main = init Vhffs::Main;
-my $cvss = Vhffs::Services::Cvs::getall( $main );
+my $cvss = Vhffs::Services::Cvs::getall( $main  , Vhffs::Constants::WAITING_FOR_MODIFICATION, undef , undef );
 my $cvs;
 my $dir;
 
@@ -39,6 +41,7 @@
     # Change files if cvs is public
     if( $cvs->is_public == 1 )
     {
+		vhffs_log( sprintf("CVS, put repository %s public" , $cvs->get_cvsroot));
 	open( FILE , ">$readers_file" ) or die( "cannot open $readers_file" );
 	print FILE "anonymous";
 	close( FILE );
@@ -53,6 +56,7 @@
     }
 	else
 	{
+		vhffs_log( sprintf("CVS, put repository %s private" , $cvs->get_cvsroot));
 		if( -f $readers_file )
 		{
 			unlink( $readers_file );
@@ -64,3 +68,7 @@
 		}
 	}
 }
+
+Vhffs::Robots::unlock;
+
+exit 0;

Modified: trunk/vhffs-robots/src/delete_cvs.pl
==============================================================================
--- trunk/vhffs-robots/src/delete_cvs.pl (original)
+++ trunk/vhffs-robots/src/delete_cvs.pl Fri Dec  9 17:25:15 2005
@@ -4,8 +4,10 @@
 use Vhffs::Robots::Cvs;
 use Vhffs::Services::Cvs;
 use Vhffs::Constants;
+use Vhffs::Robots;
 use Vhffs::Main;
 
+lock;
 
 my $main = init Vhffs::Main;
 my $lol = Vhffs::Services::Cvs::getall( $main , Vhffs::Constants::TO_DELETE );
@@ -15,9 +17,27 @@
 {
     if( ( defined $cvs ) && ( $cvs->fetch > 0 ))
     {
-		print "Will delete CVS repository " . $cvs->get_cvsroot . "\n";
-        Vhffs::Robots::Cvs::delete_cvs( $cvs );
-		$cvs->delete;
+        if( Vhffs::Robots::Cvs::delete_cvs( $cvs ) > 0 )
+		{
+			vhffs_log( sprintf( "Delete files from %s", $cvs->get_cvsroot ));
+		}
+		else
+		{
+			vhffs_log( sprintf( "Cannot delete files from %s", $cvs->get_cvsroot ));
+		}
+		
+		if( $cvs->delete > 0 )
+		{
+			vhffs_log( sprintf( "Delete CVS object %s", $cvs->get_cvsroot ));
+		}
+		else
+		{
+			vhffs_log( sprintf( "Cannot delete CVS object %s", $cvs->get_cvsroot ));
+		}
     }
 }
 
+
+unlock;
+
+exit 0;

Modified: trunk/vhffs-robots/src/delete_dns.pl
==============================================================================
--- trunk/vhffs-robots/src/delete_dns.pl (original)
+++ trunk/vhffs-robots/src/delete_dns.pl Fri Dec  9 17:25:15 2005
@@ -1,10 +1,12 @@
 #!/usr/bin/perl
 
-
+use Vhffs::Robots;
 use Vhffs::Robots::DNS;
 use Vhffs::Main;
 
 use strict;
+
+lock;
 
 my $main = init Vhffs::Main;
 my $dns;
@@ -14,7 +16,17 @@
 {
 	foreach $dns ( @{$todelete} )
 	{
-		$dns->delete;
+		if( $dns->delete > 0 )
+		{
+			vhffs_log( sprintf( "Delete %s", $dns->get_domain ));
+		}
+		else
+		{
+			vhffs_log( sprintf( "Cannot delete domain name %s", $dns->get_domain ));
+		}
 	}
 }
 
+
+unlock;
+exit 0;

Modified: trunk/vhffs-robots/src/delete_group.pl
==============================================================================
--- trunk/vhffs-robots/src/delete_group.pl (original)
+++ trunk/vhffs-robots/src/delete_group.pl Fri Dec  9 17:25:15 2005
@@ -13,6 +13,9 @@
 use Vhffs::Services::Mysql;
 use Vhffs::Services::Postgres;
 use Vhffs::Services::Svn;
+use Vhffs::Robots;
+
+Vhffs::Robots::lock;
 
 my $vhffs = init Vhffs::Main;
 my $groups = Vhffs::Group::getall( $vhffs , Vhffs::Constants::TO_DELETE );
@@ -23,14 +26,14 @@
 
 foreach $group ( @{$groups} )
 {
-	print "Will try to delete group ". $group->get_groupname . "\n";
+	vhffs_log( sprintf(  "Will try to delete group %s",  $group->get_groupname));
 	$ok = 1;
 
     $objects = Vhffs::Services::Cvs::getall( $vhffs , undef , undef , $group );
 	$ok = 0 if( defined $objects );
     foreach $object ( @{$objects} )
     {
-		printf "\tRemain cvs\n";
+		vhffs_log( sprintf( "Remain cvs for group %s before delete" , $group->get_groupname ));
         $object->set_status( Vhffs::Constants::TO_DELETE );
 		$object->commit;
     }
@@ -39,7 +42,7 @@
 	$ok = 0 if( defined $objects );
     foreach $object ( @{$objects} )
     {
-		printf "\tRemain svn\n";
+		vhffs_log( sprintf( "Remain svn for group %s before delete" , $group->get_groupname ));
         $object->set_status( Vhffs::Constants::TO_DELETE );
 		$object->commit;
     }
@@ -48,7 +51,7 @@
 	$ok = 0 if( defined $objects );
     foreach $object ( @{$objects} )
     {
-		printf "\tRemain dns\n";
+		vhffs_log( sprintf( "Remain dns for group %s before delete" , $group->get_groupname ));
         $object->set_status( Vhffs::Constants::TO_DELETE );
 		$object->commit;
     }
@@ -57,7 +60,7 @@
 	$ok = 0 if( defined $objects );
     foreach $object ( @{$objects} )
     {
-		printf "\tRemain mysql\n";
+		vhffs_log( sprintf( "Remain mysql for group %s before delete" , $group->get_groupname ));
         $object->set_status( Vhffs::Constants::TO_DELETE );
 		$object->commit;
     }
@@ -66,7 +69,7 @@
 	$ok = 0 if( defined $objects );
    foreach $object ( @{$objects} )
    {
-		printf "\tRemain postgres\n";
+		vhffs_log( sprintf( "Remain pgsql for group %s before delete" , $group->get_groupname ));
         $object->set_status( Vhffs::Constants::TO_DELETE );
 		$object->commit;
    }
@@ -76,7 +79,7 @@
 	$ok = 0 if( defined $objects );
    foreach $object ( @{$objects} )
    {
-		printf "\tRemain website\n";
+		vhffs_log( sprintf( "Remain website for group %s before delete" , $group->get_groupname ));
         $object->set_status( Vhffs::Constants::TO_DELETE );
 		$object->commit;
    }
@@ -85,7 +88,7 @@
 	$ok = 0 if( defined $objects );
    foreach $object ( @{$objects} )
    {
-		printf "\tRemain mailing-list\n";
+		vhffs_log( sprintf( "Remain list for group %s before delete" , $group->get_groupname ));
         $object->set_status( Vhffs::Constants::TO_DELETE );
 		$object->commit;
    }
@@ -95,24 +98,28 @@
 	$ok = 0 if( defined $objects );
    foreach $object ( @{$objects} )
    {
-		printf "\tRemain mail\n";
+		vhffs_log( sprintf( "Remain mail for group %s before delete" , $group->get_groupname ));
         $object->set_status( Vhffs::Constants::TO_DELETE );
 		if( $object->commit < 0 )
 		{
-			print "error while commit this object\n";
+			vhffs_log( "Error in delete group" );
 		}
    }
 
 
 	if( $ok == 1 )
 	{
-		printf "\tDelete group ". $group->get_groupname."\n";
+		vhffs_log( sprintf( "Delete group %s" , $group->get_groupname ));
 		Vhffs::Robots::Group::delete( $vhffs , $group );
 	}
 	else
 	{
-		printf "\tCannot delete group ". $group->get_groupname.", remain some services\n";
+		vhffs_log( sprintf( "Cannot elete group %s, items remains" , $group->get_groupname ));
 	}
 
 }
 
+Vhffs::Robots::unlock;
+
+exit( 0 );
+

Modified: trunk/vhffs-robots/src/mailing.pl
==============================================================================
--- trunk/vhffs-robots/src/mailing.pl (original)
+++ trunk/vhffs-robots/src/mailing.pl Fri Dec  9 17:25:15 2005
@@ -1,4 +1,6 @@
 #!/usr/bin/perl
+
+
 
 use strict;
 use Vhffs::Main;
@@ -6,24 +8,10 @@
 use Vhffs::Functions;
 use Vhffs::Robots::Mailing;
 use Vhffs::Robots::User;
+use Vhffs::Robots;
 use Vhffs::Constants;
 
-
-my $RUNFILE = "/var/run/vhffs_ml";
-
-
-
-if( -f $RUNFILE )
-{
-    print( "Robot is already running.\n" );
-    exit( 0 );
-}
-else
-{
-    system("touch $RUNFILE");
-}
-
-sleep( 40 );
+Vhffs::Robots::lock();
 
 my $users;
 my $user;
@@ -63,6 +51,6 @@
 	}
 }
 
-unlink( $RUNFILE );
+Vhffs::Robots::unlock();
 
 exit( 0 );




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/