ocket8888 commented on a change in pull request #4763:
URL: https://github.com/apache/trafficcontrol/pull/4763#discussion_r520840550



##########
File path: traffic_ops/install/bin/postinstall.test.sh
##########
@@ -0,0 +1,424 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e;
+
+if [[ ! -x /usr/bin/python3 ]]; then
+       echo "Python 3.6+ is required to run - or test - postinstall.py" >&2;
+       exit 1;
+fi
+
+ROOT_DIR="$(mktemp -d)";
+
+trap 'rm -rf $ROOT_DIR' EXIT;
+
+mkdir -p "$ROOT_DIR/etc/pki/tls/certs";
+mkdir "$ROOT_DIR/etc/pki/tls/private";
+mkdir -p "$ROOT_DIR/opt/traffic_ops/app/public/routing";
+mkdir "$ROOT_DIR/opt/traffic_ops/app/db";
+mkdir -p "$ROOT_DIR/opt/traffic_ops/app/conf/production";
+echo 
"{\"hypnotoad\":{\"listen\":[\"https://[::]:60443?cert=$ROOT_DIR/etc/pki/tls/certs/localhost.crt&key=$ROOT_DIR/etc/pki/tls/private/localhost.key\"]}}";
 > "$ROOT_DIR/opt/traffic_ops/app/conf/cdn.conf";
+mkdir -p "$ROOT_DIR/opt/traffic_ops/install/data/json";
+mkdir "$ROOT_DIR/opt/traffic_ops/install/bin";
+
+MY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+cat <<- EOF > "$ROOT_DIR/defaults.json"
+{
+       "/opt/traffic_ops/app/conf/production/database.conf": [
+               {
+                       "Database type": "Pg",
+                       "config_var": "type",
+                       "hidden": false
+               },
+               {
+                       "Database name": "traffic_ops",
+                       "config_var": "dbname",
+                       "hidden": false
+               },
+               {
+                       "Database server hostname IP or FQDN": "localhost",
+                       "config_var": "hostname",
+                       "hidden": false
+               },
+               {
+                       "Database port number": "5432",
+                       "config_var": "port",
+                       "hidden": false
+               },
+               {
+                       "Traffic Ops database user": "traffic_ops",
+                       "config_var": "user",
+                       "hidden": false
+               },
+               {
+                       "Password for Traffic Ops database user": "twelve",
+                       "config_var": "password",
+                       "hidden": true
+               }
+       ],
+       "/opt/traffic_ops/app/db/dbconf.yml": [
+               {
+                       "Database server root (admin) user": "postgres",
+                       "config_var": "pgUser",
+                       "hidden": false
+               },
+               {
+                       "Password for database server admin": "twelve",
+                       "config_var": "pgPassword",
+                       "hidden": true
+               },
+               {
+                       "Download Maxmind Database?": "no",
+                       "config_var": "maxmind",
+                       "hidden": false
+               }
+       ],
+       "/opt/traffic_ops/app/conf/cdn.conf": [
+               {
+                       "Generate a new secret?": "yes",
+                       "config_var": "genSecret",
+                       "hidden": false
+               },
+               {
+                       "Number of secrets to keep?": "1",
+                       "config_var": "keepSecrets",
+                       "hidden": false
+               },
+               {
+                       "Port to serve on?": "443",
+                       "config_var": "port",
+                       "hidden": false
+               },
+               {
+                       "Number of workers?": "12",
+                       "config_var": "workers",
+                       "hidden": false
+               },
+               {
+                       "Traffic Ops url?": "http://localhost:3000";,
+                       "config_var": "base_url",
+                       "hidden": false
+               },
+               {
+                       "ldap.conf location?": 
"/opt/traffic_ops/app/conf/ldap.conf",
+                       "config_var": "ldap_conf_location",
+                       "hidden": false
+               }
+       ],
+       "/opt/traffic_ops/app/conf/ldap.conf": [
+               {
+                       "Do you want to set up LDAP?": "no",
+                       "config_var": "setupLdap",
+                       "hidden": false
+               },
+               {
+                       "LDAP server hostname": "",
+                       "config_var": "host",
+                       "hidden": false
+               },
+               {
+                       "LDAP Admin DN": "",
+                       "config_var": "admin_dn",
+                       "hidden": false
+               },
+               {
+                       "LDAP Admin Password": "",
+                       "config_var": "admin_pass",
+                       "hidden": true
+               },
+               {
+                       "LDAP Search Base": "",
+                       "config_var": "search_base",
+                       "hidden": false
+               },
+               {
+                       "LDAP Search Query": "",
+                       "config_var": "search_query",
+                       "hidden": false
+               },
+               {
+                       "LDAP Skip TLS verify": "",
+                       "config_var": "insecure",
+                       "hidden": false
+               },
+               {
+                       "LDAP Timeout Seconds": "",
+                       "config_var": "ldap_timeout_secs",
+                       "hidden": false
+               }
+       ],
+       "/opt/traffic_ops/install/data/json/users.json": [
+               {
+                       "Administration username for Traffic Ops": "admin",
+                       "config_var": "tmAdminUser",
+                       "hidden": false
+               },
+               {
+                       "Password for the admin user": "twelve",
+                       "config_var": "tmAdminPw",
+                       "hidden": true
+               }
+       ],
+       "/opt/traffic_ops/install/data/profiles/": [
+               {
+                       "Add custom profiles?": "no",
+                       "config_var": "custom_profiles",
+                       "hidden": false
+               }
+       ],
+       "/opt/traffic_ops/install/data/json/openssl_configuration.json": [
+               {
+                       "Do you want to generate a certificate?": "yes",
+                       "config_var": "genCert",
+                       "hidden": false
+               },
+               {
+                       "Country Name (2 letter code)": "US",
+                       "config_var": "country",
+                       "hidden": false
+               },
+               {
+                       "State or Province Name (full name)": "Colorado",
+                       "config_var": "state",
+                       "hidden": false
+               },
+               {
+                       "Locality Name (eg, city)": "Denver",
+                       "config_var": "locality",
+                       "hidden": false
+               },
+               {
+                       "Organization Name (eg, company)": "Comcast",
+                       "config_var": "company",
+                       "hidden": false
+               },
+               {
+                       "Organizational Unit Name (eg, section)": "Viper",
+                       "config_var": "org_unit",
+                       "hidden": false
+               },
+               {
+                       "Common Name (eg, your name or your server's 
hostname)": "cdn",
+                       "config_var": "common_name",
+                       "hidden": false
+               },
+               {
+                       "RSA Passphrase": "testquest",
+                       "config_var": "rsaPassword",
+                       "hidden": true
+               }
+       ],
+       "/opt/traffic_ops/install/data/json/profiles.json": [
+               {
+                       "Traffic Ops url": "https://localhost";,
+                       "config_var": "tm.url",
+                       "hidden": false
+               },
+               {
+                       "Human-readable CDN Name. (No whitespace, please)": 
"kabletown_cdn",
+                       "config_var": "cdn_name",
+                       "hidden": false
+               },
+               {
+                       "DNS sub-domain for which your CDN is authoritative": 
"cdn1.kabletown.net",
+                       "config_var": "dns_subdomain",
+                       "hidden": false
+               }
+       ]
+}
+EOF
+
+"$MY_DIR/postinstall.py" --no-root --root-directory="$ROOT_DIR" 
--no-restart-to --no-database --ops-user="$(whoami)" --ops-group="$(whoami)" 
--automatic --cfile="$ROOT_DIR/defaults.json" --debug 2>"$ROOT_DIR/stderr" | 
tee "$ROOT_DIR/stdout"

Review comment:
       I'll replace the group one, but the `whoami` manpage says
   
   > Same as id -un.
   
   So there's no reason to replace that one




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to