Used set to make shell scripts more strict (#3278)

* Use set to make shell scripts more strict

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Change -o pipefail to -e

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>

* Set scripts to standard rule

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
This commit is contained in:
Owais Kazi 2022-05-16 11:05:13 -07:00 committed by GitHub
parent 4886f8e162
commit e73a410139
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 32 additions and 8 deletions

View File

@ -14,7 +14,7 @@
# when we do rebuild the files they don't jump around too much. That # when we do rebuild the files they don't jump around too much. That
# way the diffs are smaller. # way the diffs are smaller.
set -e set -e -o pipefail
script_path="$( cd "$(dirname "$0")" ; pwd -P )" script_path="$( cd "$(dirname "$0")" ; pwd -P )"
work=$(mktemp -d) work=$(mktemp -d)

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e -o pipefail
if [ "$#" -eq 0 ]; then if [ "$#" -eq 0 ]; then
printf 'Usage: %s <origin> <branch> <branch> ...\n' "$(basename "$0")" printf 'Usage: %s <origin> <branch> <branch> ...\n' "$(basename "$0")"

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/usr/bin/env bash
set -e -o pipefail
### Script to check for signoff presents on commits ### Script to check for signoff presents on commits

View File

@ -1,4 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e -o pipefail
cd /usr/share/opensearch/bin/ cd /usr/share/opensearch/bin/
/usr/local/bin/docker-entrypoint.sh | tee > /usr/share/opensearch/logs/console.log /usr/local/bin/docker-entrypoint.sh | tee > /usr/share/opensearch/logs/console.log

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e -o pipefail
# Files created by Elasticsearch should always be group writable too # Files created by Elasticsearch should always be group writable too
umask 0002 umask 0002

View File

@ -10,6 +10,8 @@
# $1=1 : indicates an new install # $1=1 : indicates an new install
# $1=2 : indicates an upgrade # $1=2 : indicates an upgrade
set -e -o pipefail
err_exit() { err_exit() {
echo "$@" >&2 echo "$@" >&2
exit 1 exit 1

View File

@ -3,6 +3,8 @@
# This wrapper script allows SystemD to feed a file containing a passphrase into # This wrapper script allows SystemD to feed a file containing a passphrase into
# the main OpenSearch startup script # the main OpenSearch startup script
set -e -o pipefail
if [ -n "$OPENSEARCH_KEYSTORE_PASSPHRASE_FILE" ] ; then if [ -n "$OPENSEARCH_KEYSTORE_PASSPHRASE_FILE" ] ; then
exec /usr/share/opensearch/bin/opensearch "$@" < "$OPENSEARCH_KEYSTORE_PASSPHRASE_FILE" exec /usr/share/opensearch/bin/opensearch "$@" < "$OPENSEARCH_KEYSTORE_PASSPHRASE_FILE"
else else

View File

@ -12,6 +12,8 @@
# Description: Starts opensearch using start-stop-daemon # Description: Starts opensearch using start-stop-daemon
### END INIT INFO ### END INIT INFO
set -e -o pipefail
PATH=/bin:/usr/bin:/sbin:/usr/sbin PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=opensearch NAME=opensearch
DESC="OpenSearch Server" DESC="OpenSearch Server"

View File

@ -16,6 +16,8 @@
# Description: OpenSearch is a very scalable, schema-free and high-performance search solution supporting multi-tenancy and near realtime search. # Description: OpenSearch is a very scalable, schema-free and high-performance search solution supporting multi-tenancy and near realtime search.
### END INIT INFO ### END INIT INFO
set -e -o pipefail
# #
# init.d / servicectl compatibility (openSUSE) # init.d / servicectl compatibility (openSUSE)
# #

View File

@ -13,6 +13,8 @@
# #
# OPENSEARCH_JAVA_OPTS="-Xms8g -Xmx8g" ./bin/opensearch # OPENSEARCH_JAVA_OPTS="-Xms8g -Xmx8g" ./bin/opensearch
set -e -o pipefail
source "`dirname "$0"`"/opensearch-env source "`dirname "$0"`"/opensearch-env
CHECK_KEYSTORE=true CHECK_KEYSTORE=true

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e -o pipefail
OPENSEARCH_MAIN_CLASS=org.opensearch.common.settings.KeyStoreCli \ OPENSEARCH_MAIN_CLASS=org.opensearch.common.settings.KeyStoreCli \
OPENSEARCH_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/keystore-cli \ OPENSEARCH_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/keystore-cli \
"`dirname "$0"`"/opensearch-cli \ "`dirname "$0"`"/opensearch-cli \

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e -o pipefail
OPENSEARCH_MAIN_CLASS=org.opensearch.cluster.coordination.NodeToolCli \ OPENSEARCH_MAIN_CLASS=org.opensearch.cluster.coordination.NodeToolCli \
"`dirname "$0"`"/opensearch-cli \ "`dirname "$0"`"/opensearch-cli \

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e -o pipefail
OPENSEARCH_MAIN_CLASS=org.opensearch.plugins.PluginCli \ OPENSEARCH_MAIN_CLASS=org.opensearch.plugins.PluginCli \
OPENSEARCH_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/plugin-cli \ OPENSEARCH_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/plugin-cli \
"`dirname "$0"`"/opensearch-cli \ "`dirname "$0"`"/opensearch-cli \

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e -o pipefail
OPENSEARCH_MAIN_CLASS=org.opensearch.index.shard.ShardToolCli \ OPENSEARCH_MAIN_CLASS=org.opensearch.index.shard.ShardToolCli \
"`dirname "$0"`"/opensearch-cli \ "`dirname "$0"`"/opensearch-cli \
"$@" "$@"

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e -o pipefail
OPENSEARCH_MAIN_CLASS=org.opensearch.upgrade.UpgradeCli \ OPENSEARCH_MAIN_CLASS=org.opensearch.upgrade.UpgradeCli \
OPENSEARCH_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/upgrade-cli \ OPENSEARCH_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/upgrade-cli \

View File

@ -1,4 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e -o pipefail
cd /usr/share/opensearch/bin/ cd /usr/share/opensearch/bin/
./opensearch-users useradd rest_user -p test-password -r superuser || true ./opensearch-users useradd rest_user -p test-password -r superuser || true
echo "testnode" > /tmp/password echo "testnode" > /tmp/password

View File

@ -17,7 +17,7 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
set -e set -e -o pipefail
krb5kdc krb5kdc
kadmind kadmind

View File

@ -10,7 +10,7 @@
# GitHub history for details. # GitHub history for details.
# #
set -e set -e -o pipefail
addprinc.sh "opensearch" addprinc.sh "opensearch"
#TODO(OpenSearch): fix username #TODO(OpenSearch): fix username

View File

@ -29,7 +29,7 @@
# GitHub history for details. # GitHub history for details.
# #
set -e set -e -o pipefail
# KDC installation steps and considerations based on https://web.mit.edu/kerberos/krb5-latest/doc/admin/install_kdc.html # KDC installation steps and considerations based on https://web.mit.edu/kerberos/krb5-latest/doc/admin/install_kdc.html
# and helpful input from https://help.ubuntu.com/community/Kerberos # and helpful input from https://help.ubuntu.com/community/Kerberos

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e -o pipefail
addprinc.sh opensearch addprinc.sh opensearch
addprinc.sh HTTP/localhost addprinc.sh HTTP/localhost