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

[Backport 2.x] Used set to make shell scripts more strict #3344

Merged
merged 1 commit into from
May 16, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# when we do rebuild the files they don't jump around too much. That
# way the diffs are smaller.

set -e
set -e -o pipefail

script_path="$( cd "$(dirname "$0")" ; pwd -P )"
work=$(mktemp -d)
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/atomic_push.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
set -e -o pipefail

if [ "$#" -eq 0 ]; then
printf 'Usage: %s <origin> <branch> <branch> ...\n' "$(basename "$0")"
Expand Down
4 changes: 3 additions & 1 deletion dev-tools/signoff-check.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh
#!/usr/bin/env bash

set -e -o pipefail

### Script to check for signoff presents on commits

Expand Down
2 changes: 2 additions & 0 deletions distribution/docker/docker-test-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env bash
set -e -o pipefail

cd /usr/share/opensearch/bin/

/usr/local/bin/docker-entrypoint.sh | tee > /usr/share/opensearch/logs/console.log
2 changes: 1 addition & 1 deletion distribution/docker/src/docker/bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
set -e -o pipefail

# Files created by Elasticsearch should always be group writable too
umask 0002
Expand Down
2 changes: 2 additions & 0 deletions distribution/packages/src/common/scripts/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# $1=1 : indicates an new install
# $1=2 : indicates an upgrade

set -e -o pipefail

err_exit() {
echo "$@" >&2
exit 1
Expand Down
2 changes: 2 additions & 0 deletions distribution/packages/src/common/systemd/systemd-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# This wrapper script allows SystemD to feed a file containing a passphrase into
# the main OpenSearch startup script

set -e -o pipefail

if [ -n "$OPENSEARCH_KEYSTORE_PASSPHRASE_FILE" ] ; then
exec /usr/share/opensearch/bin/opensearch "$@" < "$OPENSEARCH_KEYSTORE_PASSPHRASE_FILE"
else
Expand Down
2 changes: 2 additions & 0 deletions distribution/packages/src/deb/init.d/opensearch
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Description: Starts opensearch using start-stop-daemon
### END INIT INFO

set -e -o pipefail

PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=opensearch
DESC="OpenSearch Server"
Expand Down
2 changes: 2 additions & 0 deletions distribution/packages/src/rpm/init.d/opensearch
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# Description: OpenSearch is a very scalable, schema-free and high-performance search solution supporting multi-tenancy and near realtime search.
### END INIT INFO

set -e -o pipefail

#
# init.d / servicectl compatibility (openSUSE)
#
Expand Down
2 changes: 2 additions & 0 deletions distribution/src/bin/opensearch
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#
# OPENSEARCH_JAVA_OPTS="-Xms8g -Xmx8g" ./bin/opensearch

set -e -o pipefail

source "`dirname "$0"`"/opensearch-env

CHECK_KEYSTORE=true
Expand Down
2 changes: 2 additions & 0 deletions distribution/src/bin/opensearch-keystore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

set -e -o pipefail

OPENSEARCH_MAIN_CLASS=org.opensearch.common.settings.KeyStoreCli \
OPENSEARCH_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/keystore-cli \
"`dirname "$0"`"/opensearch-cli \
Expand Down
1 change: 1 addition & 0 deletions distribution/src/bin/opensearch-node
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -e -o pipefail

OPENSEARCH_MAIN_CLASS=org.opensearch.cluster.coordination.NodeToolCli \
"`dirname "$0"`"/opensearch-cli \
Expand Down
2 changes: 2 additions & 0 deletions distribution/src/bin/opensearch-plugin
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

set -e -o pipefail

OPENSEARCH_MAIN_CLASS=org.opensearch.plugins.PluginCli \
OPENSEARCH_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/plugin-cli \
"`dirname "$0"`"/opensearch-cli \
Expand Down
2 changes: 2 additions & 0 deletions distribution/src/bin/opensearch-shard
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

set -e -o pipefail

OPENSEARCH_MAIN_CLASS=org.opensearch.index.shard.ShardToolCli \
"`dirname "$0"`"/opensearch-cli \
"$@"
1 change: 1 addition & 0 deletions distribution/src/bin/opensearch-upgrade
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -e -o pipefail

OPENSEARCH_MAIN_CLASS=org.opensearch.upgrade.UpgradeCli \
OPENSEARCH_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/upgrade-cli \
Expand Down
2 changes: 2 additions & 0 deletions qa/remote-clusters/docker-test-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env bash
set -e -o pipefail

cd /usr/share/opensearch/bin/
./opensearch-users useradd rest_user -p test-password -r superuser || true
echo "testnode" > /tmp/password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# specific language governing permissions and limitations
# under the License.

set -e
set -e -o pipefail

krb5kdc
kadmind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# GitHub history for details.
#

set -e
set -e -o pipefail

addprinc.sh "opensearch"
#TODO(OpenSearch): fix username
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# 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
# and helpful input from https://help.ubuntu.com/community/Kerberos
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -e
set -e -o pipefail

addprinc.sh opensearch
addprinc.sh HTTP/localhost
Expand Down