summaryrefslogtreecommitdiff
path: root/rt/sbin/rt-setup-database.in
diff options
context:
space:
mode:
authorivan <ivan>2004-12-03 20:51:54 +0000
committerivan <ivan>2004-12-03 20:51:54 +0000
commite81cd66ea62231e89fbd30a95a0e5bdde2292eeb (patch)
treef7c448e7fde74afcea2eedc050d1a7a03b76341c /rt/sbin/rt-setup-database.in
parentf7fd2a3e34da751cbc02bbf215e99c6dc89adc15 (diff)
landing rt 3.2.2
Diffstat (limited to 'rt/sbin/rt-setup-database.in')
-rw-r--r--rt/sbin/rt-setup-database.in77
1 files changed, 61 insertions, 16 deletions
diff --git a/rt/sbin/rt-setup-database.in b/rt/sbin/rt-setup-database.in
index 0b9a1071a..9d8fd2ee0 100644
--- a/rt/sbin/rt-setup-database.in
+++ b/rt/sbin/rt-setup-database.in
@@ -1,9 +1,15 @@
#!@PERL@ -w
-# BEGIN LICENSE BLOCK
+# {{{ BEGIN BPS TAGGED BLOCK
#
-# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+# <jesse@bestpractical.com>
#
-# (Except where explictly superceded by other copyright notices)
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
#
# This work is made available to you under the terms of Version 2 of
# the GNU General Public License. A copy of that license should have
@@ -15,14 +21,29 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
-# Unless otherwise specified, all modifications, corrections or
-# extensions to this work which alter its source code become the
-# property of Best Practical Solutions, LLC when submitted for
-# inclusion in the work.
+# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
-# END LICENSE BLOCK
-
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# }}} END BPS TAGGED BLOCK
use strict;
use vars qw($PROMPT $VERSION $Handle $Nobody $SystemUser $item);
use vars
@@ -87,10 +108,30 @@ if ( $args{'action'} eq 'init' ) {
print "...skipped as ".$args{'dba'} ." is not " . $RT::DatabaseUser . " or we're working with Oracle.\n";
}
- $dbh->disconnect;
- $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} )
- || die $DBI::errstr;
+ if ($RT::DatabaseType eq "mysql") {
+ # Check which version we're running
+ my ($version) = $dbh->selectrow_hashref("show variables like 'version'")->{Value} =~ /^(\d\.\d+)/;
+ print "*** Warning: RT is unsupported on MySQL versions before 4.0.x\n" if $version < 4;
+
+ # MySQL must have InnoDB support
+ my $innodb = $dbh->selectrow_hashref("show variables like 'have_innodb'")->{Value};
+ if ($innodb eq "NO") {
+ die "RT requires that MySQL be compiled with InnoDB table support.\n".
+ "See http://dev.mysql.com/doc/mysql/en/InnoDB.html\n";
+ } elsif ($innodb eq "DISABLED") {
+ die "RT requires that MySQL InnoDB table support be enabled.\n".
+ ($version < 4
+ ? "Add 'innodb_data_file_path=ibdata1:10M:autoextend' to the [mysqld] section of my.cnf\n"
+ : "Remove the 'skip-innodb' line from your my.cnf file, restart MySQL, and try again.\n");
+ }
+ }
+
+ # SQLite can't deal with the disconnect/reconnect
+ unless ($RT::DatabaseType eq 'SQLite') {
+ $dbh->disconnect;
+ $dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} ) || die $DBI::errstr;
+ }
print "Now populating database schema.\n";
insert_schema();
print "Now inserting database ACLs\n";
@@ -114,7 +155,7 @@ elsif ( $args{'action'} eq 'insert_initial' ) {
insert_initial_data();
}
elsif ( $args{'action'} eq 'insert' ) {
- insert_data( $args{'datafile'} );
+ insert_data( $args{'datafile'} || ($args{'datadir'}."/content"));
}
elsif ($args{'action'} eq 'acl') {
$dbh = DBI->connect( $Handle->DSN, $args{'dba'}, $args{'dba-password'} )
@@ -277,6 +318,10 @@ sub insert_acl {
do $base_path . "/acl.mysql"
|| die "Couldn't find ACLS for mysql in " . $RT::EtcPath . "\n" . $@;
}
+ elsif ( $RT::DatabaseType =~ /^Sybase$/i ) {
+ do $base_path . "/acl.Sybase"
+ || die "Couldn't find ACLS for Sybase in " . $RT::EtcPath . "\n" . $@;
+ }
elsif ( $RT::DatabaseType =~ /^informix$/i ) {
do $base_path . "/acl.Informix"
|| die "Couldn't find ACLS for Informix in " . $RT::EtcPath . "\n" . $@;
@@ -339,7 +384,7 @@ sub insert_initial_data {
#Put together a current user object so we can create a User object
my $CurrentUser = new RT::CurrentUser();
- print "Checking for existing system user ($CurrentUser)...";
+ print "Checking for existing system user...";
my $test_user = RT::User->new($CurrentUser);
$test_user->Load('RT_System');
if ( $test_user->id ) {
@@ -367,7 +412,7 @@ sub insert_initial_data {
exit(1);
}
print "done.\n";
- $RT::Handle->Disconnect();
+ $RT::Handle->Disconnect() unless ($RT::DatabaseType eq 'SQLite');
}
@@ -566,7 +611,7 @@ sub insert_data {
}
print "done.\n";
}
- $RT::Handle->Disconnect();
+ $RT::Handle->Disconnect() unless ($RT::DatabaseType eq 'SQLite');
}