You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2017/05/09 18:35:17 UTC

[2/2] incubator-trafficcontrol git commit: bypass preprocessing for postinstall if -h or -defaults flags passed

bypass preprocessing for postinstall if -h or -defaults flags passed


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

Branch: refs/heads/master
Commit: 88323e2f9bf71f91d82cb32a988e0dd06f953bb0
Parents: 9bc5f04
Author: Dan Kirkwood <da...@gmail.com>
Authored: Mon May 8 17:23:12 2017 -0600
Committer: Dewayne Richardson <de...@apache.org>
Committed: Tue May 9 12:35:13 2017 -0600

----------------------------------------------------------------------
 traffic_ops/install/bin/_postinstall | 16 +++++++++++-----
 traffic_ops/install/bin/postinstall  | 16 ++++++++++++++++
 2 files changed, 27 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/88323e2f/traffic_ops/install/bin/_postinstall
----------------------------------------------------------------------
diff --git a/traffic_ops/install/bin/_postinstall b/traffic_ops/install/bin/_postinstall
index 60da86c..ac949de 100755
--- a/traffic_ops/install/bin/_postinstall
+++ b/traffic_ops/install/bin/_postinstall
@@ -732,12 +732,12 @@ sub main {
     my $help = 0;
 
     # help string
-    my $usageString = "Usage: postinstall [-a] [-debug] [-defaults] [-r] -cfile=[config_file]\n";
+    my $usageString = "Usage: postinstall [-a] [-debug] [-defaults[=<outfile]] [-r] -cfile=[config_file]\n";
 
     GetOptions(
         "cfile=s"     => \$inputFile,
         "automatic"   => \$automatic,
-        "defaults"    => \$dumpDefaults,
+        "defaults:s"  => \$dumpDefaults,
         "debug"       => \$debug,
         "help"        => \$help
     ) or die($usageString);
@@ -770,8 +770,14 @@ sub main {
         InstallUtils::logger( "Running in automatic mode", "info" );
     }
 
-    if ($dumpDefaults) {
-        InstallUtils::logger( "Writing default configuration file to $outputConfigFile", "info" );
+    if (defined $dumpDefaults) {
+        # -defaults flag provided.
+        if ($dumpDefaults ne "") {
+	    # -defaults=<filename>  -- if -defaults without a file name, use the default.
+	    # dumpDefaults with value -- use that as output file name
+	    $outputConfigFile = $dumpDefaults;
+        }
+        InstallUtils::logger( "Writing default configuration to $outputConfigFile", "info" );
         InstallUtils::writeJson( $outputConfigFile, $defaultInputs );
         return;
     }
@@ -810,7 +816,7 @@ sub main {
     chdir("/opt/traffic_ops/install/bin");
     my $rc = InstallUtils::execCommand( "./download_web_deps", "-i" );
     if ( $rc != 0 ) {
-     errorOut("Failed to install Traffic Ops Web dependencies, check the console output and rerun postinstall once you've resolved the error");
+        errorOut("Failed to install Traffic Ops Web dependencies, check the console output and rerun postinstall once you've resolved the error");
     }
 
     # The generator functions handle checking input/default/automatic mode

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/88323e2f/traffic_ops/install/bin/postinstall
----------------------------------------------------------------------
diff --git a/traffic_ops/install/bin/postinstall b/traffic_ops/install/bin/postinstall
index e9a4c55..4d9d76b 100755
--- a/traffic_ops/install/bin/postinstall
+++ b/traffic_ops/install/bin/postinstall
@@ -14,6 +14,22 @@
 # limitations under the License.
 #
 
+for arg in "$@"; do
+	case $arg in
+		-h*) action=bypass
+			;;
+		-defaults*) action=bypass
+			;;
+	esac
+done
+
+# above options don't require any of the extra processing -- just kick off the script with
+# options intact.
+if [[ $action == "bypass" ]]; then
+	/opt/traffic_ops/install/bin/_postinstall "$@"
+	exit
+fi
+
 # make sure installed with proper permissions
 umask 022