Add quotes around variable in db script 96/118696/2
authorJim Hahn <jrh3@att.com>
Tue, 2 Mar 2021 15:09:42 +0000 (10:09 -0500)
committerJim Hahn <jrh3@att.com>
Tue, 2 Mar 2021 16:03:00 +0000 (11:03 -0500)
Apparently, ash doesn't like "[ -z ${xxx} ]" if the content of $xxx
contains spaces.  Added quotes around ${xxx}.
Also fixed:
- a couple of "[" "]" mismatches
- a logic error in the selection of upgrade scripts

Issue-ID: POLICY-3117
Change-Id: I99c977825fe9df8a44c288b6307cd3e55c504f86
Signed-off-by: Jim Hahn <jrh3@att.com>
packages/docker/src/main/docker/pdpd-entrypoint.sh
policy-management/src/main/server-gen/bin/db-migrator

index 56b53e3..e12f7d5 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env ash
 
 # ########################################################################
-# Copyright 2019-2020 AT&T Intellectual Property. All rights reserved
+# Copyright 2019-2021 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.
@@ -205,7 +205,7 @@ function start {
 }
 
 function configure {
-    if [ "${DEBUG}" = "y" ]]; then
+    if [ "${DEBUG}" = "y" ]; then
         echo "-- configure --"
         set -x
     fi
index db82fc3..3151e7c 100644 (file)
@@ -3,7 +3,7 @@
 # ============LICENSE_START=======================================================
 # ONAP
 # ================================================================================
-# Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2021 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.
@@ -194,7 +194,7 @@ function is_upgrade
     local upgradeSqls
 
     upgradeSqls=$(ls "${UPGRADE_DIR}"/*"${UPGRADE_SQL_SUFFIX}" 2> /dev/null)
-    if [ -z ${upgradeSqls} ]; then
+    if [ -z "${upgradeSqls}" ]; then
         return 1
     else
         return 0
@@ -216,7 +216,7 @@ function is_downgrade
     local downgradeSqls
 
     downgradeSqls=$(ls "${DOWNGRADE_DIR}"/*"${DOWNGRADE_SQL_SUFFIX}" 2> /dev/null)
-    if [ -z ${downgradeSqls} ]; then
+    if [ -z "${downgradeSqls}" ]; then
         return 1
     else
         return 0
@@ -296,7 +296,7 @@ function track_script
 
 function run_script
 {
-    if [ "${DEBUG}" == "y" ]]; then
+    if [ "${DEBUG}" == "y" ]; then
         echo "-- run_script $* --"
         set -x
     fi
@@ -342,7 +342,7 @@ function upgrade
             sqlName=$(basename "${sqlFile}")
             schemaVersion="${sqlName%-*}"
             if [ "${schemaVersion}" -gt "${CURRENT_RELEASE}" ] && \
-                [ "${schemaVersion}" -le "${TARGET_UPGRADE_RELEASE}" ]; then
+                [ "${schemaVersion}" -le "${TARGET_UPGRADE_RELEASE}" ]; then
                 run_script "upgrade" "${sqlName}" "${sqlFile}"
                 rc=$?
                 if [ ${rc} -ne 0 ]; then