aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>2017-09-08 21:19:01 +0200
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>2017-09-08 21:19:46 +0200
commit8b810c6a4d80112a2d07cc5599984403d590579d (patch)
treee00ce454a5323e0b8851a155854a838c15437215
parent91312836e649c24d2d0268f1f5c8aa45fdd79a8d (diff)
bash scripts: Fix remaining shellcheck warn/errs
Fix/silence all shellcheck errors, except for scripts in <prototypes/sfc_tacker>. Change-Id: Idc317cdba0f69b78299f2d3665e72ffc19dd8af5 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
-rwxr-xr-xci/deploy.sh2
-rwxr-xr-xmcp/config/states/dpdk2
-rwxr-xr-xmcp/config/states/maas9
-rwxr-xr-xmcp/patches/patch.sh2
-rw-r--r--mcp/scripts/lib.sh2
5 files changed, 11 insertions, 6 deletions
diff --git a/ci/deploy.sh b/ci/deploy.sh
index 4b64000e1..5e0732aec 100755
--- a/ci/deploy.sh
+++ b/ci/deploy.sh
@@ -184,7 +184,7 @@ do
if [ -n "${bridge}" ]; then
OPNFV_BRIDGES[${OPNFV_BRIDGE_IDX}]="${bridge}"
fi
- OPNFV_BRIDGE_IDX=$[OPNFV_BRIDGE_IDX + 1]
+ OPNFV_BRIDGE_IDX=$((OPNFV_BRIDGE_IDX + 1))
done
IFS=${OIFS}
;;
diff --git a/mcp/config/states/dpdk b/mcp/config/states/dpdk
index c1ec07e27..ad435630c 100755
--- a/mcp/config/states/dpdk
+++ b/mcp/config/states/dpdk
@@ -2,7 +2,7 @@
set -x
salt -I 'nova:compute' system.reboot
-while true; do salt -I 'nova:compute' test.ping | fgrep -q 'Not connected' || break; done
+while true; do salt -I 'nova:compute' test.ping | grep -Fq 'Not connected' || break; done
salt -I 'nova:compute' state.sls linux.network
# switch to UCA repos since fuel-infra packages have bugs
diff --git a/mcp/config/states/maas b/mcp/config/states/maas
index 710ec0e82..db0bd3fe6 100755
--- a/mcp/config/states/maas
+++ b/mcp/config/states/maas
@@ -3,10 +3,12 @@ set -x
function wait_for() {
local total_attempts=$1; shift
- local cmdstr=$@
+ local cmdstr=$*
local sleep_time=10
echo "[NOTE] Waiting for cmd to return success: ${cmdstr}"
+ # shellcheck disable=SC2034
for attempt in $(seq "${total_attempts}"); do
+ # shellcheck disable=SC2015
eval "${cmdstr}" && break || true
echo -n '.'; sleep "${sleep_time}"
done
@@ -17,8 +19,10 @@ function maas_fixup() {
local statuscmd="salt 'mas01*' --out yaml state.apply maas.machines.status"
wait_for 180 "${statuscmd} | tee /dev/stderr | " \
"grep -Eq '((Deployed|Ready): 5|status:Failed|status:Allocated)'"
+ # shellcheck disable=SC2155
local statusout=$(eval "${statuscmd}")
+ # shellcheck disable=SC2155
local fcnodes=$(echo "${statusout}" | \
grep -Po '(?<=system_id:)(.*)(?=,status:Failed commissioning)')
for node_system_id in ${fcnodes}; do
@@ -30,6 +34,7 @@ function maas_fixup() {
return 1
fi
+ # shellcheck disable=SC2155
local fdnodes=$(echo "${statusout}" | \
grep -Po '(?<=system_id:)(.*)(?=,status:(Failed deployment|Allocated))')
for node_system_id in ${fdnodes}; do
@@ -106,4 +111,4 @@ wait_for 10 "! salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' state.apply linux,ntp |
"tee /dev/stderr | fgrep -q 'Not connected'"
wait_for 10 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' ssh.set_auth_key ${SUDO_USER} \
- $(awk 'NR==1{print $2}' $(eval echo ~${SUDO_USER}/.ssh/authorized_keys))"
+ $(awk 'NR==1{print $2}' "$(eval echo "~${SUDO_USER}/.ssh/authorized_keys")")"
diff --git a/mcp/patches/patch.sh b/mcp/patches/patch.sh
index aac0017b2..6cd65fd10 100755
--- a/mcp/patches/patch.sh
+++ b/mcp/patches/patch.sh
@@ -2,7 +2,7 @@
if [ -r "$1" ]; then
while IFS=': ' read -r p_dest p_file; do
- [[ "${p_dest}" =~ "$2" ]] && \
+ [[ "${p_dest}" =~ $2 ]] && \
patch -fd "${p_dest}" -p1 < "/root/fuel/mcp/patches/${p_file}"
done < "$1"
fi
diff --git a/mcp/scripts/lib.sh b/mcp/scripts/lib.sh
index 94a9bd3c3..e123e5231 100644
--- a/mcp/scripts/lib.sh
+++ b/mcp/scripts/lib.sh
@@ -141,7 +141,7 @@ start_vms() {
# start vms
for node in "${vnodes[@]}"; do
virsh start "${node}"
- sleep $[RANDOM%5+1]
+ sleep $((RANDOM%5+1))
done
}