From 1d80843aabeaebbb7f2581d7772dd74b4fe57c0f Mon Sep 17 00:00:00 2001 From: Dan Kirkwood Date: Fri, 18 Aug 2017 12:44:33 -0600 Subject: [PATCH 1/2] required keys in ldap.conf; check host form; add base_url to defaults and q's --- traffic_ops/install/bin/_postinstall | 29 +++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/traffic_ops/install/bin/_postinstall b/traffic_ops/install/bin/_postinstall index 4659142c6f..d0a711cbd5 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" }, { From 9419bb8e52b6c0423e69fc2492537dd97354acbf Mon Sep 17 00:00:00 2001 From: Dan Kirkwood Date: Tue, 22 Aug 2017 20:57:22 +0000 Subject: [PATCH 2/2] updates base_url --- traffic_ops/install/bin/_postinstall | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/traffic_ops/install/bin/_postinstall b/traffic_ops/install/bin/_postinstall index d0a711cbd5..503daa2933 100755 --- a/traffic_ops/install/bin/_postinstall +++ b/traffic_ops/install/bin/_postinstall @@ -234,6 +234,10 @@ sub generateCdnConf { $#secrets = $cdnConfiguration{keepSecrets} - 1; } } + if (exists $cdnConfiguration{base_url}) { + $cdnConf->{to}{base_url} = $cdnConfiguration{base_url}; + } + $cdnConf = setCdnConfGoPort($cdnConf); $cdnConf->{hypnotoad}{workers} = $cdnConfiguration{workers}; #InstallUtils::logger("cdnConf: " . Dumper($cdnConf), "info" );