[COMMON] Fix bashisms in import-custom-cert 26/123926/6
authorguillaume.lambert <guillaume.lambert@orange.com>
Tue, 7 Sep 2021 14:09:54 +0000 (16:09 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Tue, 7 Sep 2021 14:32:25 +0000 (16:32 +0200)
Bashisms of type (should be 'b = a') were all fixed previously
but a new one was reintroduced during the fixes of other types.

Also commit f79b6676cfdc380e004f184a21bb969b2824c06e moved
import-custom-cert shebang from bash to sh but substring syntaxes
similar to ${f: -4} and only supported by bash were not migrated.

Let's fix that alltogether
before enforcing the checkbashisms tox profile.

Issue-ID: OOM-2643
Issue-ID: POLICY-3232
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: Ie9b5ac1c2edd9ddf3574f09c77ca8734f2311d1d

kubernetes/common/cert-wrapper/resources/import-custom-certs.sh

index 6df7505..eb07a74 100755 (executable)
@@ -37,10 +37,10 @@ for f in $CERTS_DIR/*; do
     # Dont use onap truststore when aaf is disabled
     continue
   fi
-  if [ ${f: -3} = ".sh" ]; then
+  if echo $f | grep '\.sh$' >/dev/null; then
     continue
   fi
-  if [ ${f: -4} = ".b64" ]
+  if echo $f | grep '\.b64$' >/dev/null; then
     then
       base64 -d $f > $WORK_DIR/`basename $f .b64`
     else
@@ -49,8 +49,7 @@ for f in $CERTS_DIR/*; do
 done
 
 for f in $MORE_CERTS_DIR/*; do
-  if [ ${f: -4} == ".pem" ]
-    then
+  if echo $f | grep '\.pem$' >/dev/null; then
       cp $f $WORK_DIR/.
   fi
 done
@@ -67,7 +66,7 @@ fi
 
 # Import Custom Certificates
 for f in $WORK_DIR/*; do
-  if [ ${f: -4} = ".pem" ]; then
+  if echo $f | grep '\.pem$' >/dev/null; then
     echo "importing certificate: $f"
     keytool -import -file $f -alias `basename $f` -keystore $WORK_DIR/$TRUSTSTORE_OUTPUT_FILENAME -storepass $TRUSTSTORE_PASSWORD -noprompt
     if [ $? != 0 ]; then