Skip to content

[improvement](fdb) add a tool which deploys and starts fdb#39803

Merged
gavinchou merged 2 commits intoapache:masterfrom
dataroaring:fdb_tool
Sep 10, 2024
Merged

[improvement](fdb) add a tool which deploys and starts fdb#39803
gavinchou merged 2 commits intoapache:masterfrom
dataroaring:fdb_tool

Conversation

@dataroaring
Copy link
Copy Markdown
Contributor

Proposed changes

Issue Number: close #xxx

@doris-robot
Copy link
Copy Markdown

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@github-actions
Copy link
Copy Markdown
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_ctrl.sh line 5:
ROOT_DIR="$(cd "$(dirname $(readlink -f ${BASH_SOURCE[0]}))" &>/dev/null && pwd)"
                          ^-- SC2046 (warning): Quote this to prevent word splitting.
                                        ^---------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
ROOT_DIR="$(cd "$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" &>/dev/null && pwd)"


In tools/fdb/fdb_ctrl.sh line 7:
if [ -f ${ROOT_DIR}/fdb_vars.sh ]; then
   ^----------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
        ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if [[ -f "${ROOT_DIR}"/fdb_vars.sh ]]; then


In tools/fdb/fdb_ctrl.sh line 8:
    source ${ROOT_DIR}/fdb_vars.sh
           ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    source "${ROOT_DIR}"/fdb_vars.sh


In tools/fdb/fdb_ctrl.sh line 14:
if [ ! -d ${FDB_HOME} ]; then
   ^------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
          ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
if [[ ! -d "${FDB_HOME}" ]]; then


In tools/fdb/fdb_ctrl.sh line 20:
    echo "$FDB_HOME is not an absolute path."
          ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${FDB_HOME} is not an absolute path."


In tools/fdb/fdb_ctrl.sh line 24:
if [ -z ${FDB_CLUSTER_ID} ]; then
   ^----------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
        ^---------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
if [[ -z "${FDB_CLUSTER_ID}" ]]; then


In tools/fdb/fdb_ctrl.sh line 40:
mkdir -p ${LOG_DIR}
         ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
mkdir -p "${LOG_DIR}"


In tools/fdb/fdb_ctrl.sh line 41:
mkdir -p ${FDB_HOME}/conf
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
mkdir -p "${FDB_HOME}"/conf


In tools/fdb/fdb_ctrl.sh line 42:
mkdir -p ${FDB_HOME}/log
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
mkdir -p "${FDB_HOME}"/log


In tools/fdb/fdb_ctrl.sh line 48:
    if lsof -nP -iTCP:${port} -sTCP:LISTEN >/dev/null; then
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if lsof -nP -iTCP:"${port}" -sTCP:LISTEN >/dev/null; then


In tools/fdb/fdb_ctrl.sh line 55:
    if [ -d ${FDB_PKG_DIR} ]; then
       ^-------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ -d "${FDB_PKG_DIR}" ]]; then


In tools/fdb/fdb_ctrl.sh line 63:
    rm -rf ${TMP}
           ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    rm -rf "${TMP}"


In tools/fdb/fdb_ctrl.sh line 64:
    mkdir -p ${TMP}
             ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    mkdir -p "${TMP}"


In tools/fdb/fdb_ctrl.sh line 66:
    wget ${URL}/fdbbackup.x86_64 -O ${TMP}/fdbbackup
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                    ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbbackup.x86_64 -O "${TMP}"/fdbbackup


In tools/fdb/fdb_ctrl.sh line 67:
    wget ${URL}/fdbserver.x86_64 -O ${TMP}/fdbserver
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                    ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbserver.x86_64 -O "${TMP}"/fdbserver


In tools/fdb/fdb_ctrl.sh line 68:
    wget ${URL}/fdbcli.x86_64 -O ${TMP}/fdbcli
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                 ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbcli.x86_64 -O "${TMP}"/fdbcli


In tools/fdb/fdb_ctrl.sh line 69:
    wget ${URL}/fdbmonitor.x86_64 -O ${TMP}/fdbmonitor
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                     ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbmonitor.x86_64 -O "${TMP}"/fdbmonitor


In tools/fdb/fdb_ctrl.sh line 70:
    wget ${URL}/libfdb_c.x86_64.so -O ${TMP}/libfdb_c.x86_64.so
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                      ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/libfdb_c.x86_64.so -O "${TMP}"/libfdb_c.x86_64.so


In tools/fdb/fdb_ctrl.sh line 71:
    chmod +x ${TMP}/fdb*
             ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    chmod +x "${TMP}"/fdb*


In tools/fdb/fdb_ctrl.sh line 73:
    mv ${TMP} ${FDB_PKG_DIR}
       ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.
              ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    mv "${TMP}" "${FDB_PKG_DIR}"


In tools/fdb/fdb_ctrl.sh line 79:
    local num_nodes=$(echo "$FDB_CLUSTER_IPS" | tr ',' '\n' | wc -l)
          ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    local num_nodes=$(echo "${FDB_CLUSTER_IPS}" | tr ',' '\n' | wc -l)


In tools/fdb/fdb_ctrl.sh line 82:
    if [[ $num_nodes -le 2 ]]; then
          ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${num_nodes} -le 2 ]]; then


In tools/fdb/fdb_ctrl.sh line 84:
    elif [[ $num_nodes -le 4 ]]; then
            ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    elif [[ ${num_nodes} -le 4 ]]; then


In tools/fdb/fdb_ctrl.sh line 90:
    echo $FDB_CLUSTER_IPS | cut -d',' -f1-$num_coordinators | tr ',' '\n' | sed "s/$/:$FDB_PORT/" | paste -sd ','
         ^--------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
         ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                          ^---------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                          ^---------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                                      ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${FDB_CLUSTER_IPS}" | cut -d',' -f1-"${num_coordinators}" | tr ',' '\n' | sed "s/$/:${FDB_PORT}/" | paste -sd ','


In tools/fdb/fdb_ctrl.sh line 95:
    local num_nodes=$(echo "$FDB_CLUSTER_IPS" | tr ',' '\n' | wc -l)
          ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    local num_nodes=$(echo "${FDB_CLUSTER_IPS}" | tr ',' '\n' | wc -l)


In tools/fdb/fdb_ctrl.sh line 98:
    if [[ $num_nodes -eq 1 ]]; then
          ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${num_nodes} -eq 1 ]]; then


In tools/fdb/fdb_ctrl.sh line 100:
    elif [[ $num_nodes -le 4 ]]; then
            ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    elif [[ ${num_nodes} -le 4 ]]; then


In tools/fdb/fdb_ctrl.sh line 106:
    echo $fdb_mode
         ^-------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
         ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${fdb_mode}"


In tools/fdb/fdb_ctrl.sh line 111:
    local memory_gb=$1
          ^-------^ SC2034 (warning): memory_gb appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_ctrl.sh line 118:
    IFS=',' read -r -a DATA_DIR_ARRAY <<< "$DATA_DIRS"
                                           ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"


In tools/fdb/fdb_ctrl.sh line 123:
    [[ $STATLESS_PROCESSES -lt $min_processes ]] && STATLESS_PROCESSES=$min_processes
       ^-----------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                               ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                       ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ ${STATLESS_PROCESSES} -lt ${min_processes} ]] && STATLESS_PROCESSES=${min_processes}


In tools/fdb/fdb_ctrl.sh line 127:
    [[ $STORAGE_PROCESSES -lt $data_dir_count ]] && STORAGE_PROCESSES=$data_dir_count
       ^----------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                              ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                      ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ ${STORAGE_PROCESSES} -lt ${data_dir_count} ]] && STORAGE_PROCESSES=${data_dir_count}


In tools/fdb/fdb_ctrl.sh line 132:
    [[ $TRANSACTION_PROCESSES -lt $min_processes ]] && TRANSACTION_PROCESSES=$min_processes
       ^--------------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                  ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                             ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ ${TRANSACTION_PROCESSES} -lt ${min_processes} ]] && TRANSACTION_PROCESSES=${min_processes}


In tools/fdb/fdb_ctrl.sh line 133:
    [[ $TRANSACTION_PROCESSES -lt $data_dir_count ]] && TRANSACTION_PROCESSES=$data_dir_count
       ^--------------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                  ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                              ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ ${TRANSACTION_PROCESSES} -lt ${data_dir_count} ]] && TRANSACTION_PROCESSES=${data_dir_count}


In tools/fdb/fdb_ctrl.sh line 136:
    echo "Stateless Processes: $STATLESS_PROCESSES"
                               ^-----------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "Stateless Processes: ${STATLESS_PROCESSES}"


In tools/fdb/fdb_ctrl.sh line 137:
    echo "Storage Processes: $STORAGE_PROCESSES"
                             ^----------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "Storage Processes: ${STORAGE_PROCESSES}"


In tools/fdb/fdb_ctrl.sh line 138:
    echo "Transaction Processes: $TRANSACTION_PROCESSES"
                                 ^--------------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "Transaction Processes: ${TRANSACTION_PROCESSES}"


In tools/fdb/fdb_ctrl.sh line 144:
    ln -sf ${FDB_PKG_DIR}/fdbserver ${FDB_HOME}/fdbserver
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbserver "${FDB_HOME}"/fdbserver


In tools/fdb/fdb_ctrl.sh line 145:
    ln -sf ${FDB_PKG_DIR}/fdbmonitor ${FDB_HOME}/fdbmonitor
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                     ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbmonitor "${FDB_HOME}"/fdbmonitor


In tools/fdb/fdb_ctrl.sh line 146:
    ln -sf ${FDB_PKG_DIR}/fdbbackup ${FDB_HOME}/backup_agent
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbbackup "${FDB_HOME}"/backup_agent


In tools/fdb/fdb_ctrl.sh line 147:
    ln -sf ${FDB_PKG_DIR}/fdbcli ${FDB_HOME}/fdbcli
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                 ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbcli "${FDB_HOME}"/fdbcli


In tools/fdb/fdb_ctrl.sh line 149:
    CLUSTER_DESC=${FDB_CLUSTER_DESC:-$FDB_CLUSTER_ID}
                                     ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    CLUSTER_DESC=${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}


In tools/fdb/fdb_ctrl.sh line 152:
    IFS=',' read -r -a DATA_DIR_ARRAY <<< "$DATA_DIRS"
                                           ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"


In tools/fdb/fdb_ctrl.sh line 154:
         mkdir -p $DIR || handle_error "Failed to create data directory $DIR"
                  ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
                  ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                        ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
         mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"


In tools/fdb/fdb_ctrl.sh line 159:
    cat >${FDB_HOME}/conf/fdb.cluster <<EOF
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat >"${FDB_HOME}"/conf/fdb.cluster <<EOF


In tools/fdb/fdb_ctrl.sh line 163:
    cat >${FDB_HOME}/conf/fdb.conf <<EOF
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat >"${FDB_HOME}"/conf/fdb.conf <<EOF


In tools/fdb/fdb_ctrl.sh line 187:
    calculate_process_numbers $MEMORY_LIMIT_GB $CPU_CORES_LIMIT
                              ^--------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                              ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                               ^--------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                               ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}"


In tools/fdb/fdb_ctrl.sh line 192:
        echo "[fdbserver.$PORT]
                         ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        echo "[fdbserver.${PORT}]


In tools/fdb/fdb_ctrl.sh line 193:
class = stateless" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                             ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
class = stateless" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 203:
        echo "[fdbserver.$PORT]
                         ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        echo "[fdbserver.${PORT}]


In tools/fdb/fdb_ctrl.sh line 205:
datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                           ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                        ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 214:
        echo "[fdbserver.$PORT]
                         ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        echo "[fdbserver.${PORT}]


In tools/fdb/fdb_ctrl.sh line 216:
datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                           ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                        ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 221:
logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
logdir = ${LOG_DIR}" | tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 227:
    if [ ! -f ${FDB_HOME}/fdbmonitor ]; then
       ^-----------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ ! -f "${FDB_HOME}"/fdbmonitor ]]; then


In tools/fdb/fdb_ctrl.sh line 232:
    ensure_port_is_listenable "fdbserver" ${FDB_PORT}
                                          ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    ensure_port_is_listenable "fdbserver" "${FDB_PORT}"


In tools/fdb/fdb_ctrl.sh line 235:
    ${FDB_HOME}/fdbmonitor \
    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    "${FDB_HOME}"/fdbmonitor \


In tools/fdb/fdb_ctrl.sh line 236:
        --conffile ${FDB_HOME}/conf/fdb.conf \
                   ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        --conffile "${FDB_HOME}"/conf/fdb.conf \


In tools/fdb/fdb_ctrl.sh line 237:
        --lockfile ${FDB_HOME}/fdbmonitor.pid \
                   ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        --lockfile "${FDB_HOME}"/fdbmonitor.pid \


In tools/fdb/fdb_ctrl.sh line 242:
    if [ -f ${FDB_HOME}/fdbmonitor.pid ]; then
       ^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ -f "${FDB_HOME}"/fdbmonitor.pid ]]; then


In tools/fdb/fdb_ctrl.sh line 243:
        local fdb_pid=$(cat ${FDB_HOME}/fdbmonitor.pid)
              ^-----^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        local fdb_pid=$(cat "${FDB_HOME}"/fdbmonitor.pid)


In tools/fdb/fdb_ctrl.sh line 244:
        if ps -p ${fdb_pid} >/dev/null; then
                 ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        if ps -p "${fdb_pid}" >/dev/null; then


In tools/fdb/fdb_ctrl.sh line 246:
            kill -9 ${fdb_pid}
                    ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
            kill -9 "${fdb_pid}"


In tools/fdb/fdb_ctrl.sh line 252:
    if [ -f ${FDB_HOME}/fdbmonitor.pid ]; then
       ^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ -f "${FDB_HOME}"/fdbmonitor.pid ]]; then


In tools/fdb/fdb_ctrl.sh line 253:
        local fdb_pid=$(cat ${FDB_HOME}/fdbmonitor.pid)
              ^-----^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        local fdb_pid=$(cat "${FDB_HOME}"/fdbmonitor.pid)


In tools/fdb/fdb_ctrl.sh line 254:
        if ps -p ${fdb_pid} >/dev/null; then
                 ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        if ps -p "${fdb_pid}" >/dev/null; then


In tools/fdb/fdb_ctrl.sh line 261:
    rm -rf ${FDB_HOME}/*
           ^-----------^ SC2115 (warning): Use "${var:?}" to ensure this never expands to /* .
           ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    rm -rf "${FDB_HOME}"/*


In tools/fdb/fdb_ctrl.sh line 269:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 278:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 282:
    if [[ $init =~ ^(all|fdb)$ ]]; then
          ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${init} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 284:
        local fdb_mode=$(get_fdb_mode)
              ^------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In tools/fdb/fdb_ctrl.sh line 285:
        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster \
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        "${FDB_HOME}"/fdbcli -C "${FDB_HOME}"/conf/fdb.cluster \


In tools/fdb/fdb_ctrl.sh line 293:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 302:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 309:
    ps -ef | grep ${FDB_CLUSTER_DESC} | grep -v grep
    ^----^ SC2009 (info): Consider using pgrep instead of grepping ps output.
                  ^-----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    ps -ef | grep "${FDB_CLUSTER_DESC}" | grep -v grep


In tools/fdb/fdb_ctrl.sh line 330:
    echo "Unknown cmd: ${cmd}\n"
         ^---------------------^ SC2028 (info): echo may not expand escape sequences. Use printf.


In tools/fdb/fdb_ctrl.sh line 334:
if [[ $# < 1 ]]; then
         ^-- SC2071 (error): < is for string comparisons. Use -lt instead.


In tools/fdb/fdb_ctrl.sh line 347:
case $cmd in
     ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
case ${cmd} in


In tools/fdb/fdb_ctrl.sh line 349:
        deploy "$job" $skip_pkg $skip_config
                ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                      ^-------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                      ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                ^----------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                ^----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        deploy "${job}" "${skip_pkg}" "${skip_config}"


In tools/fdb/fdb_ctrl.sh line 352:
        start "$job" "${init}"
               ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        start "${job}" "${init}"


In tools/fdb/fdb_ctrl.sh line 355:
        stop "$job"
              ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        stop "${job}"


In tools/fdb/fdb_ctrl.sh line 358:
        clean "$job"
               ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        clean "${job}"


In tools/fdb/fdb_ctrl.sh line 361:
        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                                           ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements.

Did you mean: 
        "${FDB_HOME}"/fdbcli -C "${FDB_HOME}"/conf/fdb.cluster $@


In tools/fdb/fdb_ctrl.sh line 365:
        mysql -uroot -h127.0.0.1 -P$(fe_query_port 0)
                                   ^----------------^ SC2046 (warning): Quote this to prevent word splitting.


In tools/fdb/fdb_ctrl.sh line 372:
        run_regression $skip_config $@
                       ^----------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                       ^----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                    ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements.

Did you mean: 
        run_regression "${skip_config}" $@


In tools/fdb/fdb_ctrl.sh line 378:
        unknown_cmd $cmd
                    ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
                    ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        unknown_cmd "${cmd}"


In tools/fdb/fdb_vars.sh line 1:
# Description: Variables for FoundationDB
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In tools/fdb/fdb_vars.sh line 5:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 9:
DATA_DIRS="/var/lib/foundationdb/data1,/var/lib/foundationdb/data2,/var/lib/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 12:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 21:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 24:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 27:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 30:
FDB_CLUSTER_ID="SAQESzbh"
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 33:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 36:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 38:
USER=`whoami`
     ^------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
USER=$(whoami)

For more information:
  https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ...
  https://www.shellcheck.net/wiki/SC2071 -- < is for string comparisons. Use ...
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctrl.sh.orig
+++ tools/fdb/fdb_ctrl.sh
@@ -115,7 +115,7 @@
     local data_dir_count
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "$DATA_DIRS"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"$DATA_DIRS"
     data_dir_count=${#DATA_DIR_ARRAY[@]}
 
     # Stateless processes (at least 1, up to 1/4 of CPU cores)
@@ -125,13 +125,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     STORAGE_PROCESSES=$((cpu_cores / 4))
     [[ $STORAGE_PROCESSES -lt $data_dir_count ]] && STORAGE_PROCESSES=$data_dir_count
-    STORAGE_PROCESSES=$(( (STORAGE_PROCESSES / data_dir_count) * data_dir_count ))
+    STORAGE_PROCESSES=$(((STORAGE_PROCESSES / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     TRANSACTION_PROCESSES=$((cpu_cores / 8))
     [[ $TRANSACTION_PROCESSES -lt $min_processes ]] && TRANSACTION_PROCESSES=$min_processes
     [[ $TRANSACTION_PROCESSES -lt $data_dir_count ]] && TRANSACTION_PROCESSES=$data_dir_count
-    TRANSACTION_PROCESSES=$(( (TRANSACTION_PROCESSES / data_dir_count) * data_dir_count ))
+    TRANSACTION_PROCESSES=$(((TRANSACTION_PROCESSES / data_dir_count) * data_dir_count))
 
     echo "Stateless Processes: $STATLESS_PROCESSES"
     echo "Storage Processes: $STORAGE_PROCESSES"
@@ -149,9 +149,9 @@
     CLUSTER_DESC=${FDB_CLUSTER_DESC:-$FDB_CLUSTER_ID}
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "$DATA_DIRS"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"$DATA_DIRS"
     for DIR in "${DATA_DIR_ARRAY[@]}"; do
-         mkdir -p $DIR || handle_error "Failed to create data directory $DIR"
+        mkdir -p $DIR || handle_error "Failed to create data directory $DIR"
     done
 
     echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
@@ -190,7 +190,7 @@
     for ((i = 0; i < STATLESS_PROCESSES; i++)); do
         PORT=$((FDB_PORT + i))
         echo "[fdbserver.$PORT]
-class = stateless" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+class = stateless" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + STATLESS_PROCESSES))
@@ -202,7 +202,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.$PORT]
 class = storage
-datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + STORAGE_PROCESSES))
@@ -213,12 +213,12 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.$PORT]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     echo "[backup_agent]
 command = ${FDB_HOME}/backup_agent
-logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
 
     echo "Deploy FDB to: ${FDB_HOME}"
 }
@@ -345,37 +345,36 @@
 skip_config="false"
 
 case $cmd in
-    deploy)
-        deploy "$job" $skip_pkg $skip_config
-        ;;
-    start)
-        start "$job" "${init}"
-        ;;
-    stop)
-        stop "$job"
-        ;;
-    clean)
-        clean "$job"
-        ;;
-    fdbcli)
-        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
-        ;;
-    mysql)
-        is_fe_connectable
-        mysql -uroot -h127.0.0.1 -P$(fe_query_port 0)
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    run)
-        is_fe_connectable
-        run_regression $skip_config $@
-        ;;
-    status)
-        status
-        ;;
-    *)
-        unknown_cmd $cmd
-        ;;
+deploy)
+    deploy "$job" $skip_pkg $skip_config
+    ;;
+start)
+    start "$job" "${init}"
+    ;;
+stop)
+    stop "$job"
+    ;;
+clean)
+    clean "$job"
+    ;;
+fdbcli)
+    ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
+    ;;
+mysql)
+    is_fe_connectable
+    mysql -uroot -h127.0.0.1 -P$(fe_query_port 0)
+    ;;
+config)
+    generate_regression_config true
+    ;;
+run)
+    is_fe_connectable
+    run_regression $skip_config $@
+    ;;
+status)
+    status
+    ;;
+*)
+    unknown_cmd $cmd
+    ;;
 esac
-
--- tools/fdb/fdb_vars.sh.orig
+++ tools/fdb/fdb_vars.sh
@@ -35,4 +35,4 @@
 # Define the FoundationDB home directory
 FDB_HOME="/fdbhome"
 
-USER=`whoami`
+USER=$(whoami)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


Copy link
Copy Markdown
Contributor

@yagagagaga yagagagaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script is very convenient.

@github-actions
Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Aug 29, 2024
@github-actions
Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

Copy link
Copy Markdown
Contributor

@gavinchou gavinchou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too large binary

@github-actions github-actions bot removed the approved Indicates a PR has been approved by one committer. label Aug 29, 2024
@github-actions
Copy link
Copy Markdown
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_ctrl.sh line 29:
ROOT_DIR="$(cd "$(dirname $(readlink -f ${BASH_SOURCE[0]}))" &>/dev/null && pwd)"
                          ^-- SC2046 (warning): Quote this to prevent word splitting.
                                        ^---------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
ROOT_DIR="$(cd "$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" &>/dev/null && pwd)"


In tools/fdb/fdb_ctrl.sh line 31:
if [ -f ${ROOT_DIR}/fdb_vars.sh ]; then
   ^----------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
        ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if [[ -f "${ROOT_DIR}"/fdb_vars.sh ]]; then


In tools/fdb/fdb_ctrl.sh line 32:
    source ${ROOT_DIR}/fdb_vars.sh
           ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    source "${ROOT_DIR}"/fdb_vars.sh


In tools/fdb/fdb_ctrl.sh line 38:
if [ ! -d ${FDB_HOME} ]; then
   ^------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
          ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
if [[ ! -d "${FDB_HOME}" ]]; then


In tools/fdb/fdb_ctrl.sh line 44:
    echo "$FDB_HOME is not an absolute path."
          ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${FDB_HOME} is not an absolute path."


In tools/fdb/fdb_ctrl.sh line 48:
if [ -z ${FDB_CLUSTER_ID} ]; then
   ^----------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
        ^---------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
if [[ -z "${FDB_CLUSTER_ID}" ]]; then


In tools/fdb/fdb_ctrl.sh line 64:
mkdir -p ${LOG_DIR}
         ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
mkdir -p "${LOG_DIR}"


In tools/fdb/fdb_ctrl.sh line 65:
mkdir -p ${FDB_HOME}/conf
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
mkdir -p "${FDB_HOME}"/conf


In tools/fdb/fdb_ctrl.sh line 66:
mkdir -p ${FDB_HOME}/log
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
mkdir -p "${FDB_HOME}"/log


In tools/fdb/fdb_ctrl.sh line 72:
    if lsof -nP -iTCP:${port} -sTCP:LISTEN >/dev/null; then
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if lsof -nP -iTCP:"${port}" -sTCP:LISTEN >/dev/null; then


In tools/fdb/fdb_ctrl.sh line 79:
    if [ -d ${FDB_PKG_DIR} ]; then
       ^-------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ -d "${FDB_PKG_DIR}" ]]; then


In tools/fdb/fdb_ctrl.sh line 87:
    rm -rf ${TMP}
           ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    rm -rf "${TMP}"


In tools/fdb/fdb_ctrl.sh line 88:
    mkdir -p ${TMP}
             ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    mkdir -p "${TMP}"


In tools/fdb/fdb_ctrl.sh line 90:
    wget ${URL}/fdbbackup.x86_64 -O ${TMP}/fdbbackup
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                    ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbbackup.x86_64 -O "${TMP}"/fdbbackup


In tools/fdb/fdb_ctrl.sh line 91:
    wget ${URL}/fdbserver.x86_64 -O ${TMP}/fdbserver
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                    ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbserver.x86_64 -O "${TMP}"/fdbserver


In tools/fdb/fdb_ctrl.sh line 92:
    wget ${URL}/fdbcli.x86_64 -O ${TMP}/fdbcli
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                 ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbcli.x86_64 -O "${TMP}"/fdbcli


In tools/fdb/fdb_ctrl.sh line 93:
    wget ${URL}/fdbmonitor.x86_64 -O ${TMP}/fdbmonitor
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                     ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbmonitor.x86_64 -O "${TMP}"/fdbmonitor


In tools/fdb/fdb_ctrl.sh line 94:
    wget ${URL}/libfdb_c.x86_64.so -O ${TMP}/libfdb_c.x86_64.so
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                      ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/libfdb_c.x86_64.so -O "${TMP}"/libfdb_c.x86_64.so


In tools/fdb/fdb_ctrl.sh line 95:
    chmod +x ${TMP}/fdb*
             ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    chmod +x "${TMP}"/fdb*


In tools/fdb/fdb_ctrl.sh line 97:
    mv ${TMP} ${FDB_PKG_DIR}
       ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.
              ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    mv "${TMP}" "${FDB_PKG_DIR}"


In tools/fdb/fdb_ctrl.sh line 103:
    local num_nodes=$(echo "$FDB_CLUSTER_IPS" | tr ',' '\n' | wc -l)
          ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    local num_nodes=$(echo "${FDB_CLUSTER_IPS}" | tr ',' '\n' | wc -l)


In tools/fdb/fdb_ctrl.sh line 106:
    if [[ $num_nodes -le 2 ]]; then
          ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${num_nodes} -le 2 ]]; then


In tools/fdb/fdb_ctrl.sh line 108:
    elif [[ $num_nodes -le 4 ]]; then
            ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    elif [[ ${num_nodes} -le 4 ]]; then


In tools/fdb/fdb_ctrl.sh line 114:
    echo $FDB_CLUSTER_IPS | cut -d',' -f1-$num_coordinators | tr ',' '\n' | sed "s/$/:$FDB_PORT/" | paste -sd ','
         ^--------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
         ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                          ^---------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                          ^---------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                                      ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${FDB_CLUSTER_IPS}" | cut -d',' -f1-"${num_coordinators}" | tr ',' '\n' | sed "s/$/:${FDB_PORT}/" | paste -sd ','


In tools/fdb/fdb_ctrl.sh line 119:
    local num_nodes=$(echo "$FDB_CLUSTER_IPS" | tr ',' '\n' | wc -l)
          ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    local num_nodes=$(echo "${FDB_CLUSTER_IPS}" | tr ',' '\n' | wc -l)


In tools/fdb/fdb_ctrl.sh line 122:
    if [[ $num_nodes -eq 1 ]]; then
          ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${num_nodes} -eq 1 ]]; then


In tools/fdb/fdb_ctrl.sh line 124:
    elif [[ $num_nodes -le 4 ]]; then
            ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    elif [[ ${num_nodes} -le 4 ]]; then


In tools/fdb/fdb_ctrl.sh line 130:
    echo $fdb_mode
         ^-------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
         ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${fdb_mode}"


In tools/fdb/fdb_ctrl.sh line 135:
    local memory_gb=$1
          ^-------^ SC2034 (warning): memory_gb appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_ctrl.sh line 142:
    IFS=',' read -r -a DATA_DIR_ARRAY <<< "$DATA_DIRS"
                                           ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"


In tools/fdb/fdb_ctrl.sh line 147:
    [[ $STATLESS_PROCESSES -lt $min_processes ]] && STATLESS_PROCESSES=$min_processes
       ^-----------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                               ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                       ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ ${STATLESS_PROCESSES} -lt ${min_processes} ]] && STATLESS_PROCESSES=${min_processes}


In tools/fdb/fdb_ctrl.sh line 151:
    [[ $STORAGE_PROCESSES -lt $data_dir_count ]] && STORAGE_PROCESSES=$data_dir_count
       ^----------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                              ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                      ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ ${STORAGE_PROCESSES} -lt ${data_dir_count} ]] && STORAGE_PROCESSES=${data_dir_count}


In tools/fdb/fdb_ctrl.sh line 156:
    [[ $TRANSACTION_PROCESSES -lt $min_processes ]] && TRANSACTION_PROCESSES=$min_processes
       ^--------------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                  ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                             ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ ${TRANSACTION_PROCESSES} -lt ${min_processes} ]] && TRANSACTION_PROCESSES=${min_processes}


In tools/fdb/fdb_ctrl.sh line 157:
    [[ $TRANSACTION_PROCESSES -lt $data_dir_count ]] && TRANSACTION_PROCESSES=$data_dir_count
       ^--------------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                  ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                              ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ ${TRANSACTION_PROCESSES} -lt ${data_dir_count} ]] && TRANSACTION_PROCESSES=${data_dir_count}


In tools/fdb/fdb_ctrl.sh line 160:
    echo "Stateless Processes: $STATLESS_PROCESSES"
                               ^-----------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "Stateless Processes: ${STATLESS_PROCESSES}"


In tools/fdb/fdb_ctrl.sh line 161:
    echo "Storage Processes: $STORAGE_PROCESSES"
                             ^----------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "Storage Processes: ${STORAGE_PROCESSES}"


In tools/fdb/fdb_ctrl.sh line 162:
    echo "Transaction Processes: $TRANSACTION_PROCESSES"
                                 ^--------------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "Transaction Processes: ${TRANSACTION_PROCESSES}"


In tools/fdb/fdb_ctrl.sh line 168:
    ln -sf ${FDB_PKG_DIR}/fdbserver ${FDB_HOME}/fdbserver
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbserver "${FDB_HOME}"/fdbserver


In tools/fdb/fdb_ctrl.sh line 169:
    ln -sf ${FDB_PKG_DIR}/fdbmonitor ${FDB_HOME}/fdbmonitor
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                     ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbmonitor "${FDB_HOME}"/fdbmonitor


In tools/fdb/fdb_ctrl.sh line 170:
    ln -sf ${FDB_PKG_DIR}/fdbbackup ${FDB_HOME}/backup_agent
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbbackup "${FDB_HOME}"/backup_agent


In tools/fdb/fdb_ctrl.sh line 171:
    ln -sf ${FDB_PKG_DIR}/fdbcli ${FDB_HOME}/fdbcli
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                 ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbcli "${FDB_HOME}"/fdbcli


In tools/fdb/fdb_ctrl.sh line 173:
    CLUSTER_DESC=${FDB_CLUSTER_DESC:-$FDB_CLUSTER_ID}
                                     ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    CLUSTER_DESC=${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}


In tools/fdb/fdb_ctrl.sh line 176:
    IFS=',' read -r -a DATA_DIR_ARRAY <<< "$DATA_DIRS"
                                           ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"


In tools/fdb/fdb_ctrl.sh line 178:
         mkdir -p $DIR || handle_error "Failed to create data directory $DIR"
                  ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
                  ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                        ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
         mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"


In tools/fdb/fdb_ctrl.sh line 183:
    cat >${FDB_HOME}/conf/fdb.cluster <<EOF
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat >"${FDB_HOME}"/conf/fdb.cluster <<EOF


In tools/fdb/fdb_ctrl.sh line 187:
    cat >${FDB_HOME}/conf/fdb.conf <<EOF
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat >"${FDB_HOME}"/conf/fdb.conf <<EOF


In tools/fdb/fdb_ctrl.sh line 211:
    calculate_process_numbers $MEMORY_LIMIT_GB $CPU_CORES_LIMIT
                              ^--------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                              ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                               ^--------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                               ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}"


In tools/fdb/fdb_ctrl.sh line 216:
        echo "[fdbserver.$PORT]
                         ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        echo "[fdbserver.${PORT}]


In tools/fdb/fdb_ctrl.sh line 217:
class = stateless" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                             ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
class = stateless" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 227:
        echo "[fdbserver.$PORT]
                         ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        echo "[fdbserver.${PORT}]


In tools/fdb/fdb_ctrl.sh line 229:
datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                           ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                        ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 238:
        echo "[fdbserver.$PORT]
                         ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        echo "[fdbserver.${PORT}]


In tools/fdb/fdb_ctrl.sh line 240:
datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                           ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                        ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 245:
logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
logdir = ${LOG_DIR}" | tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 251:
    if [ ! -f ${FDB_HOME}/fdbmonitor ]; then
       ^-----------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ ! -f "${FDB_HOME}"/fdbmonitor ]]; then


In tools/fdb/fdb_ctrl.sh line 256:
    ensure_port_is_listenable "fdbserver" ${FDB_PORT}
                                          ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    ensure_port_is_listenable "fdbserver" "${FDB_PORT}"


In tools/fdb/fdb_ctrl.sh line 259:
    ${FDB_HOME}/fdbmonitor \
    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    "${FDB_HOME}"/fdbmonitor \


In tools/fdb/fdb_ctrl.sh line 260:
        --conffile ${FDB_HOME}/conf/fdb.conf \
                   ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        --conffile "${FDB_HOME}"/conf/fdb.conf \


In tools/fdb/fdb_ctrl.sh line 261:
        --lockfile ${FDB_HOME}/fdbmonitor.pid \
                   ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        --lockfile "${FDB_HOME}"/fdbmonitor.pid \


In tools/fdb/fdb_ctrl.sh line 266:
    if [ -f ${FDB_HOME}/fdbmonitor.pid ]; then
       ^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ -f "${FDB_HOME}"/fdbmonitor.pid ]]; then


In tools/fdb/fdb_ctrl.sh line 267:
        local fdb_pid=$(cat ${FDB_HOME}/fdbmonitor.pid)
              ^-----^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        local fdb_pid=$(cat "${FDB_HOME}"/fdbmonitor.pid)


In tools/fdb/fdb_ctrl.sh line 268:
        if ps -p ${fdb_pid} >/dev/null; then
                 ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        if ps -p "${fdb_pid}" >/dev/null; then


In tools/fdb/fdb_ctrl.sh line 270:
            kill -9 ${fdb_pid}
                    ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
            kill -9 "${fdb_pid}"


In tools/fdb/fdb_ctrl.sh line 276:
    if [ -f ${FDB_HOME}/fdbmonitor.pid ]; then
       ^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ -f "${FDB_HOME}"/fdbmonitor.pid ]]; then


In tools/fdb/fdb_ctrl.sh line 277:
        local fdb_pid=$(cat ${FDB_HOME}/fdbmonitor.pid)
              ^-----^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        local fdb_pid=$(cat "${FDB_HOME}"/fdbmonitor.pid)


In tools/fdb/fdb_ctrl.sh line 278:
        if ps -p ${fdb_pid} >/dev/null; then
                 ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        if ps -p "${fdb_pid}" >/dev/null; then


In tools/fdb/fdb_ctrl.sh line 285:
    rm -rf ${FDB_HOME}/*
           ^-----------^ SC2115 (warning): Use "${var:?}" to ensure this never expands to /* .
           ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    rm -rf "${FDB_HOME}"/*


In tools/fdb/fdb_ctrl.sh line 293:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 302:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 306:
    if [[ $init =~ ^(all|fdb)$ ]]; then
          ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${init} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 308:
        local fdb_mode=$(get_fdb_mode)
              ^------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In tools/fdb/fdb_ctrl.sh line 309:
        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster \
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        "${FDB_HOME}"/fdbcli -C "${FDB_HOME}"/conf/fdb.cluster \


In tools/fdb/fdb_ctrl.sh line 314:
    cat ${FDB_HOME}/conf/fdb.cluster
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat "${FDB_HOME}"/conf/fdb.cluster


In tools/fdb/fdb_ctrl.sh line 320:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 329:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 336:
    ps -ef | grep ${FDB_CLUSTER_DESC} | grep -v grep
    ^----^ SC2009 (info): Consider using pgrep instead of grepping ps output.
                  ^-----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    ps -ef | grep "${FDB_CLUSTER_DESC}" | grep -v grep


In tools/fdb/fdb_ctrl.sh line 357:
    echo "Unknown cmd: ${cmd}\n"
         ^---------------------^ SC2028 (info): echo may not expand escape sequences. Use printf.


In tools/fdb/fdb_ctrl.sh line 361:
if [[ $# < 1 ]]; then
         ^-- SC2071 (error): < is for string comparisons. Use -lt instead.


In tools/fdb/fdb_ctrl.sh line 374:
case $cmd in
     ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
case ${cmd} in


In tools/fdb/fdb_ctrl.sh line 376:
        deploy "$job" $skip_pkg $skip_config
                ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                      ^-------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                      ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                ^----------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                ^----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        deploy "${job}" "${skip_pkg}" "${skip_config}"


In tools/fdb/fdb_ctrl.sh line 379:
        start "$job" "${init}"
               ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        start "${job}" "${init}"


In tools/fdb/fdb_ctrl.sh line 382:
        stop "$job"
              ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        stop "${job}"


In tools/fdb/fdb_ctrl.sh line 385:
        clean "$job"
               ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        clean "${job}"


In tools/fdb/fdb_ctrl.sh line 388:
        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                                           ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements.

Did you mean: 
        "${FDB_HOME}"/fdbcli -C "${FDB_HOME}"/conf/fdb.cluster $@


In tools/fdb/fdb_ctrl.sh line 394:
        unknown_cmd $cmd
                    ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
                    ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        unknown_cmd "${cmd}"


In tools/fdb/fdb_vars.sh line 1:
# Licensed to the Apache Software Foundation (ASF) under one
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In tools/fdb/fdb_vars.sh line 25:
DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 33:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 38:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 42:
FDB_CLUSTER_ID="SAQESzbh"
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 45:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 50:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 53:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 58:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 61:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 64:
USER=`whoami`
     ^------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
USER=$(whoami)

For more information:
  https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ...
  https://www.shellcheck.net/wiki/SC2071 -- < is for string comparisons. Use ...
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctrl.sh.orig
+++ tools/fdb/fdb_ctrl.sh
@@ -139,7 +139,7 @@
     local data_dir_count
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "$DATA_DIRS"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"$DATA_DIRS"
     data_dir_count=${#DATA_DIR_ARRAY[@]}
 
     # Stateless processes (at least 1, up to 1/4 of CPU cores)
@@ -149,13 +149,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     STORAGE_PROCESSES=$((cpu_cores / 4))
     [[ $STORAGE_PROCESSES -lt $data_dir_count ]] && STORAGE_PROCESSES=$data_dir_count
-    STORAGE_PROCESSES=$(( (STORAGE_PROCESSES / data_dir_count) * data_dir_count ))
+    STORAGE_PROCESSES=$(((STORAGE_PROCESSES / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     TRANSACTION_PROCESSES=$((cpu_cores / 8))
     [[ $TRANSACTION_PROCESSES -lt $min_processes ]] && TRANSACTION_PROCESSES=$min_processes
     [[ $TRANSACTION_PROCESSES -lt $data_dir_count ]] && TRANSACTION_PROCESSES=$data_dir_count
-    TRANSACTION_PROCESSES=$(( (TRANSACTION_PROCESSES / data_dir_count) * data_dir_count ))
+    TRANSACTION_PROCESSES=$(((TRANSACTION_PROCESSES / data_dir_count) * data_dir_count))
 
     echo "Stateless Processes: $STATLESS_PROCESSES"
     echo "Storage Processes: $STORAGE_PROCESSES"
@@ -173,9 +173,9 @@
     CLUSTER_DESC=${FDB_CLUSTER_DESC:-$FDB_CLUSTER_ID}
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "$DATA_DIRS"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"$DATA_DIRS"
     for DIR in "${DATA_DIR_ARRAY[@]}"; do
-         mkdir -p $DIR || handle_error "Failed to create data directory $DIR"
+        mkdir -p $DIR || handle_error "Failed to create data directory $DIR"
     done
 
     echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
@@ -214,7 +214,7 @@
     for ((i = 0; i < STATLESS_PROCESSES; i++)); do
         PORT=$((FDB_PORT + i))
         echo "[fdbserver.$PORT]
-class = stateless" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+class = stateless" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + STATLESS_PROCESSES))
@@ -226,7 +226,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.$PORT]
 class = storage
-datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + STORAGE_PROCESSES))
@@ -237,12 +237,12 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.$PORT]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     echo "[backup_agent]
 command = ${FDB_HOME}/backup_agent
-logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
 
     echo "Deploy FDB to: ${FDB_HOME}"
 }
@@ -372,26 +372,25 @@
 skip_config="false"
 
 case $cmd in
-    deploy)
-        deploy "$job" $skip_pkg $skip_config
-        ;;
-    start)
-        start "$job" "${init}"
-        ;;
-    stop)
-        stop "$job"
-        ;;
-    clean)
-        clean "$job"
-        ;;
-    fdbcli)
-        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    *)
-        unknown_cmd $cmd
-        ;;
+deploy)
+    deploy "$job" $skip_pkg $skip_config
+    ;;
+start)
+    start "$job" "${init}"
+    ;;
+stop)
+    stop "$job"
+    ;;
+clean)
+    clean "$job"
+    ;;
+fdbcli)
+    ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
+    ;;
+config)
+    generate_regression_config true
+    ;;
+*)
+    unknown_cmd $cmd
+    ;;
 esac
-
--- tools/fdb/fdb_vars.sh.orig
+++ tools/fdb/fdb_vars.sh
@@ -32,7 +32,6 @@
 
 FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
 
-
 # Define the FoundationDB home directory, which contains the fdb binaries and logs.
 # default is /fdbhome and have to be absolute path.
 FDB_HOME="/fdbhome"
@@ -61,4 +60,4 @@
 FDB_VERSION="7.1.38"
 
 # Users who run the fdb processes, default is the current user
-USER=`whoami`
+USER=$(whoami)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Aug 29, 2024
@github-actions
Copy link
Copy Markdown
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_ctrl.sh line 29:
ROOT_DIR="$(cd "$(dirname $(readlink -f ${BASH_SOURCE[0]}))" &>/dev/null && pwd)"
                          ^-- SC2046 (warning): Quote this to prevent word splitting.
                                        ^---------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
ROOT_DIR="$(cd "$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" &>/dev/null && pwd)"


In tools/fdb/fdb_ctrl.sh line 31:
if [ -f ${ROOT_DIR}/fdb_vars.sh ]; then
   ^----------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
        ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if [[ -f "${ROOT_DIR}"/fdb_vars.sh ]]; then


In tools/fdb/fdb_ctrl.sh line 32:
    source ${ROOT_DIR}/fdb_vars.sh
           ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    source "${ROOT_DIR}"/fdb_vars.sh


In tools/fdb/fdb_ctrl.sh line 38:
if [ ! -d ${FDB_HOME} ]; then
   ^------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
          ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
if [[ ! -d "${FDB_HOME}" ]]; then


In tools/fdb/fdb_ctrl.sh line 44:
    echo "$FDB_HOME is not an absolute path."
          ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${FDB_HOME} is not an absolute path."


In tools/fdb/fdb_ctrl.sh line 48:
if [ -z ${FDB_CLUSTER_ID} ]; then
   ^----------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
        ^---------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
if [[ -z "${FDB_CLUSTER_ID}" ]]; then


In tools/fdb/fdb_ctrl.sh line 64:
mkdir -p ${LOG_DIR}
         ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
mkdir -p "${LOG_DIR}"


In tools/fdb/fdb_ctrl.sh line 65:
mkdir -p ${FDB_HOME}/conf
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
mkdir -p "${FDB_HOME}"/conf


In tools/fdb/fdb_ctrl.sh line 66:
mkdir -p ${FDB_HOME}/log
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
mkdir -p "${FDB_HOME}"/log


In tools/fdb/fdb_ctrl.sh line 72:
    if lsof -nP -iTCP:${port} -sTCP:LISTEN >/dev/null; then
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if lsof -nP -iTCP:"${port}" -sTCP:LISTEN >/dev/null; then


In tools/fdb/fdb_ctrl.sh line 79:
    if [ -d ${FDB_PKG_DIR} ]; then
       ^-------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ -d "${FDB_PKG_DIR}" ]]; then


In tools/fdb/fdb_ctrl.sh line 87:
    rm -rf ${TMP}
           ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    rm -rf "${TMP}"


In tools/fdb/fdb_ctrl.sh line 88:
    mkdir -p ${TMP}
             ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    mkdir -p "${TMP}"


In tools/fdb/fdb_ctrl.sh line 90:
    wget ${URL}/fdbbackup.x86_64 -O ${TMP}/fdbbackup
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                    ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbbackup.x86_64 -O "${TMP}"/fdbbackup


In tools/fdb/fdb_ctrl.sh line 91:
    wget ${URL}/fdbserver.x86_64 -O ${TMP}/fdbserver
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                    ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbserver.x86_64 -O "${TMP}"/fdbserver


In tools/fdb/fdb_ctrl.sh line 92:
    wget ${URL}/fdbcli.x86_64 -O ${TMP}/fdbcli
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                 ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbcli.x86_64 -O "${TMP}"/fdbcli


In tools/fdb/fdb_ctrl.sh line 93:
    wget ${URL}/fdbmonitor.x86_64 -O ${TMP}/fdbmonitor
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                     ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbmonitor.x86_64 -O "${TMP}"/fdbmonitor


In tools/fdb/fdb_ctrl.sh line 94:
    wget ${URL}/libfdb_c.x86_64.so -O ${TMP}/libfdb_c.x86_64.so
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                      ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/libfdb_c.x86_64.so -O "${TMP}"/libfdb_c.x86_64.so


In tools/fdb/fdb_ctrl.sh line 95:
    chmod +x ${TMP}/fdb*
             ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    chmod +x "${TMP}"/fdb*


In tools/fdb/fdb_ctrl.sh line 97:
    mv ${TMP} ${FDB_PKG_DIR}
       ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.
              ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    mv "${TMP}" "${FDB_PKG_DIR}"


In tools/fdb/fdb_ctrl.sh line 103:
    local num_nodes=$(echo "$FDB_CLUSTER_IPS" | tr ',' '\n' | wc -l)
          ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    local num_nodes=$(echo "${FDB_CLUSTER_IPS}" | tr ',' '\n' | wc -l)


In tools/fdb/fdb_ctrl.sh line 106:
    if [[ $num_nodes -le 2 ]]; then
          ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${num_nodes} -le 2 ]]; then


In tools/fdb/fdb_ctrl.sh line 108:
    elif [[ $num_nodes -le 4 ]]; then
            ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    elif [[ ${num_nodes} -le 4 ]]; then


In tools/fdb/fdb_ctrl.sh line 114:
    echo $FDB_CLUSTER_IPS | cut -d',' -f1-$num_coordinators | tr ',' '\n' | sed "s/$/:$FDB_PORT/" | paste -sd ','
         ^--------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
         ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                          ^---------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                          ^---------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                                      ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${FDB_CLUSTER_IPS}" | cut -d',' -f1-"${num_coordinators}" | tr ',' '\n' | sed "s/$/:${FDB_PORT}/" | paste -sd ','


In tools/fdb/fdb_ctrl.sh line 119:
    local num_nodes=$(echo "$FDB_CLUSTER_IPS" | tr ',' '\n' | wc -l)
          ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    local num_nodes=$(echo "${FDB_CLUSTER_IPS}" | tr ',' '\n' | wc -l)


In tools/fdb/fdb_ctrl.sh line 122:
    if [[ $num_nodes -eq 1 ]]; then
          ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${num_nodes} -eq 1 ]]; then


In tools/fdb/fdb_ctrl.sh line 124:
    elif [[ $num_nodes -le 4 ]]; then
            ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    elif [[ ${num_nodes} -le 4 ]]; then


In tools/fdb/fdb_ctrl.sh line 130:
    echo $fdb_mode
         ^-------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
         ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${fdb_mode}"


In tools/fdb/fdb_ctrl.sh line 135:
    local memory_gb=$1
          ^-------^ SC2034 (warning): memory_gb appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_ctrl.sh line 142:
    IFS=',' read -r -a DATA_DIR_ARRAY <<< "$DATA_DIRS"
                                           ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"


In tools/fdb/fdb_ctrl.sh line 147:
    [[ $STATLESS_PROCESSES -lt $min_processes ]] && STATLESS_PROCESSES=$min_processes
       ^-----------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                               ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                       ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ ${STATLESS_PROCESSES} -lt ${min_processes} ]] && STATLESS_PROCESSES=${min_processes}


In tools/fdb/fdb_ctrl.sh line 151:
    [[ $STORAGE_PROCESSES -lt $data_dir_count ]] && STORAGE_PROCESSES=$data_dir_count
       ^----------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                              ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                      ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ ${STORAGE_PROCESSES} -lt ${data_dir_count} ]] && STORAGE_PROCESSES=${data_dir_count}


In tools/fdb/fdb_ctrl.sh line 156:
    [[ $TRANSACTION_PROCESSES -lt $min_processes ]] && TRANSACTION_PROCESSES=$min_processes
       ^--------------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                  ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                             ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ ${TRANSACTION_PROCESSES} -lt ${min_processes} ]] && TRANSACTION_PROCESSES=${min_processes}


In tools/fdb/fdb_ctrl.sh line 157:
    [[ $TRANSACTION_PROCESSES -lt $data_dir_count ]] && TRANSACTION_PROCESSES=$data_dir_count
       ^--------------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                  ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                              ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ ${TRANSACTION_PROCESSES} -lt ${data_dir_count} ]] && TRANSACTION_PROCESSES=${data_dir_count}


In tools/fdb/fdb_ctrl.sh line 160:
    echo "Stateless Processes: $STATLESS_PROCESSES"
                               ^-----------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "Stateless Processes: ${STATLESS_PROCESSES}"


In tools/fdb/fdb_ctrl.sh line 161:
    echo "Storage Processes: $STORAGE_PROCESSES"
                             ^----------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "Storage Processes: ${STORAGE_PROCESSES}"


In tools/fdb/fdb_ctrl.sh line 162:
    echo "Transaction Processes: $TRANSACTION_PROCESSES"
                                 ^--------------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "Transaction Processes: ${TRANSACTION_PROCESSES}"


In tools/fdb/fdb_ctrl.sh line 168:
    ln -sf ${FDB_PKG_DIR}/fdbserver ${FDB_HOME}/fdbserver
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbserver "${FDB_HOME}"/fdbserver


In tools/fdb/fdb_ctrl.sh line 169:
    ln -sf ${FDB_PKG_DIR}/fdbmonitor ${FDB_HOME}/fdbmonitor
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                     ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbmonitor "${FDB_HOME}"/fdbmonitor


In tools/fdb/fdb_ctrl.sh line 170:
    ln -sf ${FDB_PKG_DIR}/fdbbackup ${FDB_HOME}/backup_agent
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbbackup "${FDB_HOME}"/backup_agent


In tools/fdb/fdb_ctrl.sh line 171:
    ln -sf ${FDB_PKG_DIR}/fdbcli ${FDB_HOME}/fdbcli
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                 ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbcli "${FDB_HOME}"/fdbcli


In tools/fdb/fdb_ctrl.sh line 173:
    CLUSTER_DESC=${FDB_CLUSTER_DESC:-$FDB_CLUSTER_ID}
                                     ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    CLUSTER_DESC=${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}


In tools/fdb/fdb_ctrl.sh line 176:
    IFS=',' read -r -a DATA_DIR_ARRAY <<< "$DATA_DIRS"
                                           ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"


In tools/fdb/fdb_ctrl.sh line 178:
         mkdir -p $DIR || handle_error "Failed to create data directory $DIR"
                  ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
                  ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                        ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
         mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"


In tools/fdb/fdb_ctrl.sh line 183:
    cat >${FDB_HOME}/conf/fdb.cluster <<EOF
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat >"${FDB_HOME}"/conf/fdb.cluster <<EOF


In tools/fdb/fdb_ctrl.sh line 187:
    cat >${FDB_HOME}/conf/fdb.conf <<EOF
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat >"${FDB_HOME}"/conf/fdb.conf <<EOF


In tools/fdb/fdb_ctrl.sh line 211:
    calculate_process_numbers $MEMORY_LIMIT_GB $CPU_CORES_LIMIT
                              ^--------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                              ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                               ^--------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                               ^--------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}"


In tools/fdb/fdb_ctrl.sh line 216:
        echo "[fdbserver.$PORT]
                         ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        echo "[fdbserver.${PORT}]


In tools/fdb/fdb_ctrl.sh line 217:
class = stateless" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                             ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
class = stateless" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 227:
        echo "[fdbserver.$PORT]
                         ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        echo "[fdbserver.${PORT}]


In tools/fdb/fdb_ctrl.sh line 229:
datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                           ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                        ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 238:
        echo "[fdbserver.$PORT]
                         ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        echo "[fdbserver.${PORT}]


In tools/fdb/fdb_ctrl.sh line 240:
datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                           ^--------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                        ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 245:
logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
logdir = ${LOG_DIR}" | tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 251:
    if [ ! -f ${FDB_HOME}/fdbmonitor ]; then
       ^-----------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ ! -f "${FDB_HOME}"/fdbmonitor ]]; then


In tools/fdb/fdb_ctrl.sh line 256:
    ensure_port_is_listenable "fdbserver" ${FDB_PORT}
                                          ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    ensure_port_is_listenable "fdbserver" "${FDB_PORT}"


In tools/fdb/fdb_ctrl.sh line 259:
    ${FDB_HOME}/fdbmonitor \
    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    "${FDB_HOME}"/fdbmonitor \


In tools/fdb/fdb_ctrl.sh line 260:
        --conffile ${FDB_HOME}/conf/fdb.conf \
                   ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        --conffile "${FDB_HOME}"/conf/fdb.conf \


In tools/fdb/fdb_ctrl.sh line 261:
        --lockfile ${FDB_HOME}/fdbmonitor.pid \
                   ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        --lockfile "${FDB_HOME}"/fdbmonitor.pid \


In tools/fdb/fdb_ctrl.sh line 266:
    if [ -f ${FDB_HOME}/fdbmonitor.pid ]; then
       ^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ -f "${FDB_HOME}"/fdbmonitor.pid ]]; then


In tools/fdb/fdb_ctrl.sh line 267:
        local fdb_pid=$(cat ${FDB_HOME}/fdbmonitor.pid)
              ^-----^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        local fdb_pid=$(cat "${FDB_HOME}"/fdbmonitor.pid)


In tools/fdb/fdb_ctrl.sh line 268:
        if ps -p ${fdb_pid} >/dev/null; then
                 ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        if ps -p "${fdb_pid}" >/dev/null; then


In tools/fdb/fdb_ctrl.sh line 270:
            kill -9 ${fdb_pid}
                    ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
            kill -9 "${fdb_pid}"


In tools/fdb/fdb_ctrl.sh line 276:
    if [ -f ${FDB_HOME}/fdbmonitor.pid ]; then
       ^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ -f "${FDB_HOME}"/fdbmonitor.pid ]]; then


In tools/fdb/fdb_ctrl.sh line 277:
        local fdb_pid=$(cat ${FDB_HOME}/fdbmonitor.pid)
              ^-----^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        local fdb_pid=$(cat "${FDB_HOME}"/fdbmonitor.pid)


In tools/fdb/fdb_ctrl.sh line 278:
        if ps -p ${fdb_pid} >/dev/null; then
                 ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        if ps -p "${fdb_pid}" >/dev/null; then


In tools/fdb/fdb_ctrl.sh line 285:
    rm -rf ${FDB_HOME}/*
           ^-----------^ SC2115 (warning): Use "${var:?}" to ensure this never expands to /* .
           ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    rm -rf "${FDB_HOME}"/*


In tools/fdb/fdb_ctrl.sh line 293:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 302:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 306:
    if [[ $init =~ ^(all|fdb)$ ]]; then
          ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${init} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 308:
        local fdb_mode=$(get_fdb_mode)
              ^------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In tools/fdb/fdb_ctrl.sh line 309:
        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster \
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        "${FDB_HOME}"/fdbcli -C "${FDB_HOME}"/conf/fdb.cluster \


In tools/fdb/fdb_ctrl.sh line 314:
    cat ${FDB_HOME}/conf/fdb.cluster
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat "${FDB_HOME}"/conf/fdb.cluster


In tools/fdb/fdb_ctrl.sh line 320:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 329:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 336:
    ps -ef | grep ${FDB_CLUSTER_DESC} | grep -v grep
    ^----^ SC2009 (info): Consider using pgrep instead of grepping ps output.
                  ^-----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    ps -ef | grep "${FDB_CLUSTER_DESC}" | grep -v grep


In tools/fdb/fdb_ctrl.sh line 357:
    echo "Unknown cmd: ${cmd}\n"
         ^---------------------^ SC2028 (info): echo may not expand escape sequences. Use printf.


In tools/fdb/fdb_ctrl.sh line 361:
if [[ $# < 1 ]]; then
         ^-- SC2071 (error): < is for string comparisons. Use -lt instead.


In tools/fdb/fdb_ctrl.sh line 374:
case $cmd in
     ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
case ${cmd} in


In tools/fdb/fdb_ctrl.sh line 376:
        deploy "$job" $skip_pkg $skip_config
                ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                      ^-------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                      ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                ^----------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                ^----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        deploy "${job}" "${skip_pkg}" "${skip_config}"


In tools/fdb/fdb_ctrl.sh line 379:
        start "$job" "${init}"
               ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        start "${job}" "${init}"


In tools/fdb/fdb_ctrl.sh line 382:
        stop "$job"
              ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        stop "${job}"


In tools/fdb/fdb_ctrl.sh line 385:
        clean "$job"
               ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        clean "${job}"


In tools/fdb/fdb_ctrl.sh line 388:
        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                                           ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements.

Did you mean: 
        "${FDB_HOME}"/fdbcli -C "${FDB_HOME}"/conf/fdb.cluster $@


In tools/fdb/fdb_ctrl.sh line 394:
        unknown_cmd $cmd
                    ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
                    ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        unknown_cmd "${cmd}"


In tools/fdb/fdb_vars.sh line 1:
# Licensed to the Apache Software Foundation (ASF) under one
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In tools/fdb/fdb_vars.sh line 25:
DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 33:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 38:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 42:
FDB_CLUSTER_ID="SAQESzbh"
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 45:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 50:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 53:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 58:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 61:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 64:
USER=`whoami`
     ^------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
USER=$(whoami)

For more information:
  https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ...
  https://www.shellcheck.net/wiki/SC2071 -- < is for string comparisons. Use ...
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctrl.sh.orig
+++ tools/fdb/fdb_ctrl.sh
@@ -139,7 +139,7 @@
     local data_dir_count
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "$DATA_DIRS"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"$DATA_DIRS"
     data_dir_count=${#DATA_DIR_ARRAY[@]}
 
     # Stateless processes (at least 1, up to 1/4 of CPU cores)
@@ -149,13 +149,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     STORAGE_PROCESSES=$((cpu_cores / 4))
     [[ $STORAGE_PROCESSES -lt $data_dir_count ]] && STORAGE_PROCESSES=$data_dir_count
-    STORAGE_PROCESSES=$(( (STORAGE_PROCESSES / data_dir_count) * data_dir_count ))
+    STORAGE_PROCESSES=$(((STORAGE_PROCESSES / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     TRANSACTION_PROCESSES=$((cpu_cores / 8))
     [[ $TRANSACTION_PROCESSES -lt $min_processes ]] && TRANSACTION_PROCESSES=$min_processes
     [[ $TRANSACTION_PROCESSES -lt $data_dir_count ]] && TRANSACTION_PROCESSES=$data_dir_count
-    TRANSACTION_PROCESSES=$(( (TRANSACTION_PROCESSES / data_dir_count) * data_dir_count ))
+    TRANSACTION_PROCESSES=$(((TRANSACTION_PROCESSES / data_dir_count) * data_dir_count))
 
     echo "Stateless Processes: $STATLESS_PROCESSES"
     echo "Storage Processes: $STORAGE_PROCESSES"
@@ -173,9 +173,9 @@
     CLUSTER_DESC=${FDB_CLUSTER_DESC:-$FDB_CLUSTER_ID}
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "$DATA_DIRS"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"$DATA_DIRS"
     for DIR in "${DATA_DIR_ARRAY[@]}"; do
-         mkdir -p $DIR || handle_error "Failed to create data directory $DIR"
+        mkdir -p $DIR || handle_error "Failed to create data directory $DIR"
     done
 
     echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
@@ -214,7 +214,7 @@
     for ((i = 0; i < STATLESS_PROCESSES; i++)); do
         PORT=$((FDB_PORT + i))
         echo "[fdbserver.$PORT]
-class = stateless" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+class = stateless" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + STATLESS_PROCESSES))
@@ -226,7 +226,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.$PORT]
 class = storage
-datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + STORAGE_PROCESSES))
@@ -237,12 +237,12 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.$PORT]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+datadir = ${DATA_DIR_ARRAY[$DIR_INDEX]}/$PORT" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     echo "[backup_agent]
 command = ${FDB_HOME}/backup_agent
-logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
 
     echo "Deploy FDB to: ${FDB_HOME}"
 }
@@ -372,26 +372,25 @@
 skip_config="false"
 
 case $cmd in
-    deploy)
-        deploy "$job" $skip_pkg $skip_config
-        ;;
-    start)
-        start "$job" "${init}"
-        ;;
-    stop)
-        stop "$job"
-        ;;
-    clean)
-        clean "$job"
-        ;;
-    fdbcli)
-        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    *)
-        unknown_cmd $cmd
-        ;;
+deploy)
+    deploy "$job" $skip_pkg $skip_config
+    ;;
+start)
+    start "$job" "${init}"
+    ;;
+stop)
+    stop "$job"
+    ;;
+clean)
+    clean "$job"
+    ;;
+fdbcli)
+    ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
+    ;;
+config)
+    generate_regression_config true
+    ;;
+*)
+    unknown_cmd $cmd
+    ;;
 esac
-
--- tools/fdb/fdb_vars.sh.orig
+++ tools/fdb/fdb_vars.sh
@@ -32,7 +32,6 @@
 
 FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
 
-
 # Define the FoundationDB home directory, which contains the fdb binaries and logs.
 # default is /fdbhome and have to be absolute path.
 FDB_HOME="/fdbhome"
@@ -61,4 +60,4 @@
 FDB_VERSION="7.1.38"
 
 # Users who run the fdb processes, default is the current user
-USER=`whoami`
+USER=$(whoami)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


gavinchou
gavinchou previously approved these changes Aug 29, 2024
@dataroaring
Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions
Copy link
Copy Markdown
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_ctrl.sh line 29:
ROOT_DIR="$(cd "$(dirname $(readlink -f ${BASH_SOURCE[0]}))" &>/dev/null && pwd)"
                          ^-- SC2046 (warning): Quote this to prevent word splitting.
                                        ^---------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
ROOT_DIR="$(cd "$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" &>/dev/null && pwd)"


In tools/fdb/fdb_ctrl.sh line 31:
if [ -f ${ROOT_DIR}/fdb_vars.sh ]; then
   ^----------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
        ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if [[ -f "${ROOT_DIR}"/fdb_vars.sh ]]; then


In tools/fdb/fdb_ctrl.sh line 32:
    source ${ROOT_DIR}/fdb_vars.sh
           ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    source "${ROOT_DIR}"/fdb_vars.sh


In tools/fdb/fdb_ctrl.sh line 38:
if [ ! -d ${FDB_HOME} ]; then
   ^------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
          ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
if [[ ! -d "${FDB_HOME}" ]]; then


In tools/fdb/fdb_ctrl.sh line 44:
    echo "$FDB_HOME is not an absolute path."
          ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${FDB_HOME} is not an absolute path."


In tools/fdb/fdb_ctrl.sh line 48:
if [ -z ${FDB_CLUSTER_ID} ]; then
   ^----------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
        ^---------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
if [[ -z "${FDB_CLUSTER_ID}" ]]; then


In tools/fdb/fdb_ctrl.sh line 64:
mkdir -p ${LOG_DIR}
         ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
mkdir -p "${LOG_DIR}"


In tools/fdb/fdb_ctrl.sh line 65:
mkdir -p ${FDB_HOME}/conf
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
mkdir -p "${FDB_HOME}"/conf


In tools/fdb/fdb_ctrl.sh line 66:
mkdir -p ${FDB_HOME}/log
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
mkdir -p "${FDB_HOME}"/log


In tools/fdb/fdb_ctrl.sh line 72:
    if lsof -nP -iTCP:${port} -sTCP:LISTEN >/dev/null; then
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if lsof -nP -iTCP:"${port}" -sTCP:LISTEN >/dev/null; then


In tools/fdb/fdb_ctrl.sh line 79:
    if [ -d ${FDB_PKG_DIR} ]; then
       ^-------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ -d "${FDB_PKG_DIR}" ]]; then


In tools/fdb/fdb_ctrl.sh line 87:
    rm -rf ${TMP}
           ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    rm -rf "${TMP}"


In tools/fdb/fdb_ctrl.sh line 88:
    mkdir -p ${TMP}
             ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    mkdir -p "${TMP}"


In tools/fdb/fdb_ctrl.sh line 90:
    wget ${URL}/fdbbackup.x86_64 -O ${TMP}/fdbbackup
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                    ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbbackup.x86_64 -O "${TMP}"/fdbbackup


In tools/fdb/fdb_ctrl.sh line 91:
    wget ${URL}/fdbserver.x86_64 -O ${TMP}/fdbserver
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                    ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbserver.x86_64 -O "${TMP}"/fdbserver


In tools/fdb/fdb_ctrl.sh line 92:
    wget ${URL}/fdbcli.x86_64 -O ${TMP}/fdbcli
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                 ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbcli.x86_64 -O "${TMP}"/fdbcli


In tools/fdb/fdb_ctrl.sh line 93:
    wget ${URL}/fdbmonitor.x86_64 -O ${TMP}/fdbmonitor
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                     ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbmonitor.x86_64 -O "${TMP}"/fdbmonitor


In tools/fdb/fdb_ctrl.sh line 94:
    wget ${URL}/libfdb_c.x86_64.so -O ${TMP}/libfdb_c.x86_64.so
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                      ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/libfdb_c.x86_64.so -O "${TMP}"/libfdb_c.x86_64.so


In tools/fdb/fdb_ctrl.sh line 95:
    chmod +x ${TMP}/fdb*
             ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    chmod +x "${TMP}"/fdb*


In tools/fdb/fdb_ctrl.sh line 97:
    mv ${TMP} ${FDB_PKG_DIR}
       ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.
              ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    mv "${TMP}" "${FDB_PKG_DIR}"


In tools/fdb/fdb_ctrl.sh line 103:
    local num_nodes=$(echo "${FDB_CLUSTER_IPS}" | tr ',' '\n' | wc -l)
          ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In tools/fdb/fdb_ctrl.sh line 114:
    echo ${FDB_CLUSTER_IPS} | cut -d',' -f1-${num_coordinators} | tr ',' '\n' | sed "s/$/:${FDB_PORT}/" | paste -sd ','
         ^----------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                            ^-----------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    echo "${FDB_CLUSTER_IPS}" | cut -d',' -f1-"${num_coordinators}" | tr ',' '\n' | sed "s/$/:${FDB_PORT}/" | paste -sd ','


In tools/fdb/fdb_ctrl.sh line 119:
    local num_nodes=$(echo "${FDB_CLUSTER_IPS}" | tr ',' '\n' | wc -l)
          ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In tools/fdb/fdb_ctrl.sh line 130:
    echo ${fdb_mode}
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    echo "${fdb_mode}"


In tools/fdb/fdb_ctrl.sh line 135:
    local memory_gb=$1
          ^-------^ SC2034 (warning): memory_gb appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_ctrl.sh line 168:
    ln -sf ${FDB_PKG_DIR}/fdbserver ${FDB_HOME}/fdbserver
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbserver "${FDB_HOME}"/fdbserver


In tools/fdb/fdb_ctrl.sh line 169:
    ln -sf ${FDB_PKG_DIR}/fdbmonitor ${FDB_HOME}/fdbmonitor
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                     ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbmonitor "${FDB_HOME}"/fdbmonitor


In tools/fdb/fdb_ctrl.sh line 170:
    ln -sf ${FDB_PKG_DIR}/fdbbackup ${FDB_HOME}/backup_agent
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbbackup "${FDB_HOME}"/backup_agent


In tools/fdb/fdb_ctrl.sh line 171:
    ln -sf ${FDB_PKG_DIR}/fdbcli ${FDB_HOME}/fdbcli
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                 ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbcli "${FDB_HOME}"/fdbcli


In tools/fdb/fdb_ctrl.sh line 173:
    CLUSTER_DESC=${FDB_CLUSTER_DESC:-$FDB_CLUSTER_ID}
                                     ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    CLUSTER_DESC=${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}


In tools/fdb/fdb_ctrl.sh line 178:
         mkdir -p ${DIR} || handle_error "Failed to create data directory ${DIR}"
                  ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"


In tools/fdb/fdb_ctrl.sh line 183:
    cat >${FDB_HOME}/conf/fdb.cluster <<EOF
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat >"${FDB_HOME}"/conf/fdb.cluster <<EOF


In tools/fdb/fdb_ctrl.sh line 187:
    cat >${FDB_HOME}/conf/fdb.conf <<EOF
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat >"${FDB_HOME}"/conf/fdb.conf <<EOF


In tools/fdb/fdb_ctrl.sh line 211:
    calculate_process_numbers ${MEMORY_LIMIT_GB} ${CPU_CORES_LIMIT}
                              ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}"


In tools/fdb/fdb_ctrl.sh line 216:
        echo "[fdbserver.$PORT]
                         ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        echo "[fdbserver.${PORT}]


In tools/fdb/fdb_ctrl.sh line 217:
class = stateless" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                             ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
class = stateless" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 229:
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                                                             ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 240:
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                                                             ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 245:
logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
logdir = ${LOG_DIR}" | tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctrl.sh line 251:
    if [ ! -f ${FDB_HOME}/fdbmonitor ]; then
       ^-----------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ ! -f "${FDB_HOME}"/fdbmonitor ]]; then


In tools/fdb/fdb_ctrl.sh line 256:
    ensure_port_is_listenable "fdbserver" ${FDB_PORT}
                                          ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    ensure_port_is_listenable "fdbserver" "${FDB_PORT}"


In tools/fdb/fdb_ctrl.sh line 259:
    ${FDB_HOME}/fdbmonitor \
    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    "${FDB_HOME}"/fdbmonitor \


In tools/fdb/fdb_ctrl.sh line 260:
        --conffile ${FDB_HOME}/conf/fdb.conf \
                   ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        --conffile "${FDB_HOME}"/conf/fdb.conf \


In tools/fdb/fdb_ctrl.sh line 261:
        --lockfile ${FDB_HOME}/fdbmonitor.pid \
                   ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        --lockfile "${FDB_HOME}"/fdbmonitor.pid \


In tools/fdb/fdb_ctrl.sh line 266:
    if [ -f ${FDB_HOME}/fdbmonitor.pid ]; then
       ^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ -f "${FDB_HOME}"/fdbmonitor.pid ]]; then


In tools/fdb/fdb_ctrl.sh line 267:
        local fdb_pid=$(cat ${FDB_HOME}/fdbmonitor.pid)
              ^-----^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        local fdb_pid=$(cat "${FDB_HOME}"/fdbmonitor.pid)


In tools/fdb/fdb_ctrl.sh line 268:
        if ps -p ${fdb_pid} >/dev/null; then
                 ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        if ps -p "${fdb_pid}" >/dev/null; then


In tools/fdb/fdb_ctrl.sh line 270:
            kill -9 ${fdb_pid}
                    ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
            kill -9 "${fdb_pid}"


In tools/fdb/fdb_ctrl.sh line 276:
    if [ -f ${FDB_HOME}/fdbmonitor.pid ]; then
       ^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ -f "${FDB_HOME}"/fdbmonitor.pid ]]; then


In tools/fdb/fdb_ctrl.sh line 277:
        local fdb_pid=$(cat ${FDB_HOME}/fdbmonitor.pid)
              ^-----^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        local fdb_pid=$(cat "${FDB_HOME}"/fdbmonitor.pid)


In tools/fdb/fdb_ctrl.sh line 278:
        if ps -p ${fdb_pid} >/dev/null; then
                 ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        if ps -p "${fdb_pid}" >/dev/null; then


In tools/fdb/fdb_ctrl.sh line 285:
    rm -rf ${FDB_HOME}/*
           ^-----------^ SC2115 (warning): Use "${var:?}" to ensure this never expands to /* .
           ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    rm -rf "${FDB_HOME}"/*


In tools/fdb/fdb_ctrl.sh line 293:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 302:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 306:
    if [[ $init =~ ^(all|fdb)$ ]]; then
          ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${init} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 308:
        local fdb_mode=$(get_fdb_mode)
              ^------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In tools/fdb/fdb_ctrl.sh line 309:
        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster \
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        "${FDB_HOME}"/fdbcli -C "${FDB_HOME}"/conf/fdb.cluster \


In tools/fdb/fdb_ctrl.sh line 314:
    cat ${FDB_HOME}/conf/fdb.cluster
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat "${FDB_HOME}"/conf/fdb.cluster


In tools/fdb/fdb_ctrl.sh line 320:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 329:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctrl.sh line 336:
    ps -ef | grep ${FDB_CLUSTER_DESC} | grep -v grep
    ^----^ SC2009 (info): Consider using pgrep instead of grepping ps output.
                  ^-----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    ps -ef | grep "${FDB_CLUSTER_DESC}" | grep -v grep


In tools/fdb/fdb_ctrl.sh line 357:
    echo "Unknown cmd: ${cmd}\n"
         ^---------------------^ SC2028 (info): echo may not expand escape sequences. Use printf.


In tools/fdb/fdb_ctrl.sh line 361:
if [[ $# < 1 ]]; then
         ^-- SC2071 (error): < is for string comparisons. Use -lt instead.


In tools/fdb/fdb_ctrl.sh line 374:
case $cmd in
     ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
case ${cmd} in


In tools/fdb/fdb_ctrl.sh line 376:
        deploy "${job}" ${skip_pkg} ${skip_config}
                        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                    ^------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        deploy "${job}" "${skip_pkg}" "${skip_config}"


In tools/fdb/fdb_ctrl.sh line 388:
        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                                           ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements.

Did you mean: 
        "${FDB_HOME}"/fdbcli -C "${FDB_HOME}"/conf/fdb.cluster $@


In tools/fdb/fdb_ctrl.sh line 394:
        unknown_cmd ${cmd}
                    ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        unknown_cmd "${cmd}"


In tools/fdb/fdb_vars.sh line 1:
# Licensed to the Apache Software Foundation (ASF) under one
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In tools/fdb/fdb_vars.sh line 25:
DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 33:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 38:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 42:
FDB_CLUSTER_ID="SAQESzbh"
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 45:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 50:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 53:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 58:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 61:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 64:
USER=`whoami`
     ^------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
USER=$(whoami)

For more information:
  https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ...
  https://www.shellcheck.net/wiki/SC2071 -- < is for string comparisons. Use ...
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctrl.sh.orig
+++ tools/fdb/fdb_ctrl.sh
@@ -139,7 +139,7 @@
     local data_dir_count
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     data_dir_count=${#DATA_DIR_ARRAY[@]}
 
     # Stateless processes (at least 1, up to 1/4 of CPU cores)
@@ -149,13 +149,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     STORAGE_PROCESSES=$((cpu_cores / 4))
     [[ ${STORAGE_PROCESSES} -lt ${data_dir_count} ]] && STORAGE_PROCESSES=${data_dir_count}
-    STORAGE_PROCESSES=$(( (STORAGE_PROCESSES / data_dir_count) * data_dir_count ))
+    STORAGE_PROCESSES=$(((STORAGE_PROCESSES / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     TRANSACTION_PROCESSES=$((cpu_cores / 8))
     [[ ${TRANSACTION_PROCESSES} -lt ${min_processes} ]] && TRANSACTION_PROCESSES=${min_processes}
     [[ ${TRANSACTION_PROCESSES} -lt ${data_dir_count} ]] && TRANSACTION_PROCESSES=${data_dir_count}
-    TRANSACTION_PROCESSES=$(( (TRANSACTION_PROCESSES / data_dir_count) * data_dir_count ))
+    TRANSACTION_PROCESSES=$(((TRANSACTION_PROCESSES / data_dir_count) * data_dir_count))
 
     echo "Stateless Processes: ${STATLESS_PROCESSES}"
     echo "Storage Processes: ${STORAGE_PROCESSES}"
@@ -173,9 +173,9 @@
     CLUSTER_DESC=${FDB_CLUSTER_DESC:-$FDB_CLUSTER_ID}
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     for DIR in "${DATA_DIR_ARRAY[@]}"; do
-         mkdir -p ${DIR} || handle_error "Failed to create data directory ${DIR}"
+        mkdir -p ${DIR} || handle_error "Failed to create data directory ${DIR}"
     done
 
     echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
@@ -214,7 +214,7 @@
     for ((i = 0; i < STATLESS_PROCESSES; i++)); do
         PORT=$((FDB_PORT + i))
         echo "[fdbserver.$PORT]
-class = stateless" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+class = stateless" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + STATLESS_PROCESSES))
@@ -226,7 +226,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = storage
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + STORAGE_PROCESSES))
@@ -237,12 +237,12 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     echo "[backup_agent]
 command = ${FDB_HOME}/backup_agent
-logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
 
     echo "Deploy FDB to: ${FDB_HOME}"
 }
@@ -372,26 +372,25 @@
 skip_config="false"
 
 case $cmd in
-    deploy)
-        deploy "${job}" ${skip_pkg} ${skip_config}
-        ;;
-    start)
-        start "${job}" "${init}"
-        ;;
-    stop)
-        stop "${job}"
-        ;;
-    clean)
-        clean "${job}"
-        ;;
-    fdbcli)
-        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    *)
-        unknown_cmd ${cmd}
-        ;;
+deploy)
+    deploy "${job}" ${skip_pkg} ${skip_config}
+    ;;
+start)
+    start "${job}" "${init}"
+    ;;
+stop)
+    stop "${job}"
+    ;;
+clean)
+    clean "${job}"
+    ;;
+fdbcli)
+    ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
+    ;;
+config)
+    generate_regression_config true
+    ;;
+*)
+    unknown_cmd ${cmd}
+    ;;
 esac
-
--- tools/fdb/fdb_vars.sh.orig
+++ tools/fdb/fdb_vars.sh
@@ -32,7 +32,6 @@
 
 FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
 
-
 # Define the FoundationDB home directory, which contains the fdb binaries and logs.
 # default is /fdbhome and have to be absolute path.
 FDB_HOME="/fdbhome"
@@ -61,4 +60,4 @@
 FDB_VERSION="7.1.38"
 
 # Users who run the fdb processes, default is the current user
-USER=`whoami`
+USER=$(whoami)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_ctr.sh line 29:
ROOT_DIR="$(cd "$(dirname $(readlink -f ${BASH_SOURCE[0]}))" &>/dev/null && pwd)"
                          ^-- SC2046 (warning): Quote this to prevent word splitting.
                                        ^---------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
ROOT_DIR="$(cd "$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" &>/dev/null && pwd)"


In tools/fdb/fdb_ctr.sh line 31:
if [ -f ${ROOT_DIR}/fdb_vars.sh ]; then
   ^----------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
        ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if [[ -f "${ROOT_DIR}"/fdb_vars.sh ]]; then


In tools/fdb/fdb_ctr.sh line 32:
    source ${ROOT_DIR}/fdb_vars.sh
           ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    source "${ROOT_DIR}"/fdb_vars.sh


In tools/fdb/fdb_ctr.sh line 38:
if [ ! -d ${FDB_HOME} ]; then
   ^------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
          ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
if [[ ! -d "${FDB_HOME}" ]]; then


In tools/fdb/fdb_ctr.sh line 44:
    echo "$FDB_HOME is not an absolute path."
          ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${FDB_HOME} is not an absolute path."


In tools/fdb/fdb_ctr.sh line 48:
if [ -z ${FDB_CLUSTER_ID} ]; then
   ^----------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
        ^---------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
if [[ -z "${FDB_CLUSTER_ID}" ]]; then


In tools/fdb/fdb_ctr.sh line 64:
mkdir -p ${LOG_DIR}
         ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
mkdir -p "${LOG_DIR}"


In tools/fdb/fdb_ctr.sh line 65:
mkdir -p ${FDB_HOME}/conf
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
mkdir -p "${FDB_HOME}"/conf


In tools/fdb/fdb_ctr.sh line 66:
mkdir -p ${FDB_HOME}/log
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
mkdir -p "${FDB_HOME}"/log


In tools/fdb/fdb_ctr.sh line 72:
    if lsof -nP -iTCP:${port} -sTCP:LISTEN >/dev/null; then
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if lsof -nP -iTCP:"${port}" -sTCP:LISTEN >/dev/null; then


In tools/fdb/fdb_ctr.sh line 79:
    if [ -d ${FDB_PKG_DIR} ]; then
       ^-------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ -d "${FDB_PKG_DIR}" ]]; then


In tools/fdb/fdb_ctr.sh line 87:
    rm -rf ${TMP}
           ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    rm -rf "${TMP}"


In tools/fdb/fdb_ctr.sh line 88:
    mkdir -p ${TMP}
             ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    mkdir -p "${TMP}"


In tools/fdb/fdb_ctr.sh line 90:
    wget ${URL}/fdbbackup.x86_64 -O ${TMP}/fdbbackup
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                    ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbbackup.x86_64 -O "${TMP}"/fdbbackup


In tools/fdb/fdb_ctr.sh line 91:
    wget ${URL}/fdbserver.x86_64 -O ${TMP}/fdbserver
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                    ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbserver.x86_64 -O "${TMP}"/fdbserver


In tools/fdb/fdb_ctr.sh line 92:
    wget ${URL}/fdbcli.x86_64 -O ${TMP}/fdbcli
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                 ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbcli.x86_64 -O "${TMP}"/fdbcli


In tools/fdb/fdb_ctr.sh line 93:
    wget ${URL}/fdbmonitor.x86_64 -O ${TMP}/fdbmonitor
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                     ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/fdbmonitor.x86_64 -O "${TMP}"/fdbmonitor


In tools/fdb/fdb_ctr.sh line 94:
    wget ${URL}/libfdb_c.x86_64.so -O ${TMP}/libfdb_c.x86_64.so
         ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                      ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    wget "${URL}"/libfdb_c.x86_64.so -O "${TMP}"/libfdb_c.x86_64.so


In tools/fdb/fdb_ctr.sh line 95:
    chmod +x ${TMP}/fdb*
             ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    chmod +x "${TMP}"/fdb*


In tools/fdb/fdb_ctr.sh line 97:
    mv ${TMP} ${FDB_PKG_DIR}
       ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.
              ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    mv "${TMP}" "${FDB_PKG_DIR}"


In tools/fdb/fdb_ctr.sh line 103:
    local num_nodes=$(echo "${FDB_CLUSTER_IPS}" | tr ',' '\n' | wc -l)
          ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In tools/fdb/fdb_ctr.sh line 114:
    echo ${FDB_CLUSTER_IPS} | cut -d',' -f1-${num_coordinators} | tr ',' '\n' | sed "s/$/:${FDB_PORT}/" | paste -sd ','
         ^----------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                            ^-----------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    echo "${FDB_CLUSTER_IPS}" | cut -d',' -f1-"${num_coordinators}" | tr ',' '\n' | sed "s/$/:${FDB_PORT}/" | paste -sd ','


In tools/fdb/fdb_ctr.sh line 119:
    local num_nodes=$(echo "${FDB_CLUSTER_IPS}" | tr ',' '\n' | wc -l)
          ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In tools/fdb/fdb_ctr.sh line 130:
    echo ${fdb_mode}
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    echo "${fdb_mode}"


In tools/fdb/fdb_ctr.sh line 135:
    local memory_gb=$1
          ^-------^ SC2034 (warning): memory_gb appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_ctr.sh line 168:
    ln -sf ${FDB_PKG_DIR}/fdbserver ${FDB_HOME}/fdbserver
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbserver "${FDB_HOME}"/fdbserver


In tools/fdb/fdb_ctr.sh line 169:
    ln -sf ${FDB_PKG_DIR}/fdbmonitor ${FDB_HOME}/fdbmonitor
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                     ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbmonitor "${FDB_HOME}"/fdbmonitor


In tools/fdb/fdb_ctr.sh line 170:
    ln -sf ${FDB_PKG_DIR}/fdbbackup ${FDB_HOME}/backup_agent
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbbackup "${FDB_HOME}"/backup_agent


In tools/fdb/fdb_ctr.sh line 171:
    ln -sf ${FDB_PKG_DIR}/fdbcli ${FDB_HOME}/fdbcli
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                 ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    ln -sf "${FDB_PKG_DIR}"/fdbcli "${FDB_HOME}"/fdbcli


In tools/fdb/fdb_ctr.sh line 173:
    CLUSTER_DESC=${FDB_CLUSTER_DESC:-$FDB_CLUSTER_ID}
                                     ^-------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    CLUSTER_DESC=${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}


In tools/fdb/fdb_ctr.sh line 178:
         mkdir -p ${DIR} || handle_error "Failed to create data directory ${DIR}"
                  ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"


In tools/fdb/fdb_ctr.sh line 183:
    cat >${FDB_HOME}/conf/fdb.cluster <<EOF
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat >"${FDB_HOME}"/conf/fdb.cluster <<EOF


In tools/fdb/fdb_ctr.sh line 187:
    cat >${FDB_HOME}/conf/fdb.conf <<EOF
         ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat >"${FDB_HOME}"/conf/fdb.conf <<EOF


In tools/fdb/fdb_ctr.sh line 211:
    calculate_process_numbers ${MEMORY_LIMIT_GB} ${CPU_CORES_LIMIT}
                              ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}"


In tools/fdb/fdb_ctr.sh line 216:
        echo "[fdbserver.$PORT]
                         ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        echo "[fdbserver.${PORT}]


In tools/fdb/fdb_ctr.sh line 217:
class = stateless" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                             ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
class = stateless" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctr.sh line 229:
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                                                             ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctr.sh line 240:
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                                                             ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctr.sh line 245:
logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
logdir = ${LOG_DIR}" | tee -a "${FDB_HOME}"/conf/fdb.conf > /dev/null


In tools/fdb/fdb_ctr.sh line 251:
    if [ ! -f ${FDB_HOME}/fdbmonitor ]; then
       ^-----------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ ! -f "${FDB_HOME}"/fdbmonitor ]]; then


In tools/fdb/fdb_ctr.sh line 256:
    ensure_port_is_listenable "fdbserver" ${FDB_PORT}
                                          ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    ensure_port_is_listenable "fdbserver" "${FDB_PORT}"


In tools/fdb/fdb_ctr.sh line 259:
    ${FDB_HOME}/fdbmonitor \
    ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    "${FDB_HOME}"/fdbmonitor \


In tools/fdb/fdb_ctr.sh line 260:
        --conffile ${FDB_HOME}/conf/fdb.conf \
                   ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        --conffile "${FDB_HOME}"/conf/fdb.conf \


In tools/fdb/fdb_ctr.sh line 261:
        --lockfile ${FDB_HOME}/fdbmonitor.pid \
                   ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        --lockfile "${FDB_HOME}"/fdbmonitor.pid \


In tools/fdb/fdb_ctr.sh line 266:
    if [ -f ${FDB_HOME}/fdbmonitor.pid ]; then
       ^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ -f "${FDB_HOME}"/fdbmonitor.pid ]]; then


In tools/fdb/fdb_ctr.sh line 267:
        local fdb_pid=$(cat ${FDB_HOME}/fdbmonitor.pid)
              ^-----^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        local fdb_pid=$(cat "${FDB_HOME}"/fdbmonitor.pid)


In tools/fdb/fdb_ctr.sh line 268:
        if ps -p ${fdb_pid} >/dev/null; then
                 ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        if ps -p "${fdb_pid}" >/dev/null; then


In tools/fdb/fdb_ctr.sh line 270:
            kill -9 ${fdb_pid}
                    ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
            kill -9 "${fdb_pid}"


In tools/fdb/fdb_ctr.sh line 276:
    if [ -f ${FDB_HOME}/fdbmonitor.pid ]; then
       ^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    if [[ -f "${FDB_HOME}"/fdbmonitor.pid ]]; then


In tools/fdb/fdb_ctr.sh line 277:
        local fdb_pid=$(cat ${FDB_HOME}/fdbmonitor.pid)
              ^-----^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                            ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        local fdb_pid=$(cat "${FDB_HOME}"/fdbmonitor.pid)


In tools/fdb/fdb_ctr.sh line 278:
        if ps -p ${fdb_pid} >/dev/null; then
                 ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        if ps -p "${fdb_pid}" >/dev/null; then


In tools/fdb/fdb_ctr.sh line 285:
    rm -rf ${FDB_HOME}/*
           ^-----------^ SC2115 (warning): Use "${var:?}" to ensure this never expands to /* .
           ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    rm -rf "${FDB_HOME}"/*


In tools/fdb/fdb_ctr.sh line 293:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctr.sh line 302:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctr.sh line 306:
    if [[ $init =~ ^(all|fdb)$ ]]; then
          ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${init} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctr.sh line 308:
        local fdb_mode=$(get_fdb_mode)
              ^------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In tools/fdb/fdb_ctr.sh line 309:
        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster \
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        "${FDB_HOME}"/fdbcli -C "${FDB_HOME}"/conf/fdb.cluster \


In tools/fdb/fdb_ctr.sh line 314:
    cat ${FDB_HOME}/conf/fdb.cluster
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
    cat "${FDB_HOME}"/conf/fdb.cluster


In tools/fdb/fdb_ctr.sh line 320:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctr.sh line 329:
    if [[ $job =~ ^(all|fdb)$ ]]; then
          ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if [[ ${job} =~ ^(all|fdb)$ ]]; then


In tools/fdb/fdb_ctr.sh line 336:
    ps -ef | grep ${FDB_CLUSTER_DESC} | grep -v grep
    ^----^ SC2009 (info): Consider using pgrep instead of grepping ps output.
                  ^-----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    ps -ef | grep "${FDB_CLUSTER_DESC}" | grep -v grep


In tools/fdb/fdb_ctr.sh line 357:
    echo "Unknown cmd: ${cmd}\n"
         ^---------------------^ SC2028 (info): echo may not expand escape sequences. Use printf.


In tools/fdb/fdb_ctr.sh line 361:
if [[ $# < 1 ]]; then
         ^-- SC2071 (error): < is for string comparisons. Use -lt instead.


In tools/fdb/fdb_ctr.sh line 374:
case $cmd in
     ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
case ${cmd} in


In tools/fdb/fdb_ctr.sh line 376:
        deploy "${job}" ${skip_pkg} ${skip_config}
                        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                    ^------------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.

Did you mean: 
        deploy "${job}" "${skip_pkg}" "${skip_config}"


In tools/fdb/fdb_ctr.sh line 388:
        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
        ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                              ^---------^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                                                           ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements.

Did you mean: 
        "${FDB_HOME}"/fdbcli -C "${FDB_HOME}"/conf/fdb.cluster $@


In tools/fdb/fdb_ctr.sh line 394:
        unknown_cmd ${cmd}
                    ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        unknown_cmd "${cmd}"


In tools/fdb/fdb_vars.sh line 1:
# Licensed to the Apache Software Foundation (ASF) under one
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In tools/fdb/fdb_vars.sh line 25:
DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 33:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 38:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 42:
FDB_CLUSTER_ID="SAQESzbh"
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 45:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 50:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 53:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 58:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 61:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 64:
USER=`whoami`
     ^------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
USER=$(whoami)

For more information:
  https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ...
  https://www.shellcheck.net/wiki/SC2071 -- < is for string comparisons. Use ...
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctr.sh.orig
+++ tools/fdb/fdb_ctr.sh
@@ -139,7 +139,7 @@
     local data_dir_count
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     data_dir_count=${#DATA_DIR_ARRAY[@]}
 
     # Stateless processes (at least 1, up to 1/4 of CPU cores)
@@ -149,13 +149,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     STORAGE_PROCESSES=$((cpu_cores / 4))
     [[ ${STORAGE_PROCESSES} -lt ${data_dir_count} ]] && STORAGE_PROCESSES=${data_dir_count}
-    STORAGE_PROCESSES=$(( (STORAGE_PROCESSES / data_dir_count) * data_dir_count ))
+    STORAGE_PROCESSES=$(((STORAGE_PROCESSES / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     TRANSACTION_PROCESSES=$((cpu_cores / 8))
     [[ ${TRANSACTION_PROCESSES} -lt ${min_processes} ]] && TRANSACTION_PROCESSES=${min_processes}
     [[ ${TRANSACTION_PROCESSES} -lt ${data_dir_count} ]] && TRANSACTION_PROCESSES=${data_dir_count}
-    TRANSACTION_PROCESSES=$(( (TRANSACTION_PROCESSES / data_dir_count) * data_dir_count ))
+    TRANSACTION_PROCESSES=$(((TRANSACTION_PROCESSES / data_dir_count) * data_dir_count))
 
     echo "Stateless Processes: ${STATLESS_PROCESSES}"
     echo "Storage Processes: ${STORAGE_PROCESSES}"
@@ -173,9 +173,9 @@
     CLUSTER_DESC=${FDB_CLUSTER_DESC:-$FDB_CLUSTER_ID}
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     for DIR in "${DATA_DIR_ARRAY[@]}"; do
-         mkdir -p ${DIR} || handle_error "Failed to create data directory ${DIR}"
+        mkdir -p ${DIR} || handle_error "Failed to create data directory ${DIR}"
     done
 
     echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
@@ -214,7 +214,7 @@
     for ((i = 0; i < STATLESS_PROCESSES; i++)); do
         PORT=$((FDB_PORT + i))
         echo "[fdbserver.$PORT]
-class = stateless" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+class = stateless" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + STATLESS_PROCESSES))
@@ -226,7 +226,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = storage
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + STORAGE_PROCESSES))
@@ -237,12 +237,12 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
     done
 
     echo "[backup_agent]
 command = ${FDB_HOME}/backup_agent
-logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf > /dev/null
+logdir = ${LOG_DIR}" | tee -a ${FDB_HOME}/conf/fdb.conf >/dev/null
 
     echo "Deploy FDB to: ${FDB_HOME}"
 }
@@ -372,26 +372,25 @@
 skip_config="false"
 
 case $cmd in
-    deploy)
-        deploy "${job}" ${skip_pkg} ${skip_config}
-        ;;
-    start)
-        start "${job}" "${init}"
-        ;;
-    stop)
-        stop "${job}"
-        ;;
-    clean)
-        clean "${job}"
-        ;;
-    fdbcli)
-        ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    *)
-        unknown_cmd ${cmd}
-        ;;
+deploy)
+    deploy "${job}" ${skip_pkg} ${skip_config}
+    ;;
+start)
+    start "${job}" "${init}"
+    ;;
+stop)
+    stop "${job}"
+    ;;
+clean)
+    clean "${job}"
+    ;;
+fdbcli)
+    ${FDB_HOME}/fdbcli -C ${FDB_HOME}/conf/fdb.cluster $@
+    ;;
+config)
+    generate_regression_config true
+    ;;
+*)
+    unknown_cmd ${cmd}
+    ;;
 esac
-
--- tools/fdb/fdb_vars.sh.orig
+++ tools/fdb/fdb_vars.sh
@@ -32,7 +32,6 @@
 
 FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
 
-
 # Define the FoundationDB home directory, which contains the fdb binaries and logs.
 # default is /fdbhome and have to be absolute path.
 FDB_HOME="/fdbhome"
@@ -61,4 +60,4 @@
 FDB_VERSION="7.1.38"
 
 # Users who run the fdb processes, default is the current user
-USER=`whoami`
+USER=$(whoami)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_ctr.sh line 138:
    local memory_gb=$1
          ^-------^ SC2034 (warning): memory_gb appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_ctr.sh line 305:
    rm -rf "${FDB_HOME}"/*
           ^-------------^ SC2115 (warning): Use "${var:?}" to ensure this never expands to /* .


In tools/fdb/fdb_ctr.sh line 379:
    echo "Unknown cmd: ${cmd}\n"
         ^---------------------^ SC2028 (info): echo may not expand escape sequences. Use printf.


In tools/fdb/fdb_vars.sh line 1:
# Licensed to the Apache Software Foundation (ASF) under one
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In tools/fdb/fdb_vars.sh line 25:
DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 33:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 38:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 42:
FDB_CLUSTER_ID="SAQESzbh"
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 45:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 50:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 53:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 58:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 61:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 64:
USER=`whoami`
     ^------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
USER=$(whoami)

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2034 -- CPU_CORES_LIMIT appears unused. V...
  https://www.shellcheck.net/wiki/SC2115 -- Use "${var:?}" to ensure this nev...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctr.sh.orig
+++ tools/fdb/fdb_ctr.sh
@@ -142,7 +142,7 @@
     local data_dir_count
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     data_dir_count=${#DATA_DIR_ARRAY[@]}
 
     # Stateless processes (at least 1, up to 1/4 of CPU cores)
@@ -152,13 +152,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     local storage_processes=$((cpu_cores / 4))
     [[ ${storage_processes} -lt ${data_dir_count} ]] && storage_processes=${data_dir_count}
-    storage_processes=$(( (storage_processes / data_dir_count) * data_dir_count ))
+    storage_processes=$(((storage_processes / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     local transaction_processes=$((cpu_cores / 8))
     [[ ${transaction_processes} -lt ${min_processes} ]] && transaction_processes=${min_processes}
     [[ ${transaction_processes} -lt ${data_dir_count} ]] && transaction_processes=${data_dir_count}
-    transaction_processes=$(( (transaction_processes / data_dir_count) * data_dir_count ))
+    transaction_processes=$(((transaction_processes / data_dir_count) * data_dir_count))
 
     # Return the values
     echo "${stateless_processes} ${storage_processes} ${transaction_processes}"
@@ -175,9 +175,9 @@
     CLUSTER_DESC="${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}"
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     for DIR in "${DATA_DIR_ARRAY[@]}"; do
-         mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
+        mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
     done
 
     echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
@@ -210,13 +210,13 @@
     CPU_CORES_LIMIT=${CPU_CORES_LIMIT:-1}
 
     # Calculate number of processes based on resources and data directories
-    read -r stateless_processes storage_processes transaction_processes <<< "$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
+    read -r stateless_processes storage_processes transaction_processes <<<"$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
 
     # Add stateless processes
     for ((i = 0; i < stateless_processes; i++)); do
         PORT=$((FDB_PORT + i))
         echo "[fdbserver.${PORT}]
-class = stateless" >> "${FDB_HOME}/conf/fdb.conf"
+class = stateless" >>"${FDB_HOME}/conf/fdb.conf"
     done
 
     FDB_PORT=$((FDB_PORT + stateless_processes))
@@ -228,7 +228,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = storage
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + storage_processes))
@@ -239,12 +239,12 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     echo "[backup_agent]
 command = ${FDB_HOME}/backup_agent
-logdir = ${LOG_DIR}" >> "${FDB_HOME}/conf/fdb.conf"
+logdir = ${LOG_DIR}" >>"${FDB_HOME}/conf/fdb.conf"
 
     echo "Deploy FDB to: ${FDB_HOME}"
 }
@@ -278,7 +278,7 @@
 function clean_fdb() {
     if [[ -f "${FDB_HOME}/fdbmonitor.pid" ]]; then
         local fdb_pid
-        
+
         fdb_pid=$(cat "${FDB_HOME}/fdbmonitor.pid")
         if ps -p "${fdb_pid}" >/dev/null; then
             echo "fdbmonitor with pid ${fdb_pid} is running, stop it first."
@@ -326,7 +326,7 @@
     if [[ ${init} =~ ^(all|fdb)$ ]]; then
         echo "Try create database ..."
         local fdb_mode
-        
+
         fdb_mode=$(get_fdb_mode)
         "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" \
             --exec "configure new ${fdb_mode} ssd" || true
@@ -394,26 +394,25 @@
 skip_config="false"
 
 case ${cmd} in
-    deploy)
-        deploy "${job}" "${skip_pkg}" "${skip_config}"
-        ;;
-    start)
-        start "${job}" "${init}"
-        ;;
-    stop)
-        stop "${job}"
-        ;;
-    clean)
-        clean "${job}"
-        ;;
-    fdbcli)
-        "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    *)
-        unknown_cmd "${cmd}"
-        ;;
+deploy)
+    deploy "${job}" "${skip_pkg}" "${skip_config}"
+    ;;
+start)
+    start "${job}" "${init}"
+    ;;
+stop)
+    stop "${job}"
+    ;;
+clean)
+    clean "${job}"
+    ;;
+fdbcli)
+    "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
+    ;;
+config)
+    generate_regression_config true
+    ;;
+*)
+    unknown_cmd "${cmd}"
+    ;;
 esac
-
--- tools/fdb/fdb_vars.sh.orig
+++ tools/fdb/fdb_vars.sh
@@ -32,7 +32,6 @@
 
 FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
 
-
 # Define the FoundationDB home directory, which contains the fdb binaries and logs.
 # default is /fdbhome and have to be absolute path.
 FDB_HOME="/fdbhome"
@@ -61,4 +60,4 @@
 FDB_VERSION="7.1.38"
 
 # Users who run the fdb processes, default is the current user
-USER=`whoami`
+USER=$(whoami)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_ctr.sh line 305:
    rm -rf "${FDB_HOME}"/*
           ^-------------^ SC2115 (warning): Use "${var:?}" to ensure this never expands to /* .


In tools/fdb/fdb_ctr.sh line 379:
    echo "Unknown cmd: ${cmd}\n"
         ^---------------------^ SC2028 (info): echo may not expand escape sequences. Use printf.


In tools/fdb/fdb_vars.sh line 1:
# Licensed to the Apache Software Foundation (ASF) under one
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In tools/fdb/fdb_vars.sh line 25:
DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 33:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 38:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 42:
FDB_CLUSTER_ID="SAQESzbh"
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 45:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 50:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 53:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 58:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 61:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 64:
USER=`whoami`
     ^------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
USER=$(whoami)

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2034 -- CPU_CORES_LIMIT appears unused. V...
  https://www.shellcheck.net/wiki/SC2115 -- Use "${var:?}" to ensure this nev...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctr.sh.orig
+++ tools/fdb/fdb_ctr.sh
@@ -142,7 +142,7 @@
     local data_dir_count
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     data_dir_count=${#DATA_DIR_ARRAY[@]}
 
     # Stateless processes (at least 1, up to 1/4 of CPU cores)
@@ -152,13 +152,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     local storage_processes=$((cpu_cores / 4))
     [[ ${storage_processes} -lt ${data_dir_count} ]] && storage_processes=${data_dir_count}
-    storage_processes=$(( (storage_processes / data_dir_count) * data_dir_count ))
+    storage_processes=$(((storage_processes / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     local transaction_processes=$((cpu_cores / 8))
     [[ ${transaction_processes} -lt ${min_processes} ]] && transaction_processes=${min_processes}
     [[ ${transaction_processes} -lt ${data_dir_count} ]] && transaction_processes=${data_dir_count}
-    transaction_processes=$(( (transaction_processes / data_dir_count) * data_dir_count ))
+    transaction_processes=$(((transaction_processes / data_dir_count) * data_dir_count))
 
     # Return the values
     echo "${stateless_processes} ${storage_processes} ${transaction_processes}"
@@ -175,9 +175,9 @@
     CLUSTER_DESC="${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}"
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     for DIR in "${DATA_DIR_ARRAY[@]}"; do
-         mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
+        mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
     done
 
     echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
@@ -210,13 +210,13 @@
     CPU_CORES_LIMIT=${CPU_CORES_LIMIT:-1}
 
     # Calculate number of processes based on resources and data directories
-    read -r stateless_processes storage_processes transaction_processes <<< "$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
+    read -r stateless_processes storage_processes transaction_processes <<<"$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
 
     # Add stateless processes
     for ((i = 0; i < stateless_processes; i++)); do
         PORT=$((FDB_PORT + i))
         echo "[fdbserver.${PORT}]
-class = stateless" >> "${FDB_HOME}/conf/fdb.conf"
+class = stateless" >>"${FDB_HOME}/conf/fdb.conf"
     done
 
     FDB_PORT=$((FDB_PORT + stateless_processes))
@@ -228,7 +228,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = storage
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + storage_processes))
@@ -239,12 +239,12 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     echo "[backup_agent]
 command = ${FDB_HOME}/backup_agent
-logdir = ${LOG_DIR}" >> "${FDB_HOME}/conf/fdb.conf"
+logdir = ${LOG_DIR}" >>"${FDB_HOME}/conf/fdb.conf"
 
     echo "Deploy FDB to: ${FDB_HOME}"
 }
@@ -278,7 +278,7 @@
 function clean_fdb() {
     if [[ -f "${FDB_HOME}/fdbmonitor.pid" ]]; then
         local fdb_pid
-        
+
         fdb_pid=$(cat "${FDB_HOME}/fdbmonitor.pid")
         if ps -p "${fdb_pid}" >/dev/null; then
             echo "fdbmonitor with pid ${fdb_pid} is running, stop it first."
@@ -326,7 +326,7 @@
     if [[ ${init} =~ ^(all|fdb)$ ]]; then
         echo "Try create database ..."
         local fdb_mode
-        
+
         fdb_mode=$(get_fdb_mode)
         "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" \
             --exec "configure new ${fdb_mode} ssd" || true
@@ -394,26 +394,25 @@
 skip_config="false"
 
 case ${cmd} in
-    deploy)
-        deploy "${job}" "${skip_pkg}" "${skip_config}"
-        ;;
-    start)
-        start "${job}" "${init}"
-        ;;
-    stop)
-        stop "${job}"
-        ;;
-    clean)
-        clean "${job}"
-        ;;
-    fdbcli)
-        "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    *)
-        unknown_cmd "${cmd}"
-        ;;
+deploy)
+    deploy "${job}" "${skip_pkg}" "${skip_config}"
+    ;;
+start)
+    start "${job}" "${init}"
+    ;;
+stop)
+    stop "${job}"
+    ;;
+clean)
+    clean "${job}"
+    ;;
+fdbcli)
+    "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
+    ;;
+config)
+    generate_regression_config true
+    ;;
+*)
+    unknown_cmd "${cmd}"
+    ;;
 esac
-
--- tools/fdb/fdb_vars.sh.orig
+++ tools/fdb/fdb_vars.sh
@@ -32,7 +32,6 @@
 
 FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
 
-
 # Define the FoundationDB home directory, which contains the fdb binaries and logs.
 # default is /fdbhome and have to be absolute path.
 FDB_HOME="/fdbhome"
@@ -61,4 +60,4 @@
 FDB_VERSION="7.1.38"
 
 # Users who run the fdb processes, default is the current user
-USER=`whoami`
+USER=$(whoami)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_vars.sh line 1:
# Licensed to the Apache Software Foundation (ASF) under one
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In tools/fdb/fdb_vars.sh line 25:
DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 33:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 38:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 42:
FDB_CLUSTER_ID="SAQESzbh"
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 45:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 50:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 53:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 58:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 61:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 64:
USER=`whoami`
     ^------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
USER=$(whoami)

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2034 -- CPU_CORES_LIMIT appears unused. V...
  https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctr.sh.orig
+++ tools/fdb/fdb_ctr.sh
@@ -142,7 +142,7 @@
     local data_dir_count
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     data_dir_count=${#DATA_DIR_ARRAY[@]}
 
     # Stateless processes (at least 1, up to 1/4 of CPU cores)
@@ -152,13 +152,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     local storage_processes=$((cpu_cores / 4))
     [[ ${storage_processes} -lt ${data_dir_count} ]] && storage_processes=${data_dir_count}
-    storage_processes=$(( (storage_processes / data_dir_count) * data_dir_count ))
+    storage_processes=$(((storage_processes / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     local transaction_processes=$((cpu_cores / 8))
     [[ ${transaction_processes} -lt ${min_processes} ]] && transaction_processes=${min_processes}
     [[ ${transaction_processes} -lt ${data_dir_count} ]] && transaction_processes=${data_dir_count}
-    transaction_processes=$(( (transaction_processes / data_dir_count) * data_dir_count ))
+    transaction_processes=$(((transaction_processes / data_dir_count) * data_dir_count))
 
     # Return the values
     echo "${stateless_processes} ${storage_processes} ${transaction_processes}"
@@ -175,9 +175,9 @@
     CLUSTER_DESC="${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}"
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     for DIR in "${DATA_DIR_ARRAY[@]}"; do
-         mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
+        mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
     done
 
     echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
@@ -210,13 +210,13 @@
     CPU_CORES_LIMIT=${CPU_CORES_LIMIT:-1}
 
     # Calculate number of processes based on resources and data directories
-    read -r stateless_processes storage_processes transaction_processes <<< "$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
+    read -r stateless_processes storage_processes transaction_processes <<<"$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
 
     # Add stateless processes
     for ((i = 0; i < stateless_processes; i++)); do
         PORT=$((FDB_PORT + i))
         echo "[fdbserver.${PORT}]
-class = stateless" >> "${FDB_HOME}/conf/fdb.conf"
+class = stateless" >>"${FDB_HOME}/conf/fdb.conf"
     done
 
     FDB_PORT=$((FDB_PORT + stateless_processes))
@@ -228,7 +228,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = storage
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + storage_processes))
@@ -239,12 +239,12 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     echo "[backup_agent]
 command = ${FDB_HOME}/backup_agent
-logdir = ${LOG_DIR}" >> "${FDB_HOME}/conf/fdb.conf"
+logdir = ${LOG_DIR}" >>"${FDB_HOME}/conf/fdb.conf"
 
     echo "Deploy FDB to: ${FDB_HOME}"
 }
@@ -278,7 +278,7 @@
 function clean_fdb() {
     if [[ -f "${FDB_HOME}/fdbmonitor.pid" ]]; then
         local fdb_pid
-        
+
         fdb_pid=$(cat "${FDB_HOME}/fdbmonitor.pid")
         if ps -p "${fdb_pid}" >/dev/null; then
             echo "fdbmonitor with pid ${fdb_pid} is running, stop it first."
@@ -326,7 +326,7 @@
     if [[ ${init} =~ ^(all|fdb)$ ]]; then
         echo "Try create database ..."
         local fdb_mode
-        
+
         fdb_mode=$(get_fdb_mode)
         "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" \
             --exec "configure new ${fdb_mode} ssd" || true
@@ -394,26 +394,25 @@
 skip_config="false"
 
 case ${cmd} in
-    deploy)
-        deploy "${job}" "${skip_pkg}" "${skip_config}"
-        ;;
-    start)
-        start "${job}" "${init}"
-        ;;
-    stop)
-        stop "${job}"
-        ;;
-    clean)
-        clean "${job}"
-        ;;
-    fdbcli)
-        "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    *)
-        unknown_cmd "${cmd}"
-        ;;
+deploy)
+    deploy "${job}" "${skip_pkg}" "${skip_config}"
+    ;;
+start)
+    start "${job}" "${init}"
+    ;;
+stop)
+    stop "${job}"
+    ;;
+clean)
+    clean "${job}"
+    ;;
+fdbcli)
+    "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
+    ;;
+config)
+    generate_regression_config true
+    ;;
+*)
+    unknown_cmd "${cmd}"
+    ;;
 esac
-
--- tools/fdb/fdb_vars.sh.orig
+++ tools/fdb/fdb_vars.sh
@@ -32,7 +32,6 @@
 
 FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
 
-
 # Define the FoundationDB home directory, which contains the fdb binaries and logs.
 # default is /fdbhome and have to be absolute path.
 FDB_HOME="/fdbhome"
@@ -61,4 +60,4 @@
 FDB_VERSION="7.1.38"
 
 # Users who run the fdb processes, default is the current user
-USER=`whoami`
+USER=$(whoami)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_vars.sh line 1:
# Licensed to the Apache Software Foundation (ASF) under one
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In tools/fdb/fdb_vars.sh line 25:
DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 33:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 38:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 42:
FDB_CLUSTER_ID="SAQESzbh"
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 45:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 50:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 53:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 58:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 61:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 64:
USER=`whoami`
     ^------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
USER=$(whoami)

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2034 -- CPU_CORES_LIMIT appears unused. V...
  https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctr.sh.orig
+++ tools/fdb/fdb_ctr.sh
@@ -142,7 +142,7 @@
     local data_dir_count
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     data_dir_count=${#DATA_DIR_ARRAY[@]}
 
     # Stateless processes (at least 1, up to 1/4 of CPU cores)
@@ -152,13 +152,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     local storage_processes=$((cpu_cores / 4))
     [[ ${storage_processes} -lt ${data_dir_count} ]] && storage_processes=${data_dir_count}
-    storage_processes=$(( (storage_processes / data_dir_count) * data_dir_count ))
+    storage_processes=$(((storage_processes / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     local transaction_processes=$((cpu_cores / 8))
     [[ ${transaction_processes} -lt ${min_processes} ]] && transaction_processes=${min_processes}
     [[ ${transaction_processes} -lt ${data_dir_count} ]] && transaction_processes=${data_dir_count}
-    transaction_processes=$(( (transaction_processes / data_dir_count) * data_dir_count ))
+    transaction_processes=$(((transaction_processes / data_dir_count) * data_dir_count))
 
     # Return the values
     echo "${stateless_processes} ${storage_processes} ${transaction_processes}"
@@ -175,9 +175,9 @@
     CLUSTER_DESC="${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}"
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     for DIR in "${DATA_DIR_ARRAY[@]}"; do
-         mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
+        mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
     done
 
     echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
@@ -210,13 +210,13 @@
     CPU_CORES_LIMIT=${CPU_CORES_LIMIT:-1}
 
     # Calculate number of processes based on resources and data directories
-    read -r stateless_processes storage_processes transaction_processes <<< "$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
+    read -r stateless_processes storage_processes transaction_processes <<<"$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
 
     # Add stateless processes
     for ((i = 0; i < stateless_processes; i++)); do
         PORT=$((FDB_PORT + i))
         echo "[fdbserver.${PORT}]
-class = stateless" >> "${FDB_HOME}/conf/fdb.conf"
+class = stateless" >>"${FDB_HOME}/conf/fdb.conf"
     done
 
     FDB_PORT=$((FDB_PORT + stateless_processes))
@@ -228,7 +228,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = storage
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + storage_processes))
@@ -239,12 +239,12 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     echo "[backup_agent]
 command = ${FDB_HOME}/backup_agent
-logdir = ${LOG_DIR}" >> "${FDB_HOME}/conf/fdb.conf"
+logdir = ${LOG_DIR}" >>"${FDB_HOME}/conf/fdb.conf"
 
     echo "Deploy FDB to: ${FDB_HOME}"
 }
@@ -278,7 +278,7 @@
 function clean_fdb() {
     if [[ -f "${FDB_HOME}/fdbmonitor.pid" ]]; then
         local fdb_pid
-        
+
         fdb_pid=$(cat "${FDB_HOME}/fdbmonitor.pid")
         if ps -p "${fdb_pid}" >/dev/null; then
             echo "fdbmonitor with pid ${fdb_pid} is running, stop it first."
@@ -326,7 +326,7 @@
     if [[ ${init} =~ ^(all|fdb)$ ]]; then
         echo "Try create database ..."
         local fdb_mode
-        
+
         fdb_mode=$(get_fdb_mode)
         "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" \
             --exec "configure new ${fdb_mode} ssd" || true
@@ -394,26 +394,25 @@
 skip_config="false"
 
 case ${cmd} in
-    deploy)
-        deploy "${job}" "${skip_pkg}" "${skip_config}"
-        ;;
-    start)
-        start "${job}" "${init}"
-        ;;
-    stop)
-        stop "${job}"
-        ;;
-    clean)
-        clean "${job}"
-        ;;
-    fdbcli)
-        "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    *)
-        unknown_cmd "${cmd}"
-        ;;
+deploy)
+    deploy "${job}" "${skip_pkg}" "${skip_config}"
+    ;;
+start)
+    start "${job}" "${init}"
+    ;;
+stop)
+    stop "${job}"
+    ;;
+clean)
+    clean "${job}"
+    ;;
+fdbcli)
+    "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
+    ;;
+config)
+    generate_regression_config true
+    ;;
+*)
+    unknown_cmd "${cmd}"
+    ;;
 esac
-
--- tools/fdb/fdb_vars.sh.orig
+++ tools/fdb/fdb_vars.sh
@@ -32,7 +32,6 @@
 
 FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
 
-
 # Define the FoundationDB home directory, which contains the fdb binaries and logs.
 # default is /fdbhome and have to be absolute path.
 FDB_HOME="/fdbhome"
@@ -61,4 +60,4 @@
 FDB_VERSION="7.1.38"
 
 # Users who run the fdb processes, default is the current user
-USER=`whoami`
+USER=$(whoami)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 1, 2024

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_vars.sh line 1:
# Licensed to the Apache Software Foundation (ASF) under one
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In tools/fdb/fdb_vars.sh line 25:
DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 33:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 38:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 42:
FDB_CLUSTER_ID=`mktemp -u XXXXXXXX`
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).
               ^------------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
FDB_CLUSTER_ID=$(mktemp -u XXXXXXXX)


In tools/fdb/fdb_vars.sh line 45:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 50:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 53:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 58:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 61:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 64:
USER=`whoami`
     ^------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
USER=$(whoami)

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2034 -- CPU_CORES_LIMIT appears unused. V...
  https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctr.sh.orig
+++ tools/fdb/fdb_ctr.sh
@@ -142,7 +142,7 @@
     local data_dir_count
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     data_dir_count=${#DATA_DIR_ARRAY[@]}
 
     # Stateless processes (at least 1, up to 1/4 of CPU cores)
@@ -152,13 +152,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     local storage_processes=$((cpu_cores / 4))
     [[ ${storage_processes} -lt ${data_dir_count} ]] && storage_processes=${data_dir_count}
-    storage_processes=$(( (storage_processes / data_dir_count) * data_dir_count ))
+    storage_processes=$(((storage_processes / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     local transaction_processes=$((cpu_cores / 8))
     [[ ${transaction_processes} -lt ${min_processes} ]] && transaction_processes=${min_processes}
     [[ ${transaction_processes} -lt ${data_dir_count} ]] && transaction_processes=${data_dir_count}
-    transaction_processes=$(( (transaction_processes / data_dir_count) * data_dir_count ))
+    transaction_processes=$(((transaction_processes / data_dir_count) * data_dir_count))
 
     # Return the values
     echo "${stateless_processes} ${storage_processes} ${transaction_processes}"
@@ -175,9 +175,9 @@
     CLUSTER_DESC="${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}"
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     for DIR in "${DATA_DIR_ARRAY[@]}"; do
-         mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
+        mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
     done
 
     echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
@@ -210,13 +210,13 @@
     CPU_CORES_LIMIT=${CPU_CORES_LIMIT:-1}
 
     # Calculate number of processes based on resources and data directories
-    read -r stateless_processes storage_processes transaction_processes <<< "$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
+    read -r stateless_processes storage_processes transaction_processes <<<"$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
 
     # Add stateless processes
     for ((i = 0; i < stateless_processes; i++)); do
         PORT=$((FDB_PORT + i))
         echo "[fdbserver.${PORT}]
-class = stateless" >> "${FDB_HOME}/conf/fdb.conf"
+class = stateless" >>"${FDB_HOME}/conf/fdb.conf"
     done
 
     FDB_PORT=$((FDB_PORT + stateless_processes))
@@ -228,7 +228,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = storage
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + storage_processes))
@@ -239,12 +239,12 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     echo "[backup_agent]
 command = ${FDB_HOME}/backup_agent
-logdir = ${LOG_DIR}" >> "${FDB_HOME}/conf/fdb.conf"
+logdir = ${LOG_DIR}" >>"${FDB_HOME}/conf/fdb.conf"
 
     echo "Deploy FDB to: ${FDB_HOME}"
 }
@@ -278,7 +278,7 @@
 function clean_fdb() {
     if [[ -f "${FDB_HOME}/fdbmonitor.pid" ]]; then
         local fdb_pid
-        
+
         fdb_pid=$(cat "${FDB_HOME}/fdbmonitor.pid")
         if ps -p "${fdb_pid}" >/dev/null; then
             echo "fdbmonitor with pid ${fdb_pid} is running, stop it first."
@@ -326,7 +326,7 @@
     if [[ ${init} =~ ^(all|fdb)$ ]]; then
         echo "Try create database ..."
         local fdb_mode
-        
+
         fdb_mode=$(get_fdb_mode)
         "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" \
             --exec "configure new ${fdb_mode} ssd" || true
@@ -394,26 +394,25 @@
 skip_config="false"
 
 case ${cmd} in
-    deploy)
-        deploy "${job}" "${skip_pkg}" "${skip_config}"
-        ;;
-    start)
-        start "${job}" "${init}"
-        ;;
-    stop)
-        stop "${job}"
-        ;;
-    clean)
-        clean "${job}"
-        ;;
-    fdbcli)
-        "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    *)
-        unknown_cmd "${cmd}"
-        ;;
+deploy)
+    deploy "${job}" "${skip_pkg}" "${skip_config}"
+    ;;
+start)
+    start "${job}" "${init}"
+    ;;
+stop)
+    stop "${job}"
+    ;;
+clean)
+    clean "${job}"
+    ;;
+fdbcli)
+    "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
+    ;;
+config)
+    generate_regression_config true
+    ;;
+*)
+    unknown_cmd "${cmd}"
+    ;;
 esac
-
--- tools/fdb/fdb_vars.sh.orig
+++ tools/fdb/fdb_vars.sh
@@ -32,14 +32,13 @@
 
 FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
 
-
 # Define the FoundationDB home directory, which contains the fdb binaries and logs.
 # default is /fdbhome and have to be absolute path.
 FDB_HOME="/fdbhome"
 
 # Define the cluster id, shoule be generated random like mktemp -u XXXXXXXX,
 # have to be different for each cluster.
-FDB_CLUSTER_ID=`mktemp -u XXXXXXXX`
+FDB_CLUSTER_ID=$(mktemp -u XXXXXXXX)
 
 # Define the cluster description, you 'd better to change it.
 FDB_CLUSTER_DESC="mycluster"
@@ -61,4 +60,4 @@
 FDB_VERSION="7.1.38"
 
 # Users who run the fdb processes, default is the current user
-USER=`whoami`
+USER=$(whoami)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


gavinchou
gavinchou previously approved these changes Sep 1, 2024
@gavinchou
Copy link
Copy Markdown
Contributor

run buildall

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 5, 2024

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_vars.sh line 1:
# Licensed to the Apache Software Foundation (ASF) under one
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In tools/fdb/fdb_vars.sh line 25:
DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 33:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 38:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 42:
FDB_CLUSTER_ID=`mktemp -u XXXXXXXX`
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).
               ^------------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
FDB_CLUSTER_ID=$(mktemp -u XXXXXXXX)


In tools/fdb/fdb_vars.sh line 45:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 50:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 53:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 58:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 61:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 64:
USER=`whoami`
     ^------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
USER=$(whoami)

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2034 -- CPU_CORES_LIMIT appears unused. V...
  https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctr.sh.orig
+++ tools/fdb/fdb_ctr.sh
@@ -142,7 +142,7 @@
     local data_dir_count
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     data_dir_count=${#DATA_DIR_ARRAY[@]}
 
     # Stateless processes (at least 1, up to 1/4 of CPU cores)
@@ -152,13 +152,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     local storage_processes=$((cpu_cores / 4))
     [[ ${storage_processes} -lt ${data_dir_count} ]] && storage_processes=${data_dir_count}
-    storage_processes=$(( (storage_processes / data_dir_count) * data_dir_count ))
+    storage_processes=$(((storage_processes / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     local transaction_processes=$((cpu_cores / 8))
     [[ ${transaction_processes} -lt ${min_processes} ]] && transaction_processes=${min_processes}
     [[ ${transaction_processes} -lt ${data_dir_count} ]] && transaction_processes=${data_dir_count}
-    transaction_processes=$(( (transaction_processes / data_dir_count) * data_dir_count ))
+    transaction_processes=$(((transaction_processes / data_dir_count) * data_dir_count))
 
     # Return the values
     echo "${stateless_processes} ${storage_processes} ${transaction_processes}"
@@ -175,9 +175,9 @@
     CLUSTER_DESC="${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}"
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     for DIR in "${DATA_DIR_ARRAY[@]}"; do
-         mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
+        mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
     done
 
     echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
@@ -210,13 +210,13 @@
     CPU_CORES_LIMIT=${CPU_CORES_LIMIT:-1}
 
     # Calculate number of processes based on resources and data directories
-    read -r stateless_processes storage_processes transaction_processes <<< "$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
+    read -r stateless_processes storage_processes transaction_processes <<<"$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
 
     # Add stateless processes
     for ((i = 0; i < stateless_processes; i++)); do
         PORT=$((FDB_PORT + i))
         echo "[fdbserver.${PORT}]
-class = stateless" >> "${FDB_HOME}/conf/fdb.conf"
+class = stateless" >>"${FDB_HOME}/conf/fdb.conf"
     done
 
     FDB_PORT=$((FDB_PORT + stateless_processes))
@@ -228,7 +228,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = storage
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + storage_processes))
@@ -239,12 +239,12 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     echo "[backup_agent]
 command = ${FDB_HOME}/backup_agent
-logdir = ${LOG_DIR}" >> "${FDB_HOME}/conf/fdb.conf"
+logdir = ${LOG_DIR}" >>"${FDB_HOME}/conf/fdb.conf"
 
     echo "Deploy FDB to: ${FDB_HOME}"
 }
@@ -278,7 +278,7 @@
 function clean_fdb() {
     if [[ -f "${FDB_HOME}/fdbmonitor.pid" ]]; then
         local fdb_pid
-        
+
         fdb_pid=$(cat "${FDB_HOME}/fdbmonitor.pid")
         if ps -p "${fdb_pid}" >/dev/null; then
             echo "fdbmonitor with pid ${fdb_pid} is running, stop it first."
@@ -326,7 +326,7 @@
     if [[ ${init} =~ ^(all|fdb)$ ]]; then
         echo "Try create database ..."
         local fdb_mode
-        
+
         fdb_mode=$(get_fdb_mode)
         "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" \
             --exec "configure new ${fdb_mode} ssd" || true
@@ -394,26 +394,25 @@
 skip_config="false"
 
 case ${cmd} in
-    deploy)
-        deploy "${job}" "${skip_pkg}" "${skip_config}"
-        ;;
-    start)
-        start "${job}" "${init}"
-        ;;
-    stop)
-        stop "${job}"
-        ;;
-    clean)
-        clean "${job}"
-        ;;
-    fdbcli)
-        "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    *)
-        unknown_cmd "${cmd}"
-        ;;
+deploy)
+    deploy "${job}" "${skip_pkg}" "${skip_config}"
+    ;;
+start)
+    start "${job}" "${init}"
+    ;;
+stop)
+    stop "${job}"
+    ;;
+clean)
+    clean "${job}"
+    ;;
+fdbcli)
+    "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
+    ;;
+config)
+    generate_regression_config true
+    ;;
+*)
+    unknown_cmd "${cmd}"
+    ;;
 esac
-
--- tools/fdb/fdb_vars.sh.orig
+++ tools/fdb/fdb_vars.sh
@@ -32,14 +32,13 @@
 
 FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
 
-
 # Define the FoundationDB home directory, which contains the fdb binaries and logs.
 # default is /fdbhome and have to be absolute path.
 FDB_HOME="/fdbhome"
 
 # Define the cluster id, shoule be generated random like mktemp -u XXXXXXXX,
 # have to be different for each cluster.
-FDB_CLUSTER_ID=`mktemp -u XXXXXXXX`
+FDB_CLUSTER_ID=$(mktemp -u XXXXXXXX)
 
 # Define the cluster description, you 'd better to change it.
 FDB_CLUSTER_DESC="mycluster"
@@ -61,4 +60,4 @@
 FDB_VERSION="7.1.38"
 
 # Users who run the fdb processes, default is the current user
-USER=`whoami`
+USER=$(whoami)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 5, 2024

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_vars.sh line 1:
# Licensed to the Apache Software Foundation (ASF) under one
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In tools/fdb/fdb_vars.sh line 25:
DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 33:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 38:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 42:
FDB_CLUSTER_ID=`mktemp -u XXXXXXXX`
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).
               ^------------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
FDB_CLUSTER_ID=$(mktemp -u XXXXXXXX)


In tools/fdb/fdb_vars.sh line 45:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 50:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 53:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 58:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 61:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 64:
USER=`whoami`
     ^------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
USER=$(whoami)

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2034 -- CPU_CORES_LIMIT appears unused. V...
  https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctr.sh.orig
+++ tools/fdb/fdb_ctr.sh
@@ -142,7 +142,7 @@
     local data_dir_count
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     data_dir_count=${#DATA_DIR_ARRAY[@]}
 
     # Stateless processes (at least 1, up to 1/4 of CPU cores)
@@ -152,13 +152,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     local storage_processes=$((cpu_cores / 4))
     [[ ${storage_processes} -lt ${data_dir_count} ]] && storage_processes=${data_dir_count}
-    storage_processes=$(( (storage_processes / data_dir_count) * data_dir_count ))
+    storage_processes=$(((storage_processes / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     local transaction_processes=$((cpu_cores / 8))
     [[ ${transaction_processes} -lt ${min_processes} ]] && transaction_processes=${min_processes}
     [[ ${transaction_processes} -lt ${data_dir_count} ]] && transaction_processes=${data_dir_count}
-    transaction_processes=$(( (transaction_processes / data_dir_count) * data_dir_count ))
+    transaction_processes=$(((transaction_processes / data_dir_count) * data_dir_count))
 
     # Return the values
     echo "${stateless_processes} ${storage_processes} ${transaction_processes}"
@@ -175,9 +175,9 @@
     CLUSTER_DESC="${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}"
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     for DIR in "${DATA_DIR_ARRAY[@]}"; do
-         mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
+        mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
     done
 
     echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
@@ -210,13 +210,13 @@
     CPU_CORES_LIMIT=${CPU_CORES_LIMIT:-1}
 
     # Calculate number of processes based on resources and data directories
-    read -r stateless_processes storage_processes transaction_processes <<< "$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
+    read -r stateless_processes storage_processes transaction_processes <<<"$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
 
     # Add stateless processes
     for ((i = 0; i < stateless_processes; i++)); do
         PORT=$((FDB_PORT + i))
         echo "[fdbserver.${PORT}]
-class = stateless" >> "${FDB_HOME}/conf/fdb.conf"
+class = stateless" >>"${FDB_HOME}/conf/fdb.conf"
     done
 
     FDB_PORT=$((FDB_PORT + stateless_processes))
@@ -228,7 +228,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = storage
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + storage_processes))
@@ -239,12 +239,12 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     echo "[backup_agent]
 command = ${FDB_HOME}/backup_agent
-logdir = ${LOG_DIR}" >> "${FDB_HOME}/conf/fdb.conf"
+logdir = ${LOG_DIR}" >>"${FDB_HOME}/conf/fdb.conf"
 
     echo "Deploy FDB to: ${FDB_HOME}"
 }
@@ -278,7 +278,7 @@
 function clean_fdb() {
     if [[ -f "${FDB_HOME}/fdbmonitor.pid" ]]; then
         local fdb_pid
-        
+
         fdb_pid=$(cat "${FDB_HOME}/fdbmonitor.pid")
         if ps -p "${fdb_pid}" >/dev/null; then
             echo "fdbmonitor with pid ${fdb_pid} is running, stop it first."
@@ -326,7 +326,7 @@
     if [[ ${init} =~ ^(all|fdb)$ ]]; then
         echo "Try create database ..."
         local fdb_mode
-        
+
         fdb_mode=$(get_fdb_mode)
         "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" \
             --exec "configure new ${fdb_mode} ssd" || true
@@ -394,26 +394,25 @@
 skip_config="false"
 
 case ${cmd} in
-    deploy)
-        deploy "${job}" "${skip_pkg}" "${skip_config}"
-        ;;
-    start)
-        start "${job}" "${init}"
-        ;;
-    stop)
-        stop "${job}"
-        ;;
-    clean)
-        clean "${job}"
-        ;;
-    fdbcli)
-        "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    *)
-        unknown_cmd "${cmd}"
-        ;;
+deploy)
+    deploy "${job}" "${skip_pkg}" "${skip_config}"
+    ;;
+start)
+    start "${job}" "${init}"
+    ;;
+stop)
+    stop "${job}"
+    ;;
+clean)
+    clean "${job}"
+    ;;
+fdbcli)
+    "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
+    ;;
+config)
+    generate_regression_config true
+    ;;
+*)
+    unknown_cmd "${cmd}"
+    ;;
 esac
-
--- tools/fdb/fdb_vars.sh.orig
+++ tools/fdb/fdb_vars.sh
@@ -32,14 +32,13 @@
 
 FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
 
-
 # Define the FoundationDB home directory, which contains the fdb binaries and logs.
 # default is /fdbhome and have to be absolute path.
 FDB_HOME="/fdbhome"
 
 # Define the cluster id, shoule be generated random like mktemp -u XXXXXXXX,
 # have to be different for each cluster.
-FDB_CLUSTER_ID=`mktemp -u XXXXXXXX`
+FDB_CLUSTER_ID=$(mktemp -u XXXXXXXX)
 
 # Define the cluster description, you 'd better to change it.
 FDB_CLUSTER_DESC="mycluster"
@@ -61,4 +60,4 @@
 FDB_VERSION="7.1.38"
 
 # Users who run the fdb processes, default is the current user
-USER=`whoami`
+USER=$(whoami)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 5, 2024

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_vars.sh line 26:
DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 34:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 39:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 43:
FDB_CLUSTER_ID=`mktemp -u XXXXXXXX`
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).
               ^------------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
FDB_CLUSTER_ID=$(mktemp -u XXXXXXXX)


In tools/fdb/fdb_vars.sh line 46:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 51:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 54:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 59:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 62:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).

For more information:
  https://www.shellcheck.net/wiki/SC2034 -- CPU_CORES_LIMIT appears unused. V...
  https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctl.sh.orig
+++ tools/fdb/fdb_ctl.sh
@@ -142,7 +142,7 @@
     local data_dir_count
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     data_dir_count=${#DATA_DIR_ARRAY[@]}
 
     # Stateless processes (at least 1, up to 1/4 of CPU cores)
@@ -152,13 +152,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     local storage_processes=$((cpu_cores / 4))
     [[ ${storage_processes} -lt ${data_dir_count} ]] && storage_processes=${data_dir_count}
-    storage_processes=$(( (storage_processes / data_dir_count) * data_dir_count ))
+    storage_processes=$(((storage_processes / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     local transaction_processes=$((cpu_cores / 8))
     [[ ${transaction_processes} -lt ${min_processes} ]] && transaction_processes=${min_processes}
     [[ ${transaction_processes} -lt ${data_dir_count} ]] && transaction_processes=${data_dir_count}
-    transaction_processes=$(( (transaction_processes / data_dir_count) * data_dir_count ))
+    transaction_processes=$(((transaction_processes / data_dir_count) * data_dir_count))
 
     # Return the values
     echo "${stateless_processes} ${storage_processes} ${transaction_processes}"
@@ -175,9 +175,9 @@
     CLUSTER_DESC="${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}"
 
     # Convert comma-separated DATA_DIRS into an array
-    IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
+    IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
     for DIR in "${DATA_DIR_ARRAY[@]}"; do
-         mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
+        mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
     done
 
     echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
@@ -210,13 +210,13 @@
     CPU_CORES_LIMIT=${CPU_CORES_LIMIT:-1}
 
     # Calculate number of processes based on resources and data directories
-    read -r stateless_processes storage_processes transaction_processes <<< "$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
+    read -r stateless_processes storage_processes transaction_processes <<<"$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
 
     # Add stateless processes
     for ((i = 0; i < stateless_processes; i++)); do
         PORT=$((FDB_PORT + i))
         echo "[fdbserver.${PORT}]
-class = stateless" >> "${FDB_HOME}/conf/fdb.conf"
+class = stateless" >>"${FDB_HOME}/conf/fdb.conf"
     done
 
     FDB_PORT=$((FDB_PORT + stateless_processes))
@@ -228,7 +228,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = storage
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + storage_processes))
@@ -239,12 +239,12 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     echo "[backup_agent]
 command = ${FDB_HOME}/backup_agent
-logdir = ${LOG_DIR}" >> "${FDB_HOME}/conf/fdb.conf"
+logdir = ${LOG_DIR}" >>"${FDB_HOME}/conf/fdb.conf"
 
     echo "Deploy FDB to: ${FDB_HOME}"
 }
@@ -278,7 +278,7 @@
 function clean_fdb() {
     if [[ -f "${FDB_HOME}/fdbmonitor.pid" ]]; then
         local fdb_pid
-        
+
         fdb_pid=$(cat "${FDB_HOME}/fdbmonitor.pid")
         if ps -p "${fdb_pid}" >/dev/null; then
             echo "fdbmonitor with pid ${fdb_pid} is running, stop it first."
@@ -326,7 +326,7 @@
     if [[ ${init} =~ ^(all|fdb)$ ]]; then
         echo "Try create database ..."
         local fdb_mode
-        
+
         fdb_mode=$(get_fdb_mode)
         "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" \
             --exec "configure new ${fdb_mode} ssd" || true
@@ -394,26 +394,25 @@
 skip_config="false"
 
 case ${cmd} in
-    deploy)
-        deploy "${job}" "${skip_pkg}" "${skip_config}"
-        ;;
-    start)
-        start "${job}" "${init}"
-        ;;
-    stop)
-        stop "${job}"
-        ;;
-    clean)
-        clean "${job}"
-        ;;
-    fdbcli)
-        "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    *)
-        unknown_cmd "${cmd}"
-        ;;
+deploy)
+    deploy "${job}" "${skip_pkg}" "${skip_config}"
+    ;;
+start)
+    start "${job}" "${init}"
+    ;;
+stop)
+    stop "${job}"
+    ;;
+clean)
+    clean "${job}"
+    ;;
+fdbcli)
+    "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
+    ;;
+config)
+    generate_regression_config true
+    ;;
+*)
+    unknown_cmd "${cmd}"
+    ;;
 esac
-
--- tools/fdb/fdb_vars.sh.orig
+++ tools/fdb/fdb_vars.sh
@@ -33,14 +33,13 @@
 
 FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
 
-
 # Define the FoundationDB home directory, which contains the fdb binaries and logs.
 # default is /fdbhome and have to be absolute path.
 FDB_HOME="/fdbhome"
 
 # Define the cluster id, shoule be generated random like mktemp -u XXXXXXXX,
 # have to be different for each cluster.
-FDB_CLUSTER_ID=`mktemp -u XXXXXXXX`
+FDB_CLUSTER_ID=$(mktemp -u XXXXXXXX)
 
 # Define the cluster description, you 'd better to change it.
 FDB_CLUSTER_DESC="mycluster"
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 5, 2024

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In tools/fdb/fdb_vars.sh line 26:
DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/data3"
^-------^ SC2034 (warning): DATA_DIRS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 34:
FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"
^-------------^ SC2034 (warning): FDB_CLUSTER_IPS appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 38:
FDB_HOME="/fdbhome"
^------^ SC2034 (warning): FDB_HOME appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 42:
FDB_CLUSTER_ID=$(mktemp -u XXXXXXXX)
^------------^ SC2034 (warning): FDB_CLUSTER_ID appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 45:
FDB_CLUSTER_DESC="mycluster"
^--------------^ SC2034 (warning): FDB_CLUSTER_DESC appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 50:
MEMORY_LIMIT_GB=16
^-------------^ SC2034 (warning): MEMORY_LIMIT_GB appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 53:
CPU_CORES_LIMIT=8
^-------------^ SC2034 (warning): CPU_CORES_LIMIT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 58:
FDB_PORT=4500
^------^ SC2034 (warning): FDB_PORT appears unused. Verify use (or export if used externally).


In tools/fdb/fdb_vars.sh line 61:
FDB_VERSION="7.1.38"
^---------^ SC2034 (warning): FDB_VERSION appears unused. Verify use (or export if used externally).

For more information:
  https://www.shellcheck.net/wiki/SC2034 -- CPU_CORES_LIMIT appears unused. V...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctl.sh.orig
+++ tools/fdb/fdb_ctl.sh
@@ -152,13 +152,13 @@
     # Storage processes (must be a multiple of the number of data directories)
     local storage_processes=$((cpu_cores / 4))
     [[ ${storage_processes} -lt ${data_dir_count} ]] && storage_processes=${data_dir_count}
-    storage_processes=$(((storage_processes / data_dir_count) * data_dir_count ))
+    storage_processes=$(((storage_processes / data_dir_count) * data_dir_count))
 
     # Transaction processes (must be a multiple of the number of data directories)
     local transaction_processes=$((cpu_cores / 8))
     [[ ${transaction_processes} -lt ${min_processes} ]] && transaction_processes=${min_processes}
     [[ ${transaction_processes} -lt ${data_dir_count} ]] && transaction_processes=${data_dir_count}
-    transaction_processes=$(((transaction_processes / data_dir_count) * data_dir_count ))
+    transaction_processes=$(((transaction_processes / data_dir_count) * data_dir_count))
 
     # Return the values
     echo "${stateless_processes} ${storage_processes} ${transaction_processes}"
@@ -228,7 +228,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = storage
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + storage_processes))
@@ -239,7 +239,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     echo "[backup_agent]
@@ -278,7 +278,7 @@
 function clean_fdb() {
     if [[ -f "${FDB_HOME}/fdbmonitor.pid" ]]; then
         local fdb_pid
-        
+
         fdb_pid=$(cat "${FDB_HOME}/fdbmonitor.pid")
         if ps -p "${fdb_pid}" >/dev/null; then
             echo "fdbmonitor with pid ${fdb_pid} is running, stop it first."
@@ -326,7 +326,7 @@
     if [[ ${init} =~ ^(all|fdb)$ ]]; then
         echo "Try create database ..."
         local fdb_mode
-        
+
         fdb_mode=$(get_fdb_mode)
         "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" \
             --exec "configure new ${fdb_mode} ssd" || true
@@ -394,26 +394,25 @@
 skip_config="false"
 
 case ${cmd} in
-    deploy)
-        deploy "${job}" "${skip_pkg}" "${skip_config}"
-        ;;
-    start)
-        start "${job}" "${init}"
-        ;;
-    stop)
-        stop "${job}"
-        ;;
-    clean)
-        clean "${job}"
-        ;;
-    fdbcli)
-        "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
-        ;;
-    config)
-        generate_regression_config true
-        ;;
-    *)
-        unknown_cmd "${cmd}"
-        ;;
+deploy)
+    deploy "${job}" "${skip_pkg}" "${skip_config}"
+    ;;
+start)
+    start "${job}" "${init}"
+    ;;
+stop)
+    stop "${job}"
+    ;;
+clean)
+    clean "${job}"
+    ;;
+fdbcli)
+    "${FDB_HOME}/fdbcli" -C "${FDB_HOME}/conf/fdb.cluster" "$@"
+    ;;
+config)
+    generate_regression_config true
+    ;;
+*)
+    unknown_cmd "${cmd}"
+    ;;
 esac
-
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 5, 2024

sh-checker report

To get the full details, please check in the job output.

shellcheck errors
'shellcheck ' found no issues.

shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctl.sh.orig
+++ tools/fdb/fdb_ctl.sh
@@ -228,7 +228,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = storage
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     FDB_PORT=$((FDB_PORT + storage_processes))
@@ -239,7 +239,7 @@
         DIR_INDEX=$((i % STORAGE_DIR_COUNT))
         echo "[fdbserver.${PORT}]
 class = transaction
-datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" |  tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
+datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
     done
 
     echo "[backup_agent]
@@ -278,7 +278,7 @@
 function clean_fdb() {
     if [[ -f "${FDB_HOME}/fdbmonitor.pid" ]]; then
         local fdb_pid
-        
+
         fdb_pid=$(cat "${FDB_HOME}/fdbmonitor.pid")
         if ps -p "${fdb_pid}" >/dev/null; then
             echo "fdbmonitor with pid ${fdb_pid} is running, stop it first."
@@ -416,4 +416,3 @@
     unknown_cmd "${cmd}"
     ;;
 esac
-
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 5, 2024

sh-checker report

To get the full details, please check in the job output.

shellcheck errors
'shellcheck ' found no issues.

shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctl.sh.orig
+++ tools/fdb/fdb_ctl.sh
@@ -278,7 +278,7 @@
 function clean_fdb() {
     if [[ -f "${FDB_HOME}/fdbmonitor.pid" ]]; then
         local fdb_pid
-        
+
         fdb_pid=$(cat "${FDB_HOME}/fdbmonitor.pid")
         if ps -p "${fdb_pid}" >/dev/null; then
             echo "fdbmonitor with pid ${fdb_pid} is running, stop it first."
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 5, 2024

sh-checker report

To get the full details, please check in the job output.

shellcheck errors
'shellcheck ' found no issues.

shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctl.sh.orig
+++ tools/fdb/fdb_ctl.sh
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 5, 2024

sh-checker report

To get the full details, please check in the job output.

shellcheck errors
'shellcheck ' found no issues.

shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- tools/fdb/fdb_ctl.sh.orig
+++ tools/fdb/fdb_ctl.sh
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


@dataroaring
Copy link
Copy Markdown
Contributor Author

run buildall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/3.0.2-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants