You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2017/01/27 16:53:23 UTC

[02/36] incubator-trafficcontrol git commit: Changed database to pg and made downloading maxmind database optional defaulting to yes

Changed database to pg and made downloading maxmind database optional defaulting to yes


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

Branch: refs/heads/master
Commit: 2f73509c900146dd2afee3ff299b1e238a2f4c3b
Parents: 2ab71fd
Author: peter.w.ryder <pe...@gmail.com>
Authored: Fri Jan 20 09:34:10 2017 -0500
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Fri Jan 27 09:52:53 2017 -0700

----------------------------------------------------------------------
 traffic_ops/install/bin/input.json  | 11 ++++++--
 traffic_ops/install/bin/postinstall | 47 ++++++++++++++++----------------
 2 files changed, 33 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/2f73509c/traffic_ops/install/bin/input.json
----------------------------------------------------------------------
diff --git a/traffic_ops/install/bin/input.json b/traffic_ops/install/bin/input.json
index 31b126f..136dfa7 100644
--- a/traffic_ops/install/bin/input.json
+++ b/traffic_ops/install/bin/input.json
@@ -1,7 +1,7 @@
 {
   "/opt/traffic_ops/app/conf/production/database.conf":[
     {
-      "Database type":"mysql",
+      "Database type":"pg",
       "config_var":"type"
     },
     {
@@ -24,6 +24,10 @@
       "Traffic Ops database password":"default",
       "config_var":"password",
       "hidden":"1"
+    },
+    {
+      "Download Maxmind Database?":"yes",
+      "config_var":"maxmind"
     }
   ],
   "/opt/traffic_ops/app/db/dbconf.yml":[
@@ -82,7 +86,10 @@
     }
   ],
   "/opt/traffic_ops/install/data/profiles/":[
-
+    {
+      "Add custom profiles?":"no",
+      "config_var":"custom_profiles"
+    }
   ],
   "/opt/traffic_ops/install/data/json/openssl_configuration.json":[
     {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/2f73509c/traffic_ops/install/bin/postinstall
----------------------------------------------------------------------
diff --git a/traffic_ops/install/bin/postinstall b/traffic_ops/install/bin/postinstall
index 0f187b8..f1aa23f 100755
--- a/traffic_ops/install/bin/postinstall
+++ b/traffic_ops/install/bin/postinstall
@@ -87,7 +87,7 @@ my $automatic = 0;
 my $defaultInputs;
 
 sub getDbDriver {
-    return "mymysql";
+    return "pg";
 }
 
 sub getInstallPath {
@@ -407,6 +407,10 @@ sub getDefaults {
                 "Password for Traffic Ops database user" => "",
                 "config_var"                             => "password",
                 "hidden"                                 => "true"
+            },
+            {
+                "Download Maxmind Database?" => "yes",
+                "config_var" => "maxmind"
             }
         ],
         $dbConfFile => [
@@ -464,7 +468,12 @@ sub getDefaults {
                 "hidden"                      => "true"
             }
         ],
-        $profilesConfFile => [],
+        $profilesConfFile => [
+            {
+                "Add custom profiles?" =>"no",
+                "config_var" => "custom_profiles"
+            }
+        ],
         $opensslConfFile  => [
             {
                 "Do you want to generate a certificate?" => "yes",
@@ -559,19 +568,11 @@ sub setupDatabase {
     my $todbconf    = shift;
     my $opensslconf = shift;
     my $genCert     = shift;
-
-    #
-    # Call mysql initialization script.
-    #
-    InstallUtils::logger( "Creating database with user: $todbconf->{dbAdminUser}", "info" );
-    my $result = InstallUtils::execCommand( "/opt/traffic_ops/install/bin/create_db", $todbconf->{dbAdminUser}, $todbconf->{dbAdminPw} );
-    if ( $result != 0 ) {
-        errorOut("Failed to create the database");
-    }
+    my $setupMaxmind = shift;
 
     InstallUtils::logger( "Setting up database", "info" );
     chdir("/opt/traffic_ops/app");
-    $result = InstallUtils::execCommand( "/usr/bin/perl", "db/admin.pl", "--env=production", "setup" );
+    my $result = InstallUtils::execCommand( "/usr/bin/perl", "db/admin.pl", "--env=production", "setup" );
 
     if ( $result != 0 ) {
         errorOut("Database initialization failed");
@@ -580,16 +581,16 @@ sub setupDatabase {
         InstallUtils::logger( "Database initialization succeeded", "info" );
     }
 
-    $result = InstallUtils::execCommand( "/opt/traffic_ops/install/bin/dataload", $todbconf->{dbAdminUser}, $todbconf->{dbAdminPw} );
-    if ( $result != 0 ) {
-        InstallUtils::logger( "Failed to load seed data", "error" );
+    if ($setupMaxmind =~ /^y(?:es)?/) {
+        InstallUtils::logger( "Downloading Maxmind data", "info" );
+        chdir("/opt/traffic_ops/app/public/routing");
+        $result = InstallUtils::execCommand("/usr/bin/wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz");
+        if ( $result != 0 ) {
+            InstallUtils::logger( "Failed to download MaxMind data", "error" );
+        }
     }
-
-    InstallUtils::logger( "Downloading MaxMind data", "info" );
-    chdir("/opt/traffic_ops/app/public/routing");
-    $result = InstallUtils::execCommand("/usr/bin/wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz");
-    if ( $result != 0 ) {
-        InstallUtils::logger( "Failed to download MaxMind data", "error" );
+    else {
+        InstallUtils::logger("Not downloading Maxmind data");
     }
 
     InstallUtils::logger( "Copying coverage zone file to public dir", "info" );
@@ -758,10 +759,10 @@ sub main {
     # if reconfigure is set then setup the database
     if ($reconfigure) {
         if ($automatic) {
-            setupDatabase( $todbconf, $opensslConfFile, $opensslconf->{genCert} );
+            setupDatabase( $todbconf, $opensslConfFile, $opensslconf->{"genCert"}, $todbconf->{"maxmind"} );
         }
         else {
-            setupDatabase( $todbconf, 0, $opensslconf->{genCert} );
+            setupDatabase( $todbconf, 0, $opensslconf->{"genCert"} );
         }
     }