Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added shell script checker #198

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/code-hygiene.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ jobs:

- name: Linelint
uses: fernandrone/[email protected]
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
ignore_paths: ./gradlew
11 changes: 6 additions & 5 deletions client/sniffer/src/test/resources/create_test_nodes_info.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions distribution/packages/src/deb/init.d/opensearch
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,6 +59,7 @@ PID_DIR="/var/run/opensearch"

# overwrite settings from default file
if [ -f "$DEFAULT" ]; then
# shellcheck source=/dev/null
. "$DEFAULT"
fi

Expand Down Expand Up @@ -105,7 +106,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" ] && [ -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

Expand All @@ -116,7 +117,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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,10 @@ USER=$(echo $PRINC | tr "/" "_")

VDIR=/fixture
RESOURCES=$VDIR/src/main/resources
PROV_DIR=$RESOURCES/provision
ENVPROP_FILE=$RESOURCES/env.properties
BUILD_DIR=$VDIR/build
CONF_DIR=$BUILD_DIR/conf
KEYTAB_DIR=$BUILD_DIR/keytabs
LOCALSTATEDIR=/etc
LOGDIR=/var/log/krb5

mkdir -p $KEYTAB_DIR

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ ENVPROP_FILE=$RESOURCES/env.properties
LOCALSTATEDIR=/etc
LOGDIR=/var/log/krb5

MARKER_FILE=/etc/marker

# Pull environment information
REALM_NAME=$(cat $ENVPROP_FILE | grep realm= | cut -d '=' -f 2)
Expand Down