#!/usr/bin/perl
# sandbox
# The MySQL Sandbox
# Copyright (C) 2009 Giuseppe Maxia
# Contacts: http://datacharmer.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
use strict;
use warnings;
use English qw( -no_match_vars );
use Data::Dumper;
use MySQL::Sandbox qw(runs_as_root);
my $DEBUG = $MySQL::Sandbox::DEBUG;
runs_as_root();
#my $install_dir;
#$install_dir = $PROGRAM_NAME;
#$install_dir =~ s{/\w+(\.pl)?$}{};
my $msb = MySQL::Sandbox->new();
my @apps = (
{
name => 'make_sandbox',
description => 'the easiest way of creating a sandbox',
},
{
name => 'low_level_make_sandbox',
description => q{create a single sandbox, with fine tuning options (don't use directly)},
},
{
name => 'make_replication_sandbox',
description => 'creates a sandbox with replicated master and slaves or circular',
},
{
name => 'make_multiple_sandbox',
description => 'creates a group of sandboxes with the same version',
},
{
name => 'make_multiple_custom_sandbox',
description => 'create a group of sandboxes with different versions',
},
{
name => 'make_sandbox_from_source',
description => 'create a sandbox from a build directory',
},
{
name => 'make_sandbox_from_installed',
description => 'create a sandbox from already installed binaries',
},
{
name => 'sbtool',
description => 'performs auxiliary actions with existing sandboxes',
},
);
my $choice = shift
or help();
if (grep {$choice eq $_->{name} } @apps ) {
my $application = "$choice";
if ( -x $application) {
exec $application, @ARGV;
}
else {
die "application $application not found\n";
}
}
else {
exec "perldoc MySQL::Sandbox";
#die "'$choice' is not an application in MySQL Sandbox\n";
}
sub help {
print $msb->credits();
print "available applications:\n";
for my $app (@apps) {
printf " %-30s: %s\n", $app->{'name'}, $app->{'description'};
}
exit(1);
}
__END__