Improve localize scripts

Improve scripts to avoid unecessary WAR repackaging. Tomcat extracts WAR content
when deployed so there is no need to repackage whole WAR (time-costly operation)
in order to update template properties

Issue-ID: VID-164
Change-Id: I2aa2db915ba7408cf9da51a28695c4890c369312
Signed-off-by: kurczews <krzysztof.kurczewski@nokia.com>
diff --git a/deliveries/src/main/scripts/localize.sh b/deliveries/src/main/scripts/localize.sh
index 3966f70..aca557f 100755
--- a/deliveries/src/main/scripts/localize.sh
+++ b/deliveries/src/main/scripts/localize.sh
@@ -1,18 +1,23 @@
 #!/bin/bash
 
-#Extract the WAR so it can be customized by the localization script
-cd /tmp/vid/stage
-jar -xf vid.war
-
-source /tmp/vid/localize_war.sh || {
-	echo "ERROR: Localization script failed"
-	exit 2
+fillTemplateProperties() {
+  source /tmp/vid/localize_war.sh $1 || {
+  	echo "ERROR: Localization script failed"
+  	exit 2
+  }
 }
 
-#Create the customized WAR and deploy it to Tomcat
-mkdir -p /tmp/vid/deployed
-cd /tmp/vid/stage
-jar -cvf /tmp/vid/deployed/vid.war .
-cd
-mv -f /tmp/vid/deployed/vid.war /usr/local/tomcat/webapps
+deployWarOnTomcatManually() {
+  cd /usr/local/tomcat/webapps/
+  mkdir vid
+  cd vid
+  jar -xf /tmp/vid/stage/vid.war
+}
+
+deployWarOnTomcatManually
+
+TEMPLATES_BASE_DIR=/usr/local/tomcat/webapps/vid/WEB-INF
+
+fillTemplateProperties ${TEMPLATES_BASE_DIR}
+
 catalina.sh run
diff --git a/deliveries/src/main/scripts/localize_asdc.sh b/deliveries/src/main/scripts/localize_asdc.sh
index 549c17a..af48318 100755
--- a/deliveries/src/main/scripts/localize_asdc.sh
+++ b/deliveries/src/main/scripts/localize_asdc.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/asdc.properties
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/asdc_template.properties
+FINAL_CONFIG_FILE=$1/conf/asdc.properties
+TEMPLATE_CONFIG_FILE=$1/conf/asdc_template.properties
 
 echo "Localizing the ASDC client configuration"
 
diff --git a/deliveries/src/main/scripts/localize_cache.sh b/deliveries/src/main/scripts/localize_cache.sh
index d25949c..2d676c3 100755
--- a/deliveries/src/main/scripts/localize_cache.sh
+++ b/deliveries/src/main/scripts/localize_cache.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/classes/cache.ccf
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/classes/cache_template.ccf
+FINAL_CONFIG_FILE=$1/classes/cache.ccf
+TEMPLATE_CONFIG_FILE=$1/classes/cache_template.ccf
 
 echo "Localizing the VID cache configuration"
 
diff --git a/deliveries/src/main/scripts/localize_log4j.sh b/deliveries/src/main/scripts/localize_log4j.sh
index d2ab2bb..121f567 100755
--- a/deliveries/src/main/scripts/localize_log4j.sh
+++ b/deliveries/src/main/scripts/localize_log4j.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/log4j.properties
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/log4j_template.properties
+FINAL_CONFIG_FILE=$1/conf/log4j.properties
+TEMPLATE_CONFIG_FILE=$1/conf/log4j_template.properties
 
 echo "Localizing the VID log4j configuration"
 
diff --git a/deliveries/src/main/scripts/localize_logback.sh b/deliveries/src/main/scripts/localize_logback.sh
index 43798eb..a0f1773 100755
--- a/deliveries/src/main/scripts/localize_logback.sh
+++ b/deliveries/src/main/scripts/localize_logback.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/classes/logback.xml
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/classes/logback_template.xml
+FINAL_CONFIG_FILE=$1/classes/logback.xml
+TEMPLATE_CONFIG_FILE=$1/classes/logback_template.xml
 
 echo "Localizing the VID logback configuration"
 
diff --git a/deliveries/src/main/scripts/localize_portal.sh b/deliveries/src/main/scripts/localize_portal.sh
index f29d485..947e0e1 100755
--- a/deliveries/src/main/scripts/localize_portal.sh
+++ b/deliveries/src/main/scripts/localize_portal.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/classes/portal.properties
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/classes/portal_template.properties
+FINAL_CONFIG_FILE=$1/classes/portal.properties
+TEMPLATE_CONFIG_FILE=$1/classes/portal_template.properties
 
 echo "Localizing the VID portal configuration"
 
diff --git a/deliveries/src/main/scripts/localize_quartz.sh b/deliveries/src/main/scripts/localize_quartz.sh
index c284e6c..c22d879 100755
--- a/deliveries/src/main/scripts/localize_quartz.sh
+++ b/deliveries/src/main/scripts/localize_quartz.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/quartz.properties
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/quartz_template.properties
+FINAL_CONFIG_FILE=$1/conf/quartz.properties
+TEMPLATE_CONFIG_FILE=$1/conf/quartz_template.properties
 
 echo "Localizing the VID quartz configuration"
 
diff --git a/deliveries/src/main/scripts/localize_system.sh b/deliveries/src/main/scripts/localize_system.sh
index a739335..0947d49 100755
--- a/deliveries/src/main/scripts/localize_system.sh
+++ b/deliveries/src/main/scripts/localize_system.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/system.properties
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/system_template.properties
+FINAL_CONFIG_FILE=$1/conf/system.properties
+TEMPLATE_CONFIG_FILE=$1/conf/system_template.properties
 
 echo "Localizing the VID system configuration"
 
diff --git a/deliveries/src/main/scripts/localize_war.sh b/deliveries/src/main/scripts/localize_war.sh
index f0669e0..99cb177 100755
--- a/deliveries/src/main/scripts/localize_war.sh
+++ b/deliveries/src/main/scripts/localize_war.sh
@@ -1,31 +1,31 @@
 #!/bin/bash
 
-source /tmp/vid/localize_logback.sh || {
+source /tmp/vid/localize_logback.sh $1 || {
 	echo "ERROR: Localizing logback.xml failed"
 	exit 1
 }
 
-source /tmp/vid/localize_portal.sh || {
+source /tmp/vid/localize_portal.sh $1 || {
 	echo "ERROR: Localizing portal.properties failed"
 	exit 1
 }
 
-source /tmp/vid/localize_quartz.sh || {
+source /tmp/vid/localize_quartz.sh $1 || {
 	echo "ERROR: Localizing quartz.properties failed"
 	exit 1
 }
 
-source /tmp/vid/localize_system.sh || {
+source /tmp/vid/localize_system.sh $1 || {
 	echo "ERROR: Localizing system.properties failed"
 	exit 1
 }
 
-source /tmp/vid/localize_cache.sh || {
+source /tmp/vid/localize_cache.sh $1 || {
 	echo "ERROR: Localizing cache.ccf failed"
 	exit 1
 }
 
-source /tmp/vid/localize_asdc.sh || {
+source /tmp/vid/localize_asdc.sh $1 || {
 	echo "ERROR: Localizing asdc.properties failed"
 	exit 1
 }