[vhffs-dev] [2060] Reworked mysql robots |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 2060
Author: gradator
Date: 2012-02-25 22:15:22 +0100 (Sat, 25 Feb 2012)
Log Message:
-----------
Reworked mysql robots
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm
trunk/vhffs-api/src/Vhffs/Services/Mysql.pm
trunk/vhffs-robots/Makefile.am
Added Paths:
-----------
trunk/vhffs-robots/src/mysql.pl
Removed Paths:
-------------
trunk/vhffs-robots/src/mysql_create.pl
trunk/vhffs-robots/src/mysql_delete.pl
trunk/vhffs-robots/src/mysql_modify.pl
Modified: trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm 2012-02-25 21:14:33 UTC (rev 2059)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mysql.pm 2012-02-25 21:15:22 UTC (rev 2060)
@@ -29,20 +29,18 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-
-package Vhffs::Robots::Mysql;
-
-require 5.004;
use strict;
use utf8;
-use POSIX;
-use locale;
-use Locale::gettext;
-use Vhffs::Services::Mysql;
+use File::Path;
+use File::Basename;
+use File::Copy;
+
use Vhffs::Constants;
use Vhffs::Functions;
use Vhffs::Robots;
+use Vhffs::Services::Mysql;
+package Vhffs::Robots::Mysql;
sub mysql_admin_db_connect {
use DBI;
@@ -55,112 +53,135 @@
return DBI->connect( 'DBI:mysql:dbname=mysql;host='.$dbhost , $dbuser , $dbpass );
}
-# TODO - rework that ...
-sub delete_db {
- my $main = shift;
- my $db = shift;
- return unless defined $db;
+sub create {
+ my $mysql = shift;
+ return undef unless defined $mysql and $mysql->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
- my $robotconf = $main->get_config->get_robots;
+ my $vhffs = $mysql->get_main;
- my $dbi = mysql_admin_db_connect( $main );
+ my $dbi = mysql_admin_db_connect( $vhffs );
return unless $dbi;
- my $query;
- $db->add_history( 'Ok, robots takes the destruction of this database' );
+ # create the database
+ unless( $dbi->do( 'CREATE DATABASE '.$mysql->get_dbname ) ) {
+ $mysql->set_status( Vhffs::Constants::CREATION_ERROR );
+ $mysql->commit;
+ Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while creating mysql database '.$mysql->get_dbname );
+ return undef;
+ }
- $query = 'DELETE FROM `user` WHERE User = \''.$db->get_dbname.'\'';
- $dbi->do( $query ) or $db->add_history('Error while grant access to the database');
+ # grant privileges to user
+ my $query = 'GRANT ALL ON '.$mysql->get_dbname.'.* TO '.$mysql->get_dbname.' IDENTIFIED BY ?';
+ unless( $dbi->do( $query, undef, $mysql->get_dbpassword ) ) {
+ $mysql->set_status( Vhffs::Constants::CREATION_ERROR );
+ $mysql->commit;
+ Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while granting privileges to mysql database '.$mysql->get_dbname.' to '.$mysql->get_dbname );
+ $dbi->do( 'DROP DATABASE '.$mysql->get_dbname );
+ return undef;
+ }
- $query = 'DELETE FROM `db` WHERE User = \''.$db->get_dbname.'\'';
- $dbi->do( $query ) or $db->add_history('Error while grant access to the database');
+ $dbi->do( 'FLUSH PRIVILEGES' );
+ $dbi->disconnect;
- $query = 'DELETE FROM `tables_priv` WHERE User = \''.$db->get_dbname.'\'';
- $dbi->do( $query ) or $db->add_history('Error while grant access to the database');
+ Vhffs::Robots::vhffs_log( $vhffs, 'Created mysql database '.$mysql->get_dbname );
+ $mysql->blank_password;
+ $mysql->set_status( Vhffs::Constants::ACTIVATED );
+ $mysql->commit;
- $query = 'DELETE FROM `columns_priv` WHERE User = \''.$db->get_dbname.'\'';
- $dbi->do( $query ) or $db->add_history('Error while grant access to the database');
+ return 1;
+}
+sub delete {
+ my $mysql = shift;
+ return undef unless defined $mysql and $mysql->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
+
+ my $vhffs = $mysql->get_main;
+
+ my $dbi = mysql_admin_db_connect( $vhffs );
+ return unless $dbi;
+
+ my $fail = 0;
+ $dbi->do( 'DELETE FROM user WHERE User = ?', undef, $mysql->get_dbname ) or $fail=1;
+ $dbi->do( 'DELETE FROM db WHERE User = ?', undef, $mysql->get_dbname ) or $fail=1;
+ $dbi->do( 'DELETE FROM tables_priv WHERE User = ?', undef, $mysql->get_dbname ) or $fail=1;
+ $dbi->do( 'DELETE FROM columns_priv WHERE User = ?', undef, $mysql->get_dbname ) or $fail=1;
+
+ if( $fail ) {
+ $mysql->set_status( Vhffs::Constants::DELETION_ERROR );
+ $mysql->commit;
+ Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while revoking privileges from mysql database '.$mysql->get_dbname.' for '.$mysql->get_dbname );
+ return undef;
+ }
+
$dbi->do( 'FLUSH PRIVILEGES' );
# Dump the database after access are removed (thus setting the database read-only) and just before dropping it
- my $tmpfile = _dump( $db );
+ my $tmpfile = _dump( $mysql );
if( defined $tmpfile ) {
- my $file = $robotconf->{'archive_deleted_path'}.'/'.time().'_'.$db->get_group->get_groupname.'_mysql_'.$db->get_dbname.'.dump';
- require File::Copy;
- File::Copy::move( $tmpfile , $file );
+ my $file = $vhffs->get_config->get_robots->{'archive_deleted_path'}.'/'.time().'_'.$mysql->get_group->get_groupname.'_mysql_'.$mysql->get_dbname.'.dump';
+ File::Copy::move( $tmpfile, $file );
}
- $query = 'DROP DATABASE `'.$db->get_dbname.'`';
- $dbi->do( $query ) or $db->add_history('Error while deleting the database');
+ unless( $dbi->do( 'DROP DATABASE '.$mysql->get_dbname ) ) {
+ $mysql->set_status( Vhffs::Constants::DELETION_ERROR );
+ $mysql->commit;
+ Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while removing mysql database '.$mysql->get_dbname );
+ return undef;
+ }
$dbi->disconnect;
- $db->add_history( 'Robots finished the destruction' );
- $db->delete;
+ if( $mysql->delete ) {
+ Vhffs::Robots::vhffs_log( $vhffs, 'Deleted mysql database '.$mysql->get_dbname );
+ } else {
+ $mysql->set_status( Vhffs::Constants::DELETION_ERROR );
+ $mysql->commit;
+ Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while deleting mysql database '.$mysql->get_dbname.' object' );
+ return undef;
+ }
+
+ return 1;
}
-sub create_db {
- my $main = shift;
- my $db = shift;
- return unless defined $db;
+sub modify {
+ my $mysql = shift;
+ return undef unless defined $mysql and $mysql->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION;
- my $dbi = mysql_admin_db_connect( $main );
- return unless $dbi;
+ my $vhffs = $mysql->get_main;
- my $query;
- $db->add_history( 'Ok, robots takes the creation of this database' );
-
- # create the database
- $query = 'CREATE DATABASE `'.$db->get_dbname.'`';
- $dbi->do( $query ) or $db->add_history('Error while creating the database');
-
- # grant privileges to user
- $query = 'GRANT ALL ON '.$db->get_dbname.'.* TO '.$db->get_dbname.' IDENTIFIED BY ?';
- $dbi->do( $query, undef, $db->get_dbpassword ) or $db->add_history( 'An error occured while granting privileges to an admin user' );
-
- $dbi->do( 'FLUSH PRIVILEGES' );
- $dbi->disconnect;
-
- $db->add_history( 'Robots finished the creation' );
- $db->set_status( Vhffs::Constants::ACTIVATED );
- $db->commit;
- $db->blank_password;
-}
-
-sub update_db {
- my $main = shift;
- my $db = shift;
- return unless defined $db;
-
- my $dbi = mysql_admin_db_connect( $main );
+ my $dbi = mysql_admin_db_connect( $vhffs );
return unless $dbi;
- my $query;
- $db->add_history( 'Ok, will change password for this database' );
+ if( $mysql->get_dbpassword ) {
+ unless( $dbi->do( 'UPDATE user SET PASSWORD=PASSWORD(?) WHERE user = ?', undef, $mysql->get_dbpassword, $mysql->get_dbname) ) {
+ $mysql->set_status( Vhffs::Constants::MODIFICATION_ERROR );
+ $mysql->commit;
+ Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while modifying mysql database '.$mysql->get_dbname );
+ return undef;
+ }
+ $mysql->blank_password;
+ $mysql->add_history( 'Password changed' );
+ Vhffs::Robots::vhffs_log( $vhffs, 'Password changed for mysql database '.$mysql->get_dbname );
+ }
- $query = 'UPDATE user SET PASSWORD=PASSWORD(?) WHERE user = ?';
- $dbi->do( $query, undef, $db->get_dbpassword, $db->get_dbname) or $db->add_history('Error while grant access to the database');
-
$dbi->do( 'FLUSH PRIVILEGES' );
$dbi->disconnect;
- $db->add_history( 'Robots changed the password for this database' );
- $db->set_status( Vhffs::Constants::ACTIVATED );
- $db->commit;
- $db->blank_password;
+ $mysql->set_status( Vhffs::Constants::ACTIVATED );
+ $mysql->commit;
+ return 1;
}
sub _dump {
- my $db = shift;
- my $mysqlconf = $db->{main}->get_config->get_service('mysql');
+ my $mysql = shift;
+ my $mysqlconf = $mysql->{main}->get_config->get_service('mysql');
return undef unless defined $mysqlconf;
- my ( $tmpfile, $tmppath ) = Vhffs::Robots::tmpfile( $db->{main} );
+ my ( $tmpfile, $tmppath ) = Vhffs::Robots::tmpfile( $mysql->{main} );
return undef unless defined $tmpfile;
my $ret;
- my $childpid = open( my $output, '-|', $mysqlconf->{'mysqldump_path'}, '-c', '-R', '--hex-blob', '-u', $mysqlconf->{'username'}, '-h', $mysqlconf->{'host'}, '-p'.$mysqlconf->{'password'}, $db->get_dbname );
+ my $childpid = open( my $output, '-|', $mysqlconf->{'mysqldump_path'}, '-c', '-R', '--hex-blob', '-u', $mysqlconf->{'username'}, '-h', $mysqlconf->{'host'}, '-p'.$mysqlconf->{'password'}, $mysql->get_dbname );
if ($childpid) {
# Ensure output is in binary mode
binmode($output);
@@ -192,19 +213,21 @@
}
sub dump_night {
- my $db = shift;
+ my $mysql = shift;
- my $dir = $db->get_group->get_dir;
- return unless -d $dir;
- my $file = $dir.'/'.$db->get_dbname.'.mysql.dump';
+ my $dir = $mysql->get_group->get_dir;
+ return undef unless -d $dir;
+ my $file = $dir.'/'.$mysql->get_dbname.'.mysql.dump';
- my $tmpfile = _dump($db);
+ my $tmpfile = _dump($mysql);
return undef unless defined $tmpfile;
chmod( 0440, $tmpfile );
- chown( $db->get_owner_uid , $db->get_owner_gid , $tmpfile );
+ chown( $mysql->get_owner_uid , $mysql->get_owner_gid , $tmpfile );
require File::Copy;
File::Copy::move( $tmpfile , $file );
+
+ return 1;
}
1;
Modified: trunk/vhffs-api/src/Vhffs/Services/Mysql.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Mysql.pm 2012-02-25 21:14:33 UTC (rev 2059)
+++ trunk/vhffs-api/src/Vhffs/Services/Mysql.pm 2012-02-25 21:15:22 UTC (rev 2060)
@@ -254,6 +254,8 @@
my $request = $self->{'db'}->prepare('UPDATE vhffs_mysql SET dbpass=\'\' WHERE mysql_id=?') or return -1;
$request->execute( $self->{mysql_id} );
+
+ $self->{'dbpass'} = '';
return 1;
}
Modified: trunk/vhffs-robots/Makefile.am
===================================================================
--- trunk/vhffs-robots/Makefile.am 2012-02-25 21:14:33 UTC (rev 2059)
+++ trunk/vhffs-robots/Makefile.am 2012-02-25 21:15:22 UTC (rev 2060)
@@ -32,10 +32,8 @@
src/mailinglist_create.pl \
src/mailinglist_delete.pl \
src/mailing.pl \
- src/mysql_create.pl \
- src/mysql_delete.pl \
+ src/mysql.pl \
src/mysql_dump.pl \
- src/mysql_modify.pl \
src/object_cleanup.pl \
src/pgsql_create.pl \
src/pgsql_delete.pl \
Copied: trunk/vhffs-robots/src/mysql.pl (from rev 2056, trunk/vhffs-robots/src/mysql_create.pl)
===================================================================
--- trunk/vhffs-robots/src/mysql.pl (rev 0)
+++ trunk/vhffs-robots/src/mysql.pl 2012-02-25 21:15:22 UTC (rev 2060)
@@ -0,0 +1,59 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#3. Neither the name of vhffs nor the names of its contributors
+# may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Robots::Mysql;
+
+my $vhffs = init Vhffs::Main;
+exit 1 unless defined $vhffs;
+
+Vhffs::Robots::lock( $vhffs, 'mysql' );
+
+my $repos = Vhffs::Services::Mysql::getall( $vhffs, Vhffs::Constants::WAITING_FOR_CREATION );
+foreach ( @{$repos} ) {
+ Vhffs::Robots::Mysql::create( $_ );
+}
+
+$repos = Vhffs::Services::Mysql::getall( $vhffs, Vhffs::Constants::WAITING_FOR_DELETION );
+foreach ( @{$repos} ) {
+ Vhffs::Robots::Mysql::delete( $_ );
+}
+
+$repos = Vhffs::Services::Mysql::getall( $vhffs, Vhffs::Constants::WAITING_FOR_MODIFICATION );
+foreach ( @{$repos} ) {
+ Vhffs::Robots::Mysql::modify( $_ );
+}
+
+Vhffs::Robots::unlock( $vhffs, 'mysql' );
+exit 0;
Deleted: trunk/vhffs-robots/src/mysql_create.pl
===================================================================
--- trunk/vhffs-robots/src/mysql_create.pl 2012-02-25 21:14:33 UTC (rev 2059)
+++ trunk/vhffs-robots/src/mysql_create.pl 2012-02-25 21:15:22 UTC (rev 2060)
@@ -1,67 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-#3. Neither the name of vhffs nor the names of its contributors
-# may be used to endorse or promote products derived from this
-# software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-use strict;
-use utf8;
-use POSIX;
-use locale;
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Robots;
-use Vhffs::Services::Mysql;
-use Vhffs::Robots::Mysql;
-use Vhffs::Constants;
-use Vhffs::Main;
-
-
-my $vhffs = init Vhffs::Main;
-
-Vhffs::Robots::lock( $vhffs , "mysql" );
-
-my $dbs = Vhffs::Services::Mysql::getall( $vhffs , Vhffs::Constants::WAITING_FOR_CREATION , undef , undef );
-my $db;
-
-
-foreach $db ( @{$dbs} )
-{
- if( Vhffs::Robots::Mysql::create_db( $vhffs , $db ) < 0 )
- {
- Vhffs::Robots::vhffs_log( $vhffs, sprintf("Cannot create MySQL database %s",$db->get_dbname) );
-
- }
- else
- {
- Vhffs::Robots::vhffs_log( $vhffs, sprintf("Create MySQL database %s",$db->get_dbname) );
- }
-}
-
-
-Vhffs::Robots::unlock( $vhffs , "mysql" );
-exit 0;
Deleted: trunk/vhffs-robots/src/mysql_delete.pl
===================================================================
--- trunk/vhffs-robots/src/mysql_delete.pl 2012-02-25 21:14:33 UTC (rev 2059)
+++ trunk/vhffs-robots/src/mysql_delete.pl 2012-02-25 21:15:22 UTC (rev 2060)
@@ -1,65 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-#3. Neither the name of vhffs nor the names of its contributors
-# may be used to endorse or promote products derived from this
-# software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-use strict;
-use utf8;
-
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Robots;
-use Vhffs::Robots::Mysql;
-use Vhffs::Services::Mysql;
-use Vhffs::Main;
-
-
-my $vhffs = init Vhffs::Main;
-
-Vhffs::Robots::lock( $vhffs , "mysql" );
-
-my $dbs = Vhffs::Services::Mysql::getall( $vhffs , Vhffs::Constants::WAITING_FOR_DELETION , undef , undef );
-my $db;
-
-
-foreach $db ( @{$dbs} )
-{
- if( Vhffs::Robots::Mysql::delete_db( $vhffs , $db ) < 0 )
- {
- Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Cannot delete MySQL database %s" , $db->get_dbname ));
- }
- else
- {
- Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Delete MySQL database %s" , $db->get_dbname ));
- }
-}
-
-
-Vhffs::Robots::unlock( $vhffs , "mysql" );
-
-exit 0;
Deleted: trunk/vhffs-robots/src/mysql_modify.pl
===================================================================
--- trunk/vhffs-robots/src/mysql_modify.pl 2012-02-25 21:14:33 UTC (rev 2059)
+++ trunk/vhffs-robots/src/mysql_modify.pl 2012-02-25 21:15:22 UTC (rev 2060)
@@ -1,64 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-#3. Neither the name of vhffs nor the names of its contributors
-# may be used to endorse or promote products derived from this
-# software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-use strict;
-use utf8;
-
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Robots;
-use Vhffs::Robots::Mysql;
-use Vhffs::Services::Mysql;
-use Vhffs::Main;
-
-
-
-my $vhffs = init Vhffs::Main;
-
-Vhffs::Robots::lock( $vhffs , "mysql" );
-
-my $dbs = Vhffs::Services::Mysql::getall( $vhffs , Vhffs::Constants::WAITING_FOR_MODIFICATION , undef , undef );
-my $db;
-
-foreach $db ( @{$dbs} )
-{
- if( Vhffs::Robots::Mysql::update_db( $vhffs , $db ) < 0 )
- {
- Vhffs::Robots::vhffs_log( $vhffs, "Error while update MySQL database" );
- }
- else
- {
- Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Update MySQL database %s" , $db->get_dbname ) );
- }
-}
-
-Vhffs::Robots::unlock( $vhffs , "mysql" );
-exit 0;
-