[freeside-commits] freeside/rt/sbin rt-setup-database.in,1.5,1.6

Ivan,,, ivan at wavetail.420.am
Sat Oct 15 02:33:55 PDT 2005


Update of /home/cvs/cvsroot/freeside/rt/sbin
In directory wavetail:/tmp/cvs-serv6970/sbin

Modified Files:
	rt-setup-database.in 
Log Message:
landing rt 3.4.4 on HEAD


Index: rt-setup-database.in
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/sbin/rt-setup-database.in,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- rt-setup-database.in	3 Dec 2004 20:51:54 -0000	1.5
+++ rt-setup-database.in	15 Oct 2005 09:33:53 -0000	1.6
@@ -1,9 +1,9 @@
 #!@PERL@ -w
-# {{{ BEGIN BPS TAGGED BLOCK
+# BEGIN BPS TAGGED BLOCK {{{
 # 
 # COPYRIGHT:
 #  
-# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC 
+# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC 
 #                                          <jesse at bestpractical.com>
 # 
 # (Except where explicitly superseded by other copyright notices)
@@ -43,7 +43,7 @@
 # works based on those contributions, and sublicense and distribute
 # those contributions and any derivatives thereof.
 # 
-# }}} END BPS TAGGED BLOCK
+# END BPS TAGGED BLOCK }}}
 use strict;
 use vars qw($PROMPT $VERSION $Handle $Nobody $SystemUser $item);
 use vars
@@ -199,6 +199,7 @@
 
 	local $SIG{__WARN__} = sub {};
 	my $is_local = 0; # local/etc/schema needs to be nonfatal. 
+        $dbh->begin_work or die $dbh->errstr;
         foreach my $statement (@schema) {
 	    if ($statement =~ /^\s*;$/) { $is_local = 1; next; }
             print STDERR "SQL: $statement\n" if defined $args{'debug'};
@@ -207,12 +208,13 @@
                 die "Problem with statement:\n $statement\n" . $sth->errstr;
             }
         }
+        $dbh->commit or die $dbh->errstr;
 
     }
     else {
         die "Couldn't find schema file for " . $RT::DatabaseType . "\n";
     }
-    print "schema sucessfully inserted\n";
+    print "Done setting up database schema.\n";
 
 }
 
@@ -220,7 +222,6 @@
 
 # {{{ sub drop_db
 sub drop_db {
-    return if ( $RT::DatabaseType eq 'SQLite' );
     if ( $RT::DatabaseType eq 'Oracle' ) {
         print <<END;
 
@@ -244,6 +245,10 @@
 
     print "Dropping $RT::DatabaseType database $RT::DatabaseName.\n";
 
+    if ( $RT::DatabaseType eq 'SQLite' ) {
+	unlink $RT::DatabaseName or warn $!;
+	return;
+    }
     $dbh->do("Drop DATABASE $RT::DatabaseName") or warn $DBI::errstr;
 }
 
@@ -276,20 +281,19 @@
 # }}}
 
 sub get_dba_password {
-    print
-"In order to create a new database and grant RT access to that database,\n";
+    print "In order to create or update your RT database,";
     print "this script needs to connect to your "
       . $RT::DatabaseType
       . " instance on "
       . $RT::DatabaseHost . " as "
       . $args{'dba'} . ".\n";
-    print
-"Please specify that user's database password below. If the user has no database\n";
+    print "Please specify that user's database password below. If the user has no database\n";
     print "password, just press return.\n\n";
     print "Password: ";
     ReadMode('noecho');
     my $password = ReadLine(0);
     ReadMode('normal');
+    print "\n";
     return ($password);
 }
 
@@ -316,15 +320,15 @@
     }
     elsif ( $RT::DatabaseType =~ /^mysql$/i ) {
         do $base_path . "/acl.mysql"
-          || die "Couldn't find ACLS for mysql in " . $RT::EtcPath . "\n" . $@;
+          || die "Couldn't find ACLS for mysql in $base_path\n" . $@;
     }
     elsif ( $RT::DatabaseType =~ /^Sybase$/i ) {
         do $base_path . "/acl.Sybase"
-          || die "Couldn't find ACLS for Sybase in " . $RT::EtcPath . "\n" . $@;
+          || die "Couldn't find ACLS for Sybase in $base_path\n" . $@;
     }
     elsif ( $RT::DatabaseType =~ /^informix$/i ) {
         do $base_path . "/acl.Informix"
-          || die "Couldn't find ACLS for Informix in " . $RT::EtcPath . "\n" . $@;
+          || die "Couldn't find ACLS for Informix in $base_path\n" . $@;
     }
     elsif ( $RT::DatabaseType =~ /^SQLite$/i ) {
         return;
@@ -341,6 +345,7 @@
             die "Problem with statement:\n $statement\n" . $sth->errstr;
         }
     }
+    print "Done setting up database ACLs.\n";
 }
 
 # }}}
@@ -405,7 +410,8 @@
         RealName => 'The RT System itself',
         Comments =>
 'Do not delete or modify this user. It is integral to RT\'s internal database structures',
-        Creator => '1' );
+        Creator => '1',
+        LastUpdatedBy => '1' );
 
     unless ($val) {
         print "$msg\n";
@@ -439,6 +445,7 @@
                              ObjectType    => 'RT::System',
                              ObjectId      => '1' );
 
+        print "done.\n";
     }
 
     # Slurp in stuff to insert from the datafile. Possible things to go in here:-
@@ -612,7 +619,7 @@
         print "done.\n";
     }
     $RT::Handle->Disconnect() unless ($RT::DatabaseType eq 'SQLite');
-
+    print "Done setting up database content.\n";
 }
 
 =head2 ACLEquivGroupId



More information about the freeside-commits mailing list