diff --git a/.github/workflows/code-hygiene.yml b/.github/workflows/code-hygiene.yml index cf5fc97cb119c..2c0181d0960d8 100644 --- a/.github/workflows/code-hygiene.yml +++ b/.github/workflows/code-hygiene.yml @@ -12,12 +12,12 @@ jobs: - name: Linelint uses: fernandrone/linelint@0.0.4 - shellcheck: - name: Shellcheck - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Run ShellCheck - uses: ludeeus/action-shellcheck@master - with: - ignore_paths: "*/gradlew" + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + ignore_paths: "*/gradlew" diff --git a/client/sniffer/src/test/resources/create_test_nodes_info.bash b/client/sniffer/src/test/resources/create_test_nodes_info.bash index 78e67562d815b..ab58eadc20738 100644 --- a/client/sniffer/src/test/resources/create_test_nodes_info.bash +++ b/client/sniffer/src/test/resources/create_test_nodes_info.bash @@ -38,17 +38,18 @@ function do_version() { tar xf ../opensearch-min-${version}-linux-x64.tar.gz local http_port=9200 + local cluster_manager initial_cluster_manager_nodes data for node in ${nodes}; do mkdir ${node} cp -r opensearch-${version}/* ${node} - local cluster_manager=$([[ "$node" =~ ^m.* ]] && echo 'cluster_manager,' || echo '') + cluster_manager=$([[ "$node" =~ ^m.* ]] && echo 'cluster_manager,' || echo '') # 'cluster_manager' role is add in version 2.x and above, use 'master' role in 1.x cluster_manager=$([[ ! "$cluster_manager" == '' && ${version} =~ ^1\. ]] && echo 'master,' || echo ${cluster_manager}) - local data=$([[ "$node" =~ ^d.* ]] && echo 'data,' || echo '') + data=$([[ "$node" =~ ^d.* ]] && echo 'data,' || echo '') # m2 is always cluster_manager and data for these test just so we have a node like that data=$([[ "$node" == 'm2' ]] && echo 'data,' || echo ${data}) # setting name 'cluster.initial_cluster_manager_nodes' is add in version 2.x and above - local initial_cluster_manager_nodes=$([[ ${version} =~ ^1\. ]] && echo 'initial_master_nodes' || echo 'initial_cluster_manager_nodes') + initial_cluster_manager_nodes=$([[ ${version} =~ ^1\. ]] && echo 'initial_master_nodes' || echo 'initial_cluster_manager_nodes') local transport_port=$((http_port+100)) cat >> ${node}/config/opensearch.yml << __OPENSEARCH_YML @@ -79,7 +80,7 @@ __OPENSEARCH_YML done echo "waiting for all nodes to join" - until [ $(echo ${nodes} | wc -w) -eq $(curl -s localhost:9200/_cat/nodes | wc -l) ]; do + until [ "$(echo ${nodes} | wc -w)" -eq "$(curl -s localhost:9200/_cat/nodes | wc -l)" ]; do sleep .25 done @@ -90,7 +91,7 @@ __OPENSEARCH_YML for node in ${nodes}; do echo "stopping ${version}/${node}..." - kill $(cat ${node}/pidfile) + kill "$(cat ${node}/pidfile)" done popd >> /dev/null diff --git a/distribution/packages/src/deb/init.d/opensearch b/distribution/packages/src/deb/init.d/opensearch index 681d87df1d356..60f7610c0dfcf 100755 --- a/distribution/packages/src/deb/init.d/opensearch +++ b/distribution/packages/src/deb/init.d/opensearch @@ -19,7 +19,7 @@ NAME=opensearch DESC="OpenSearch Server" DEFAULT=/etc/default/$NAME -if [ `id -u` -ne 0 ]; then +if [ "`id -u`" -ne 0 ]; then echo "You need root privileges to run this script" exit 1 fi @@ -105,7 +105,7 @@ case "$1" in ulimit -l $MAX_LOCKED_MEMORY fi - if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ] && [ "$MAX_MAP_COUNT" -gt $(cat /proc/sys/vm/max_map_count) ]; then + if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ] && [ "$MAX_MAP_COUNT" -gt "$(cat /proc/sys/vm/max_map_count)" ]; then sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT fi @@ -116,7 +116,7 @@ case "$1" in i=0 timeout=10 # Wait for the process to be properly started before exiting - until { kill -0 `cat "$PID_FILE"`; } >/dev/null 2>&1 + until { kill -0 "`cat "$PID_FILE"`"; } >/dev/null 2>&1 do sleep 1 i=$(($i + 1))