You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by fr...@apache.org on 2017/04/20 18:39:52 UTC
[03/44] incubator-trafficcontrol git commit: Corrected database
connection and removed hardcoded getDbDriver function
Corrected database connection and removed hardcoded getDbDriver function
(cherry picked from commit 72f5b25bf81a4f3756b3763568cd091fbec0e696)
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/44401f86
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/44401f86
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/44401f86
Branch: refs/heads/2.0.x
Commit: 44401f86ae0d474b0855c1ad3e0454d7669187da
Parents: a8c36d6
Author: PeterRyder <pe...@gmail.com>
Authored: Tue Feb 7 11:14:23 2017 -0500
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Wed Apr 19 15:34:01 2017 -0600
----------------------------------------------------------------------
traffic_ops/install/bin/postinstall | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/44401f86/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");