aboutsummaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/main/scripts/install/siteconf.pl
diff options
context:
space:
mode:
authorVenkata Harish K Kajur <vk250x@att.com>2017-05-12 17:36:59 -0400
committerVenkata Harish K Kajur <vk250x@att.com>2017-05-12 17:37:13 -0400
commitb5b99b72733ca5c064b46fdf4527ace28b8b545b (patch)
treeb1606e7d824e5d56b3530f724bf7bf326f9a7833 /aai-traversal/src/main/scripts/install/siteconf.pl
parentb6a2b26886ac329dd0836270127c1b9d283c3659 (diff)
Add all of the traversal source files
Change-Id: Id31f4bdda9c86f782f86829f8b86dada959a9729 Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-traversal/src/main/scripts/install/siteconf.pl')
-rw-r--r--aai-traversal/src/main/scripts/install/siteconf.pl100
1 files changed, 100 insertions, 0 deletions
diff --git a/aai-traversal/src/main/scripts/install/siteconf.pl b/aai-traversal/src/main/scripts/install/siteconf.pl
new file mode 100644
index 0000000..d035851
--- /dev/null
+++ b/aai-traversal/src/main/scripts/install/siteconf.pl
@@ -0,0 +1,100 @@
+#!/usr/bin/perl
+# CC_ID_SITECONF_PL[] = "@(#)/vobs/waas/src/oam/siteconf.pl@@/main/4"
+
+#.Description
+# This perl script takes as input template file,
+# and one or more configuration files. It uses the values in the
+# configuration files as substitutions for the matching tags in the template
+# file.
+
+#.Constraints
+# The input files must be readable by the script.
+
+#.See Also
+#
+
+use Getopt::Std;
+
+local $dbg=0;
+
+getopts ('dt:c:');
+
+if ($opt_d) {
+ $dbg=$opt_d;
+}
+
+if ($dbg) {
+ print STDERR "opt_d=$opt_d\n";
+ print STDERR "opt_t=$opt_t\n";
+ print STDERR "opt_c=$opt_c\n";
+}
+
+###
+# Print usage if no arguments passed
+if (! $opt_t) {
+ print STDERR "Usage: $0 -t templatefile -c configfilelist\n";
+ exit (1);
+}
+
+# process the template file variable
+if ($opt_t) {
+ if (! -r $opt_t) {
+ print STDERR "Error: Can't read template file $opt_t\n";
+ exit (2);
+ }
+ $templatefile = $opt_t;
+}
+else {
+ print STDERR "Error: You must enter the template file name\n";
+ exit (2);
+}
+
+###
+# Global error flag for return code when exiting
+$err = 0;
+
+$configlist = '';
+if ($opt_c) {
+ $configlist = $opt_c;
+}
+
+# process the site configuration file variable
+if ($configlist) {
+ @siteary = split /,/, $configlist;
+}
+
+# Add PROJECT_HOME to Conf dictionary
+$Conf{'PROJECT_HOME'} = $ENV{'PROJECT_HOME'};
+
+foreach $arg (@siteary) {
+ if ($dbg) { print STDERR "Opening $arg\n" }
+
+ open(CONF, $arg) || die $!, ", '$arg'\n";
+
+ while (<CONF>) {
+ #1 while chomp();
+ $_ =~ s/[\r\n]$//g; # strip newlines and dos-injected carriage returns
+ if ( /=/ ) {
+ ($attr,$value) = split(/=/,$_,2);
+ $value =~ s/\$PHOME/$ENV{'PROJECT_HOME'}/;
+ $value =~ s/\$PROJECT_HOME/$ENV{'PROJECT_HOME'}/;
+ $Conf{$attr} = $value;
+ }
+ }
+
+ close CONF;
+}
+
+if ($dbg) { print STDERR "Expanding $templatefile\n" }
+
+# Expand a config file
+
+open(TEMPLATE, $templatefile) || die $!, ", '$templatefile'\n";
+while (<TEMPLATE>) {
+ # handle strings such as @HTTP_ROOT@@HTTP_PORT@
+ s/@(\w+)@/$Conf{$1}/g;
+ print;
+}
+
+close TEMPLATE;
+