From 2265e817b8229be6edcbb0e2df228cd1f6728457 Mon Sep 17 00:00:00 2001 From: Taka Cho Date: Tue, 8 Dec 2020 16:35:43 -0500 Subject: [PATCH] remove bash to ash removal any GPL-3.0 and plus license Issue-ID: POLICY-2847 Change-Id: Ia79a1113073d596d92d78d72ce561f56be78434f Signed-off-by: Taka Cho --- scripts/policy/docker-compose-all.yml | 6 +++--- scripts/policy/wait_for_port.sh | 19 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/scripts/policy/docker-compose-all.yml b/scripts/policy/docker-compose-all.yml index 7b1f00a0..00f76350 100644 --- a/scripts/policy/docker-compose-all.yml +++ b/scripts/policy/docker-compose-all.yml @@ -51,7 +51,7 @@ services: - ./wait_for_port.sh:/opt/app/policy/api/bin/wait_for_port.sh:ro entrypoint: ./wait_for_port.sh command: [ - '-c', 'bash ./policy-api.sh', + '-c', './policy-api.sh', 'mariadb', '3306' ] pap: @@ -69,7 +69,7 @@ services: - ./wait_for_port.sh:/opt/app/policy/pap/bin/wait_for_port.sh:ro entrypoint: ./wait_for_port.sh command: [ - '-c', 'bash ./policy-pap.sh', + '-c', './policy-pap.sh', 'mariadb', '3306', 'policy.api.simpledemo.onap.org', '3905', 'api', '6969' @@ -89,7 +89,7 @@ services: - ./wait_for_port.sh:/opt/app/policy/pdpx/bin/wait_for_port.sh:ro entrypoint: ./wait_for_port.sh command: [ - '-c', 'bash ./policy-pdpx.sh', + '-c', './policy-pdpx.sh', 'mariadb', '3306', 'policy.api.simpledemo.onap.org', '3905', 'pap', '6969' diff --git a/scripts/policy/wait_for_port.sh b/scripts/policy/wait_for_port.sh index c50cd970..1d2f5155 100755 --- a/scripts/policy/wait_for_port.sh +++ b/scripts/policy/wait_for_port.sh @@ -1,35 +1,34 @@ -#!/bin/bash +#!/bin/sh tmout=120 cmd= - while getopts c:t: opt; do case "$opt" in c) cmd="$OPTARG" ;; t) tmout="$OPTARG" ;; esac done -let nargs=$OPTIND-1 +nargs=$(expr $OPTIND - 1) shift $nargs -let even_args=$#%2 -if [[ $# -lt 2 || $even_args -ne 0 ]]; then - echo "args: [-t timeout] [-c command] hostname1 port1 hostname2 port2 ..." >&2 - exit 1 +even_args=$(expr $# % 2) +if [ $# -lt 2 -o $even_args -ne 0 ]; then + echo "args: [-t timeout] [-c command] hostname1 port1 hostname2 port2 ..." >&2 + exit 1 fi -while [[ $# -ge 2 ]]; do +while [ $# -ge 2 ]; do export host=$1 export port=$2 shift shift echo "Waiting for $host port $port..." - timeout $tmout bash -c 'until nc -vz "$host" "$port"; do echo -n "."; + timeout $tmout sh -c 'until nc -vz "$host" "$port"; do echo -n "."; sleep 1; done' rc=$? - if [[ $rc != 0 ]]; then + if [ $rc != 0 ]; then echo "$host port $port cannot be reached" exit $rc fi -- 2.16.6