From 1a2776f052d843cc79a94b03549b47cfcececb52 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Tue, 9 Feb 2021 01:37:31 +0100 Subject: [PATCH] shellcheck: demo.sh make shellcheck happy on demo.sh Signed-off-by: Guillaume Abrioux (cherry picked from commit 08a74b7e2c61738b7b771c059a93445a01dd89ab) --- src/daemon/demo.sh | 7 +++++-- travis-builds/validate_demo_cluster.sh | 14 +++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/daemon/demo.sh b/src/daemon/demo.sh index ced4845c3..4c119a7bd 100755 --- a/src/daemon/demo.sh +++ b/src/daemon/demo.sh @@ -12,6 +12,7 @@ MDS_PATH="/var/lib/ceph/mds/${CLUSTER}-$MDS_NAME" RGW_PATH="/var/lib/ceph/radosgw/${CLUSTER}-rgw.${RGW_NAME}" # shellcheck disable=SC2153 MGR_PATH="/var/lib/ceph/mgr/${CLUSTER}-$MGR_NAME" +# shellcheck disable=SC2034 MGR_IP=$MON_IP : "${DEMO_DAEMONS:=all}" : "${RGW_ENABLE_USAGE_LOG:=true}" @@ -35,6 +36,7 @@ MGR_IP=$MON_IP ####### function bootstrap_mon { if [[ ! "${CEPH_VERSION}" =~ ^(luminous|mimic)$ ]]; then + # shellcheck disable=SC2034 MON_PORT=3300 fi # shellcheck disable=SC1091 @@ -73,7 +75,7 @@ function parse_size { function bootstrap_osd { # Apply the tuning on Nautilus and above only since the values applied are causing the ceph-osd to crash on earlier versions if [[ ${OSD_BLUESTORE} -eq 1 ]] && [[ ! "${CEPH_VERSION}" =~ ^(luminous|mimic)$ ]]; then - tune_memory $(get_available_ram) + tune_memory "$(get_available_ram)" fi if [[ -n "$OSD_DEVICE" ]]; then @@ -93,7 +95,7 @@ function bootstrap_osd { : "${OSD_COUNT:=1}" for i in $(seq 1 1 "$OSD_COUNT"); do - let OSD_ID="$i"-1 || true + (( OSD_ID="$i"-1 )) || true OSD_PATH="/var/lib/ceph/osd/${CLUSTER}-${OSD_ID}" if [ ! -e "$OSD_PATH"/keyring ]; then @@ -162,6 +164,7 @@ function bootstrap_mds { ####### function bootstrap_rgw { if [[ "$RGW_FRONTEND_TYPE" == "civetweb" ]]; then + # shellcheck disable=SC2153 RGW_FRONTED_OPTIONS="$RGW_FRONTEND_OPTIONS port=$RGW_FRONTEND_IP:$RGW_FRONTEND_PORT" elif [[ "$RGW_FRONTEND_TYPE" == "beast" ]]; then RGW_FRONTED_OPTIONS="$RGW_FRONTEND_OPTIONS endpoint=$RGW_FRONTEND_IP:$RGW_FRONTEND_PORT" diff --git a/travis-builds/validate_demo_cluster.sh b/travis-builds/validate_demo_cluster.sh index 4a77c6035..8476b52e5 100755 --- a/travis-builds/validate_demo_cluster.sh +++ b/travis-builds/validate_demo_cluster.sh @@ -6,26 +6,26 @@ set -xe # FUNCTIONS # ############# function get_cluster_name { - cluster=$(docker exec ceph-demo grep -R fsid /etc/ceph/ | egrep -o '^[^.]*') - DOCKER_COMMAND="docker exec ceph-demo ceph --connect-timeout 3 --cluster $(basename $cluster)" + cluster=$(docker exec ceph-demo grep -R fsid /etc/ceph/ | grep -Eo '^[^.]*') + DOCKER_COMMAND="docker exec ceph-demo ceph --connect-timeout 3 --cluster $(basename "$cluster")" } function wait_for_daemon () { timeout=90 daemon_to_test=$1 while [ $timeout -ne 0 ]; do - if eval $daemon_to_test; then + if eval "$daemon_to_test"; then return 0 fi sleep 1 - let timeout=timeout-1 + (( timeout=timeout-1 )) done return 1 } function get_ceph_version { # shellcheck disable=SC2046 - echo $($DOCKER_COMMAND --version | grep -Eo '[0-9][0-9]\.[0-9]') + $DOCKER_COMMAND --version | grep -Eo '[0-9][0-9]\.[0-9]' } function ceph_status { @@ -75,7 +75,7 @@ function test_demo_mgr { function test_demo_rest_api { key=$($DOCKER_COMMAND restful list-keys | python -c 'import json, sys; print(json.load(sys.stdin)["demo"])') - docker exec ceph-demo curl -s --connect-timeout 1 -u demo:$key -k https://0.0.0.0:8003/server + docker exec ceph-demo curl -s --connect-timeout 1 -u demo:"$key" -k https://0.0.0.0:8003/server # shellcheck disable=SC2046 return $(wait_for_daemon "$DOCKER_COMMAND mgr dump | grep -sq 'restful\": \"https://.*:8003'") } @@ -85,7 +85,7 @@ function test_demo_rest_api { ######## get_cluster_name ceph_status # wait for the cluster to stabilize -ceph_version=$(get_ceph_version) +get_ceph_version test_demo_mon test_demo_osd test_demo_rgw