You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ne...@apache.org on 2017/03/08 23:15:50 UTC

[6/7] incubator-trafficcontrol git commit: Corrected database connection and removed hardcoded getDbDriver function

Corrected database connection and removed hardcoded getDbDriver function


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/72f5b25b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/72f5b25b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/72f5b25b

Branch: refs/heads/master
Commit: 72f5b25bf81a4f3756b3763568cd091fbec0e696
Parents: bd79a22
Author: PeterRyder <pe...@gmail.com>
Authored: Tue Feb 7 11:14:23 2017 -0500
Committer: Dave Neuman <ne...@apache.org>
Committed: Wed Mar 8 16:15:20 2017 -0700

----------------------------------------------------------------------
 traffic_ops/install/bin/postinstall | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/72f5b25b/traffic_ops/install/bin/postinstall
----------------------------------------------------------------------
diff --git a/traffic_ops/install/bin/postinstall b/traffic_ops/install/bin/postinstall
index 634a405..0ec3273 100755
--- a/traffic_ops/install/bin/postinstall
+++ b/traffic_ops/install/bin/postinstall
@@ -87,10 +87,6 @@ my $inputFile = "";
 my $automatic = 0;
 my $defaultInputs;
 
-sub getDbDriver {
-    return "Pg";
-}
-
 sub getInstallPath {
     my $relPath = shift;
     return join( '/', "/tmp/traffic_ops", $relPath );
@@ -187,7 +183,7 @@ sub generateDbConf {
     # No YAML library installed, but this is a simple file..
     open( my $fh, '>', $toDBFileName ) or errorOut("Can't write to $toDBFileName!");
     print $fh "production:\n";
-    print $fh "    driver: ", getDbDriver() . "\n";
+    print $fh "    driver: $dbconf{type}\n";
     print $fh "    open: tcp:$dbconf{hostname}:$dbconf{port}*$dbconf{dbname}/$dbconf{user}/$dbconf{password}\n";
     close $fh;
 
@@ -563,18 +559,7 @@ sub setupDatabase {
 
     my $dbconf = InstallUtils::readJson( $databaseConfFile );
 
-    InstallUtils::logger( "Setting up database", "info" );
-    chdir("/opt/traffic_ops/app");
-    my $result = InstallUtils::execCommand( "/usr/bin/perl", "db/admin.pl", "--env=production", "setup" );
-
-    if ( $result != 0 ) {
-        errorOut("Database initialization failed");
-    }
-    else {
-        InstallUtils::logger( "Database initialization succeeded", "info" );
-    }
-
-    my $dsn = sprintf( "DBI:Pg:%s:%s:%s", "Pg", $dbconf->{"hostname"}, $dbconf->{"port"} );
+    my $dsn = sprintf( "DBI:%s:dbname=%s", $dbconf->{"type"}, $dbconf->{"dbname"} );
     my $dbh = DBI->connect( $dsn, $todbconf->{"dbAdminUser"}, $todbconf->{"dbAdminPw"} );
     if ($dbh) {
         InstallUtils::logger("Database connection succeeded", "info");
@@ -586,6 +571,17 @@ sub setupDatabase {
         exit(-1)
     }
 
+    InstallUtils::logger( "Setting up database", "info" );
+    chdir("/opt/traffic_ops/app");
+    my $result = InstallUtils::execCommand( "/usr/bin/perl", "db/admin.pl", "--env=production", "setup" );
+
+    if ( $result != 0 ) {
+        errorOut("Database initialization failed");
+    }
+    else {
+        InstallUtils::logger( "Database initialization succeeded", "info" );
+    }
+
     if ( $setupMaxmind =~ /^y(?:es)?/ ) {
         InstallUtils::logger( "Downloading Maxmind data", "info" );
         chdir("/opt/traffic_ops/app/public/routing");