Tweaking scripts to install for pdpd-cl image 72/79872/3
authorJorge Hernandez <jorge.hernandez-herrero@att.com>
Thu, 7 Mar 2019 05:31:48 +0000 (23:31 -0600)
committerJorge Hernandez <jorge.hernandez-herrero@att.com>
Thu, 7 Mar 2019 14:59:56 +0000 (08:59 -0600)
Change-Id: I5f7ab5de402a5412938f42ae76e21f112b106b3a
Issue-ID: POLICY-1560
Signed-off-by: Jorge Hernandez <jorge.hernandez-herrero@att.com>
packages/base/src/files/etc/cron.d/monitor.cron
packages/base/src/files/etc/profile.d/env.sh
policy-management/src/main/server-gen/bin/db-migrator
policy-management/src/main/server-gen/bin/features

index 68cb310..338c1d4 100755 (executable)
@@ -1,8 +1,8 @@
 ###
 # ============LICENSE_START=======================================================
-# Base Package
+# ONAP
 # ================================================================================
-# Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -18,4 +18,4 @@
 # ============LICENSE_END=========================================================
 ###
 
-* * * * * export POLICY_HOME=${{POLICY_HOME}}; ${{POLICY_HOME}}/bin/monitor >/dev/null 2>&1
+* * * * * bash -l -c '${POLICY_HOME}/bin/monitor >/dev/null 2>&1'
index 833064f..5a58940 100644 (file)
@@ -1,9 +1,9 @@
 #!/usr/bin/env bash
 ###
 # ============LICENSE_START=======================================================
-# Base Package
+# ONAP
 # ================================================================================
-# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # ============LICENSE_END=========================================================
 ###
 
+
+# some non-docker environments may set up POLICY_HOME
+# as a templated installation var (ie. ${{x}}) instead of
+# an environment variable (case of docker passed to the
+# container). The following condition accommodates that
+# scenario.
+
+templateRegex='^\$\{\{POLICY_HOME}}$'
+
+if [[ -z "${POLICY_HOME}" ]]; then
+    templatedPolicyHome='${{POLICY_HOME}}'
+    if [[ ! ${templatedPolicyHome} =~ ${templateRegex} ]]; then
+        POLICY_HOME=${templatedPolicyHome}
+    fi
+fi
+
 set -a
 
-POLICY_HOME=${{POLICY_HOME}}
+POLICY_HOME=${POLICY_HOME:=/opt/app/policy}
 
-source ${POLICY_HOME}/etc/build.info
-for c in ${POLICY_HOME}/etc/profile.d/*.conf ; do
+confs=$(ls "${POLICY_HOME}"/etc/profile.d/*.conf 2> /dev/null)
+for c in ${confs} ; do
     source ${c}
 done
 
-for x in ${POLICY_HOME}/bin ${JAVA_HOME}/bin ${HOME}/bin ; do
+for x in "${POLICY_HOME}"/bin "${JAVA_HOME}"/bin "${HOME}"/bin ; do
   if [ -d $x ] ; then
     case ":$PATH:" in
       *":$x:"*) :;; # already there
index 1024005..29a50d4 100644 (file)
@@ -3,7 +3,7 @@
 # ============LICENSE_START=======================================================
 # ONAP
 # ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -520,7 +520,7 @@ if [[ -z ${SCHEMA} ]]; then
        exit 2
 fi
 
-source "${POLICY_HOME}"/etc/profile.d/base.conf
+source "${POLICY_HOME}"/etc/profile.d/env.sh
 
 if [[ -z ${SQL_HOST} ]] || [[ -z ${SQL_USER} ]] || [[ -z ${SQL_PASSWORD} ]]; then
        echo "error: no database has been set up" 
index 861806a..d9c6eb2 100644 (file)
@@ -409,10 +409,9 @@ function enableDbAnalysis()
                return 0
        fi
        
-       source "${POLICY_HOME}"/etc/profile.d/base.conf
+       source "${POLICY_HOME}"/etc/profile.d/env.sh
        if [[ -z ${SQL_HOST} ]] || [[ -z ${SQL_USER} ]] || [[ -z ${SQL_PASSWORD} ]]; then
-               echo "error: not existing configuration to contact the database"
-               return 2
+               echo "warning: DB server is not configured"
        fi
 
        return 0
@@ -1086,7 +1085,7 @@ function installFeatures
                                echo "feature ${name} has been installed (no configuration present)"
                        fi
                                        
-                       customOpScript "${featureName}" "install"
+                       customOpScript "${name}" "install"
                done
                
                # check the current directory and the 'config' directory for a