[MOBY-guts] biomoby commit
Eddie Kawas
kawas at dev.open-bio.org
Thu May 29 19:59:21 UTC 2008
kawas
Thu May 29 15:59:21 EDT 2008
Update of /home/repository/moby/moby-live/Perl/MOBY-Server/bin/scripts
In directory dev.open-bio.org:/tmp/cvs-serv16174/Perl/MOBY-Server/bin/scripts
Modified Files:
moby-s-install.pl
Log Message:
*made mobycentral.config readable by all
*prompt user for a new db user/pass for access to the registry so that root password isnt used
moby-live/Perl/MOBY-Server/bin/scripts moby-s-install.pl,1.5,1.6
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY-Server/bin/scripts/moby-s-install.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- /home/repository/moby/moby-live/Perl/MOBY-Server/bin/scripts/moby-s-install.pl 2008/05/29 14:15:13 1.5
+++ /home/repository/moby/moby-live/Perl/MOBY-Server/bin/scripts/moby-s-install.pl 2008/05/29 19:59:21 1.6
@@ -30,6 +30,11 @@
sub say { print @_, "\n"; }
+ # query is for creating the moby_username and password for local access to dbs
+ sub prepare_query {
+ my $s = join "", @_;
+ return qq|GRANT ALL ON $s TO ?\@'localhost' IDENTIFIED BY ? WITH GRANT OPTION|;
+ }
sub check_module {
eval "require $_[0]";
if ($@) {
@@ -378,6 +383,10 @@
my $url = prompt_user_input( "What is the mysql url?", "localhost" );
my $port = prompt_user_input( "What is the mysql port #?", "3306" );
+ # prompt for a new user/password combo so that people cant determine the root password from MOBY::Config
+ my $moby_username = prompt_user_input( "What username (I will create it if it doesn't exist)\n would you like to access your local db?", "moby_user" );
+ my $moby_password = prompt_user_input( "Please provide a password for '$moby_username': ", "" );
+
#db names
say
"\nPrompting for mysql table names. Use default names unless you know what you are doing!";
@@ -400,10 +409,12 @@
You have provided the following values:
mySQL Details
- username : $username
- password : $password
- URL : $url
- port : $port
+ username : $username
+ password : $password
+ URL : $url
+ port : $port
+ registry db username : $moby_username
+ registry db password : $moby_password
Tables:
Object ontology : $m_object
@@ -416,9 +427,10 @@
say($msg);
return (
- $username, $password, $url,
- $port, $m_object, $m_relationship,
- $m_service, $m_namespace, $m_central
+ $username, $password, $url,
+ $port, $m_object, $m_relationship,
+ $m_service, $m_namespace, $m_central,
+ $moby_username, $moby_password
);
}
@@ -461,7 +473,7 @@
# since the file contains the root DB password
# make it only readable by root
- chmod 0600, $file;
+ chmod 0644, $file;
die "Couldn't make MOBY config file readable only by root: $!"
if $?;
@@ -533,7 +545,8 @@
my (
$username, $password, $url,
$port, $m_object, $m_relationship,
- $m_service, $m_namespace, $m_central
+ $m_service, $m_namespace, $m_central,
+ $moby_username, $moby_password
);
say "We are going to be placing files into your apache setup, in the cgi-bin/ directory and conf/ directory";
@@ -600,18 +613,19 @@
# copy mobycentral.config to conf directory
(
- $username, $password, $url,
- $port, $m_object, $m_relationship,
- $m_service, $m_namespace, $m_central
+ $username, $password, $url,
+ $port, $m_object, $m_relationship,
+ $m_service, $m_namespace, $m_central,
+ $moby_username, $moby_password
)
= prompt_moby_config_info;
# TODO - collect the values and do this at the end
# fill out mobycentral.config
fill_out_moby_conf("$apache_conf/mobycentral.config",
- $username, $password, $url,
- $port, $m_object, $m_relationship,
- $m_service, $m_namespace, $m_central
+ $moby_username, $moby_password, $url,
+ $port, $m_object, $m_relationship,
+ $m_service, $m_namespace, $m_central
);
}
@@ -623,16 +637,17 @@
say " Installing the file '$apache_conf/mobycentral.config' ...";
# fill out mobycentral.config
- ( $username, $password, $url,
- $port, $m_object, $m_relationship,
- $m_service, $m_namespace, $m_central
+ ( $username, $password, $url,
+ $port, $m_object, $m_relationship,
+ $m_service, $m_namespace, $m_central,
+ $moby_username, $moby_password
) = prompt_moby_config_info;
# TODO - collect the values and do this at the end
fill_out_moby_conf("$apache_conf/mobycentral.config",
- $username, $password, $url,
- $port, $m_object, $m_relationship,
- $m_service, $m_namespace, $m_central
+ $moby_username, $moby_password, $url,
+ $port, $m_object, $m_relationship,
+ $m_service, $m_namespace, $m_central
);
}
@@ -829,7 +844,9 @@
and $m_relationship
and $m_service
and $m_namespace
- and $m_central;
+ and $m_central,
+ and $moby_username,
+ and $moby_password;
# check to see if mobycentral.config has been created in the conf
# directory first -> if so, parse it
@@ -852,8 +869,8 @@
$db_sections{$dbname} = $dbConfig;
}
- $username = $db_sections{mobycentral}->{username};
- $password = $db_sections{mobycentral}->{password} || "";
+ $moby_username = $db_sections{mobycentral}->{username};
+ $moby_password = $db_sections{mobycentral}->{password} || "";
$url = $db_sections{mobycentral}->{url};
$port = $db_sections{mobycentral}->{port};
$m_object = $db_sections{mobyobject}->{dbname};
@@ -871,19 +888,27 @@
say " Installing the file '$apache_conf/mobycentral.config' ...";
# fill out mobycentral.config
- ($username, $password, $url,
- $port, $m_object, $m_relationship,
- $m_service, $m_namespace, $m_central
+ ($username, $password, $url,
+ $port, $m_object, $m_relationship,
+ $m_service, $m_namespace, $m_central,
+ $moby_username, $moby_password
) = prompt_moby_config_info;
fill_out_moby_conf(
"$apache_conf/mobycentral.config",
- $username, $password, $url,
- $port, $m_object, $m_relationship,
- $m_service, $m_namespace, $m_central
+ $moby_username, $moby_password, $url,
+ $port, $m_object, $m_relationship,
+ $m_service, $m_namespace, $m_central
);
}
+ # make sure that we have a root password/username
+ unless ($username and $password) {
+ $username =
+ prompt_user_input( "What is your root mysql username?", "root" );
+ $password =
+ prompt_user_input( "What is your root mysql users' password?", "" );
+ }
# now start creating the tables
say " creating the tables to use for the registry ...";
my %dbsections = (
@@ -940,7 +965,8 @@
$mobynamespace, $mobyrelationship
) = $central->MOBY::Client::Central::DUMP();
my $drh = DBI->install_driver("mysql");
-
+ # used for creating the user/pass for the registry
+ my $dbh = DBI->connect("DBI:mysql:mysql:localhost:3306", "root", "root", { RaiseError => 1, AutoCommit => 1 });
my ( $fh, $filename ) = tempfile( UNLINK => 1 );
say "Processing dump for service instances ...";
print $fh $mobycentral;
@@ -952,6 +978,12 @@
$drh->func( 'createdb', $dbsections{mobycentral},
$url, $username, $password, 'admin' );
};
+ eval {
+ my $db = $dbsections{mobycentral} . ".*";
+ $dbh->do(prepare_query($db),undef,$moby_username,$moby_password)
+ || say ("Could not give '$moby_username' access to $db - Error:\n$DBI::errstr");
+ };
+ die $! if $!;
system( "mysql -h $url -P $port -u $username --password=$password "
. $dbsections{mobycentral}
. "<$filename" ) == 0
@@ -969,6 +1001,11 @@
$drh->func( 'createdb', $dbsections{mobyobject}, $url,
$username, $password, 'admin' );
};
+ eval {
+ my $db = $dbsections{mobyobject} . ".*";
+ $dbh->do(prepare_query($db),undef,$moby_username,$moby_password)
+ || say ("Could not give '$moby_username' access to $db - Error:\n$DBI::errstr");
+ };
system( "mysql -h $url -P $port -u $username --password=$password "
. $dbsections{mobyobject}
. "<$filename" ) == 0
@@ -986,6 +1023,11 @@
$drh->func( 'createdb', $dbsections{mobyservice},
$url, $username, $password, 'admin' );
};
+ eval {
+ my $db = $dbsections{mobyservice} . ".*";
+ $dbh->do(prepare_query($db),undef,$moby_username,$moby_password)
+ || say ("Could not give '$moby_username' access to $db - Error:\n$DBI::errstr");
+ };
system( "mysql -h $url -P $port -u $username --password=$password "
. $dbsections{mobyservice}
. "<$filename" ) == 0
@@ -1003,6 +1045,11 @@
$drh->func( 'createdb', $dbsections{mobynamespace},
$url, $username, $password, 'admin' );
};
+ eval {
+ my $db = $dbsections{mobynamespace} . ".*";
+ $dbh->do(prepare_query($db),undef,$moby_username,$moby_password)
+ || say ("Could not give '$moby_username' access to $db - Error:\n$DBI::errstr");
+ };
system( "mysql -h $url -P $port -u $username --password=$password "
. $dbsections{mobynamespace}
. "<$filename" ) == 0
@@ -1020,6 +1067,11 @@
$drh->func( 'createdb', $dbsections{mobyrelationship},
$url, $username, $password, 'admin' );
};
+ eval {
+ my $db = $dbsections{mobyrelationship} . ".*";
+ $dbh->do(prepare_query($db),undef,$moby_username,$moby_password)
+ || say ("Could not give '$moby_username' access to $db - Error:\n$DBI::errstr");
+ };
system( "mysql -h $url -P $port -u $username --password=$password "
. $dbsections{mobyrelationship}
. "<$filename" ) == 0
@@ -1042,31 +1094,38 @@
#process each db
foreach my $section ( keys %dbsections ) {
- my $sqlfilepath = File::ShareDir::dist_file( 'MOBY',
- "db/schema/$section.mysql" );
- my $drh = DBI->install_driver("mysql");
-
- # drop the db
- eval {
- $drh->func( 'dropdb', $dbsections{$section}, $url,
- $username, $password, 'admin' );
- } if $drop_db;
-
- # create the db
- eval {
- $drh->func( 'createdb', $dbsections{$section}, $url,
- $username, $password, 'admin' );
- };
-
- #create the tables in the db
- do {
- say "\n\tProblem creating tables in the db: $section: $!";
- }
- unless system(
- "mysql -h $url -P $port -u $username --password=$password "
- . $dbsections{$section}
- . "<$sqlfilepath" ) == 0;
- say "\tProcessing of $section completed ... ";
+ my $sqlfilepath = File::ShareDir::dist_file( 'MOBY',
+ "db/schema/$section.mysql" );
+ my $drh = DBI->install_driver("mysql");
+ # used for creating the user/pass for the registry
+ my $dbh = DBI->connect("DBI:mysql:mysql:localhost:3306", "root", "root", { RaiseError => 1, AutoCommit => 1 });
+ # drop the db
+ eval {
+ $drh->func( 'dropdb', $dbsections{$section}, $url,
+ $username, $password, 'admin' );
+ } if $drop_db;
+
+ # create the db
+ eval {
+ $drh->func( 'createdb', $dbsections{$section}, $url,
+ $username, $password, 'admin' );
+ };
+
+ # give moby_username permission to access it
+ eval {
+ my $db = $dbsections{$section} . ".*";
+ $dbh->do(prepare_query($db),undef,$moby_username,$moby_password)
+ || say ("Could not give '$moby_username' access to $db - Error:\n$DBI::errstr");
+ };
+ #create the tables in the db
+ do {
+ say "\n\tProblem creating tables in the db: $section: $!";
+ }
+ unless system(
+ "mysql -h $url -P $port -u $username --password=$password "
+ . $dbsections{$section}
+ . "<$sqlfilepath" ) == 0;
+ say "\tProcessing of $section completed ... ";
}
say "populating the tables with basic data ...";
%dbsections = (
@@ -1075,14 +1134,14 @@
'mobyrelationship' => $m_relationship
);
foreach my $section ( keys %dbsections ) {
- my $sqlfilepath =
- File::ShareDir::dist_file( 'MOBY', "db/data/$section.data" );
- system(
- "mysql -h $url -P $port -u $username --password=$password "
- . $dbsections{$section}
- . "<$sqlfilepath" ) == 0
- or say "\n\tProblem populating the db: $section: $!";
- say "\tPopulation processing for db $section completed ...";
+ my $sqlfilepath =
+ File::ShareDir::dist_file( 'MOBY', "db/data/$section.data" );
+ system(
+ "mysql -h $url -P $port -u $username --password=$password "
+ . $dbsections{$section}
+ . "<$sqlfilepath" ) == 0
+ or (say "\n\tProblem populating the db: $section: $!" and $error++);
+ say "\tPopulation processing for db $section completed ...";
}
}
More information about the MOBY-guts
mailing list