~giuseppe-maxia/mysql-sandbox/mysql-sandbox-3

« back to all changes in this revision

Viewing changes to bin/sbtool

  • Committer: Giuseppe Maxia
  • Date: 2010-05-24 20:30:20 UTC
  • Revision ID: g.maxia@gmail.com-20100524203020-fznam8olowxn2363
- Fixed bug in ./clear script. In version 5.5 and bigger, it erased the performance_schema database, which should not be removed. If it exists, its tables are now truncated.
- Fixed bug in ./clear script. The removal of databases was not executed in a clean mode.
- Added a script to install plugins in ./drafts 

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
#    delete => 'removes a sandbox completely',
57
57
#    preserve => 'makes a sandbox permanent',
58
58
#    unpreserve => 'makes a sandbox not permanent',
 
59
#    plugin => adds plugin support to a sandbox (innodb,semisynch)
59
60
#);
60
61
 
61
62
my %supported_formats = %MySQL::Sandbox::Scripts::sbtool_supported_formats;
135
136
    }
136
137
    delete_sandbox( $msb->{options}{source_dir});
137
138
}
 
139
elsif ($msb->{options}{operation} eq 'plugin') {
 
140
    add_plugin( $msb->{options}{source_dir}, $msb->{options}{plugin} );
 
141
}
138
142
else {
139
143
    croak "unsupported operation ($msb->{options}{operation})\n";
140
144
}
333
337
    return ($info, $info->{opt}{port});
334
338
}
335
339
 
 
340
sub add_plugin {
 
341
    my ($source, $plugin) = @_;
 
342
    unless ($source) {
 
343
        croak "Need a source directory (--source_dir)\n";
 
344
    }
 
345
    unless ($plugin) {
 
346
        croak "Need a plugin (--plugin)\n";
 
347
    }
 
348
    $plugin   =~ s/^\s//;
 
349
    $plugin   =~ s/\s*$//;
 
350
    $source   =~ s/^\s//;
 
351
    $source   =~ s/\s*$//;
 
352
    $source   =~ s/\/$//;
 
353
    $source   =~ s/^\s*~/$ENV{HOME}/;
 
354
    unless ($source =~ m{^/})  {
 
355
        croak "The source directory must be an absolute path.\n"; 
 
356
    }
 
357
    unless ( -d $source )  {
 
358
        croak "directory $source does not exist\n";
 
359
    }
 
360
    if ( ( -x "$source/start") && ( -x "$source/stop")) {
 
361
        add_plugin_to_single($source, $plugin);
 
362
    }
 
363
    elsif ( ( -x "$source/start_all") && ( -x "$source/stop_all")) {
 
364
        add_plugin_to_multiple($source, $plugin);
 
365
    }
 
366
    else {
 
367
        croak "directory $source does not seem to be a sandbox\n";
 
368
    }
 
369
}
 
370
 
 
371
sub add_plugin_to_single {
 
372
    my ( $source, $plugin) = @_;
 
373
    die "TODO. See set_plugin.pl instead\n";
 
374
}
 
375
 
 
376
sub add_plugin_to_multiple {
 
377
    my ( $source, $plugin) = @_;
 
378
    die "TODO. See set_plugin.pl instead\n";
 
379
}
 
380
 
336
381
sub move_sandbox {
337
382
    my ($source, $dest) = @_;
338
383
    unless ($source) {