[Rt-commit] r12008 - in rt/branches/3.8-TESTING: . html/installation
sartak at bestpractical.com
sartak at bestpractical.com
Fri May 2 18:07:51 EDT 2008
Author: sartak
Date: Fri May 2 18:07:50 2008
New Revision: 12008
Modified:
rt/branches/3.8-TESTING/ (props changed)
rt/branches/3.8-TESTING/html/installation/Basics.html
rt/branches/3.8-TESTING/html/installation/DatabaseDetails.html
rt/branches/3.8-TESTING/html/installation/Finish.html
rt/branches/3.8-TESTING/html/installation/Initialize.html
rt/branches/3.8-TESTING/html/installation/Sendmail.html
rt/branches/3.8-TESTING/lib/RT/Config.pm
rt/branches/3.8-TESTING/lib/RT/Installer.pm
Log:
Modified: rt/branches/3.8-TESTING/html/installation/Basics.html
==============================================================================
--- rt/branches/3.8-TESTING/html/installation/Basics.html (original)
+++ rt/branches/3.8-TESTING/html/installation/Basics.html Fri May 2 18:07:50 2008
@@ -62,6 +62,7 @@
<%init>
my @results;
+push @results, 'Connected Database with success!' unless $RT::Installer->{InstallConfig}{DatabaseType} eq 'SQLite';
my @Types = qw/rtname Organization MinimumPasswordLength Timezone/;
@@ -81,8 +82,8 @@
RT::Interface::Web::Redirect(RT->Config->Get('WebURL') .
'installation/DatabaseDetails.html');
}
-
- unless ( @results ) {
+ if ( $RT::Installer->{InstallConfig}{DatabaseType} eq 'SQLite' ?
+ @results == 0 : @results == 1 ) {
RT::Interface::Web::Redirect(RT->Config->Get('WebURL') .
'installation/Emails.html');
}
Modified: rt/branches/3.8-TESTING/html/installation/DatabaseDetails.html
==============================================================================
--- rt/branches/3.8-TESTING/html/installation/DatabaseDetails.html (original)
+++ rt/branches/3.8-TESTING/html/installation/DatabaseDetails.html Fri May 2 18:07:50 2008
@@ -54,15 +54,9 @@
CurrentValue => RT::Installer->CurrentValues(@Types) &>
<input type="hidden" name="Run" value="1">
-<& /Elements/Submit, Label => loc('Next: Check Database Connectivity'),
-Back => 1, BackLabel => loc('Back: Select Database Type'),
+<& /Elements/Submit, Label => $RT::Installer->{InstallConfig}{DatabaseType} eq
+'SQLite' ? loc('Next: Customize Basics') : loc('Next: Check Database Connectivity'), Back => 1, BackLabel => loc('Back: Select Database Type'),
&>
-
-% if ( $results[0] eq 'connect succeed!' ) {
-<& /Elements/Submit, Label => loc('Next: Customize Basics'), Name => 'Next' &>
-% }
-
-
</form>
</&>
<%init>
@@ -81,78 +75,39 @@
if ( $Run ) {
- $m->comp('/Widgets/BulkProcess', Types => \@Types, Arguments => \%ARGS,
- Store => $RT::Installer->{InstallConfig},
- Meta => $RT::Installer->{Meta}, KeepUndef => 1 );
+ $m->comp('/Widgets/BulkProcess', Types => \@Types, Arguments => \%ARGS, Store
+ => $RT::Installer->{InstallConfig}, Meta =>
+ $RT::Installer->{Meta}, KeepUndef => 1 );
if ( $Back ) {
RT::Interface::Web::Redirect(RT->Config->Get('WebURL') .
'installation/DatabaseType.html');
}
-
- if ( $ARGS{Next} ) {
- RT::Interface::Web::Redirect(RT->Config->Get('WebURL') .
-'installation/Basics.html');
- }
- my ( $status, $msg ) = RT::Installer->SaveConfig;
- if ( $status ) {
- RT->LoadConfig;
- # dba connect systemdsn
- my $dbh = DBI->connect(
- RT::Handle->SystemDSN, $ARGS{DatabaseAdmin}, $ARGS{DatabaseAdminPassword}, { RaiseError => 0, PrintError => 0 },
- );
-
- if ( $dbh ) {
- push @results, 'connect succeed!';
- # dba connect dsn, which has table info
- $dbh = DBI->connect(
- RT::Handle->DSN, $ARGS{DatabaseAdmin}, $ARGS{DatabaseAdminPassword}, { RaiseError => 0, PrintError => 0 },
- );
+ my $handle = DBIx::SearchBuilder::Handle->new();
+ my $db_type = $RT::Installer->{InstallConfig}{DatabaseType};
- if ( $dbh ) {
- # check if Tickets table exists
- my $sth = $dbh->table_info('', '', 'Tickets', 'TABLE');
- # get 'Tickets' if it exists
- if ( ($sth->fetchrow_array)[2] ) {
-
- $sth = $dbh->prepare('select id from Users where Name=?');
- $sth->execute('RT_System');
- if ( $sth->fetchrow_array ) {
- $RT::Installer->{DatabaseAction} = 'none';
- push @results, "Database $RT::DatabaseName seems complete,
- don't need to initialize any more.";
- }
- else {
- $RT::Installer->{DatabaseAction} = 'acl,coredata,insert';
- push @results, "Database $RT::DatabaseName already exists
- and has RT tables in place, but does not contain RT's metadata. 'Initialize
- Database' later can use this existing db and tables and insert metadata, if this's ok, click 'Customize Baisc' below to go on customizing RT";
- }
- }
- else {
- $RT::Installer->{DatabaseAction} = 'schema,acl,coredata,insert';
- push @results, "Database $RT::DatabaseName already exists, but
- does not contain RT's tables and metadata. 'Initialize Database' later can use
- this existing db and insert tables and metadata, if this's ok, click
- 'Customize Baisc' below to go on customizing RT";
- }
+ my $dsn;
+ $dsn = "dbi:$db_type:";
+ if ( $db_type eq 'Pg' ) {
+ # with postgres, you want to connect to template1 database
+ $dsn .= 'dbname=template1';
+ }
+ $dsn .= ";host=$ARGS{DatabaseHost}" if $ARGS{DatabaseHost};
+ $dsn .= ";port=$ARGS{DatabasePort}" if $ARGS{DatabasePort};
+ $dsn .= ";requiressl=1" if $ARGS{DatabaseRequireSSL};
- }
- else {
- $RT::Installer->{DatabaseAction} =
- 'create,schema,acl,coredata,insert';
- }
- }
- else {
- $RT::Installer->{DatabaseAction} = 'error';
- push @results, "Failed to connect: $DBI::errstr";
- }
+ my $dbh = DBI->connect(
+ $dsn, $ARGS{DatabaseUser}, $ARGS{DatabasePassword},
+ { RaiseError => 0, PrintError => 0 },
+ );
+
+ if ( $dbh ) {
+ RT::Interface::Web::Redirect(RT->Config->Get('WebURL') .
+'installation/Basics.html');
}
else {
- push @results, $msg;
+ push @results, "Failed to connect: $DBI::errstr";
}
-
-
}
</%init>
Modified: rt/branches/3.8-TESTING/html/installation/Finish.html
==============================================================================
--- rt/branches/3.8-TESTING/html/installation/Finish.html (original)
+++ rt/branches/3.8-TESTING/html/installation/Finish.html Fri May 2 18:07:50 2008
@@ -62,25 +62,4 @@
it as you want.
</p>
</div>
-
-<form method="post">
-<input type="hidden" value="1" name="Run" />
-<& /Elements/Submit, Label => 'Start RT Journey!' &>
-</form>
-
</&>
-<%init>
-if ( $Run ) {
- RT->InstallMode(0);
- RT->LoadConfig;
- RT->ConnectToDatabase();
- RT->InitSystemObjects();
- RT->InitClasses();
- RT->InitPlugins();
- RT::Interface::Web::Redirect(RT->Config->Get('WebURL'));
-}
-</%init>
-
-<%args>
-$Run => undef
-</%args>
Modified: rt/branches/3.8-TESTING/html/installation/Initialize.html
==============================================================================
--- rt/branches/3.8-TESTING/html/installation/Initialize.html (original)
+++ rt/branches/3.8-TESTING/html/installation/Initialize.html Fri May 2 18:07:50 2008
@@ -69,61 +69,11 @@
'installation/Sendmail.html');
}
- my @actions = split /,/, $RT::Installer->{DatabaseAction};
-
- my $sysdbh = DBI->connect(
- RT::Handle->SystemDSN,
- $RT::Installer->{InstallConfig}{DatabaseAdmin},
- $RT::Installer->{InstallConfig}{DatabaseAdminPassword},
- { RaiseError => 0, PrintError => 0 },
- );
- die $DBI::errstr unless $sysdbh;
-
- my ( $status, $msg ) = ( 1, '' );
- if ( shift @actions eq 'create' ) {
- ($status, $msg) = RT::Handle->CreateDatabase( $sysdbh );
- unless ( $status ) {
- push @results, "ERROR: $msg";
- }
- }
-
- if ( $status ) {
- my $dbh = DBI->connect(
- RT::Handle->DSN, $RT::Installer->{InstallConfig}{DatabaseAdmin},
- $RT::Installer->{InstallConfig}{DatabaseAdminPassword},
- { RaiseError => 0, PrintError => 0 },
- );
- die $DBI::errstr unless $dbh;
-
- foreach my $action ( @actions ) {
- ($status, $msg) = (1, '');
- if ( $action eq 'schema' ) {
- ($status, $msg) = RT::Handle->InsertSchema( $dbh );
- }
- elsif ( $action eq 'acl' ) {
- ($status, $msg) = RT::Handle->InsertACL( $dbh );
- }
- elsif ( $action eq 'coredata' ) {
- $RT::Handle = new RT::Handle;
- $RT::Handle->dbh( undef );
- RT::ConnectToDatabase();
- RT::InitLogging();
- ($status, $msg) = $RT::Handle->InsertInitialData;
- }
- elsif ( $action eq 'insert' ) {
- $RT::Handle = new RT::Handle;
- RT::Init();
- my $file = $RT::EtcPath . "/initialdata";
- ($status, $msg) = $RT::Handle->InsertData( $file );
- }
- unless ( $status ) {
- push @results, "ERROR: $msg";
- last;
- }
- }
- }
-
- unless ( @results ) {
+ my $msg = `echo | $^X sbin/rt-setup-database --action init --dba $RT::Installer->{InstallConfig}{DatabaseUser} --dba-password '$RT::Installer->{InstallConfig}{DatabasePassword}' 2>&1`;
+ @results = split /\n/, $msg;
+# XXX $? doesn't work here, so I decided to grep the strings to find if any
+# error happens
+ unless ( grep { /^ERROR:|aborted/ } @results ) {
RT::Interface::Web::Redirect(RT->Config->Get('WebURL') .
'installation/Finish.html');
}
Modified: rt/branches/3.8-TESTING/html/installation/Sendmail.html
==============================================================================
--- rt/branches/3.8-TESTING/html/installation/Sendmail.html (original)
+++ rt/branches/3.8-TESTING/html/installation/Sendmail.html Fri May 2 18:07:50 2008
@@ -58,8 +58,7 @@
CurrentValue => RT::Installer->CurrentValues(@Types) &>
<input type="hidden" name="Run" value="1">
-<& /Elements/Submit, Label => $RT::Installer->{DatabaseAction} eq 'none' ?
-loc('Next: Finish') : loc('Next: Initialize Database'), Back => 1,
+<& /Elements/Submit, Label => loc('Next: Initialize Database'), Back => 1,
BackLabel => loc('Back: Customize Emails') &>
</form>
</&>
@@ -81,22 +80,22 @@
unless ( @results ) {
- my ( $status, $msg ) = RT::Installer->SaveConfig;
- if ( $status ) {
- RT->LoadConfig;
+ require File::Spec;
+ my $file = File::Spec->catfile($RT::EtcPath, 'RT_SiteConfig.pm');
- if ( $RT::Installer->{DatabaseAction} ne 'none' ) {
- RT::Interface::Web::Redirect(RT->Config->Get('WebURL') .
-'installation/Initialize.html');
- }
- else {
- RT::Interface::Web::Redirect(RT->Config->Get('WebURL') .
-'installation/Finish.html');
+ if ( open my $fh, '>', $file ) {
+ for ( keys %{$RT::Installer->{InstallConfig}} ) {
+ print $fh "Set( \$$_, '$RT::Installer->{InstallConfig}{$_}' );\n";
}
+ print $fh "1;\n";
+ close $fh;
+
+ RT::Interface::Web::Redirect(RT->Config->Get('WebURL') .
+'installation/Initialize.html');
}
else {
- push @results, $msg;
+ push @results, "Can't open config file $file to write: $!";
}
}
}
Modified: rt/branches/3.8-TESTING/lib/RT/Config.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Config.pm (original)
+++ rt/branches/3.8-TESTING/lib/RT/Config.pm Fri May 2 18:07:50 2008
@@ -167,7 +167,6 @@
DisableGraphViz => {
Type => 'SCALAR',
PostLoadCheck => sub {
- my $self = shift;
my $value = shift;
return if $value;
return if $INC{'GraphViz'};
Modified: rt/branches/3.8-TESTING/lib/RT/Installer.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Installer.pm (original)
+++ rt/branches/3.8-TESTING/lib/RT/Installer.pm Fri May 2 18:07:50 2008
@@ -244,24 +244,6 @@
return { map { $_ => CurrentValue($_) } @types };
}
-
-sub SaveConfig {
-
- require File::Spec;
- my $file = File::Spec->catfile($RT::EtcPath, 'RT_SiteConfig.pm');
-
- if ( open my $fh, '>', $file ) {
- for ( keys %{$RT::Installer->{InstallConfig}} ) {
- print $fh "Set( \$$_, '$RT::Installer->{InstallConfig}{$_}' );\n";
- }
- print $fh "1;\n";
- close $fh;
- return ( 1, 'saved config with success' );
- }
-
- return ( 0, "can't save config to $file: $!" );
-}
-
=head1 NAME
RT::Installer - RT's Installer
More information about the Rt-commit
mailing list