required keys in ldap.conf; check host form; add base_url to defaults and q's


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

Branch: refs/heads/master
Commit: df979b164af2575159cd339036200a72215c63c2
Parents: 5b42514
Author: Dan Kirkwood <dang...@gmail.com>
Authored: Fri Aug 18 12:44:33 2017 -0600
Committer: Jeremy Mitchell <mitchell...@gmail.com>
Committed: Wed Aug 23 10:37:41 2017 -0600

----------------------------------------------------------------------
 traffic_ops/install/bin/_postinstall | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/df979b16/traffic_ops/install/bin/_postinstall
----------------------------------------------------------------------
diff --git a/traffic_ops/install/bin/_postinstall 
b/traffic_ops/install/bin/_postinstall
index 4659142..d0a711c 100755
--- a/traffic_ops/install/bin/_postinstall
+++ b/traffic_ops/install/bin/_postinstall
@@ -263,6 +263,25 @@ sub generateLdapConf {
     }
 
     my %ldapConf = getConfig( $userInput, $fileName );
+    # convert any deprecated keys to the correct key name
+    my %keys_converted = ( password => 'admin_pw', hostname => 'host' );
+    for my $key (keys %ldapConf) {
+        if ( exists $keys_converted{$key} ) {
+            $ldapConf{ $keys_converted{$key} } = delete $ldapConf{$key};
+        }
+    }
+
+    my @requiredKeys = qw{ host admin_dn admin_pw search_base };
+    for my $k (@requiredKeys) {
+        if (! exists $ldapConf{$k} ) {
+            errorOut("$k is a required key in $fileName");
+        }
+    }
+
+    # do a very loose check of form -- 'host' must be hostname:port
+    if ( $ldapConf{ host } !~ /^\S+:\d+$/ ) {
+        errorOut("host in $fileName must be of form 'hostname:port'");
+    }
 
     make_path( dirname($fileName), { mode => 0755 } );
     InstallUtils::writeJson( $fileName, \%ldapConf );
@@ -450,7 +469,11 @@ sub getDefaults {
             {
                 "Number of workers?" => "96",
                 "config_var"         => "workers"
-            }
+            },
+            {
+                "Traffic Ops url?"   => "http://localhost:3000";,
+                "config_var"         => "base_url"
+            },
         ],
         $ldapConfFile => [
             {
@@ -459,7 +482,7 @@ sub getDefaults {
             },
             {
                 "LDAP server hostname" => "",
-                "config_var"           => "hostname"
+                "config_var"           => "host"
             },
             {
                 "LDAP Admin DN" => "",
@@ -467,7 +490,7 @@ sub getDefaults {
             },
             {
                 "LDAP Admin Password" => "",
-                "config_var"          => "password",
+                "config_var"          => "admin_pw",
                 "hidden"              => "true"
             },
             {

Reply via email to