chore(shellcheck): fix shellcheck linting warnings

This commit is contained in:
Thales Macedo Garitezi 2021-12-22 15:07:23 -03:00
parent e137555052
commit 014b6d3cfd
No known key found for this signature in database
GPG Key ID: DD279F8152A9B6DD
8 changed files with 44 additions and 18 deletions

View File

@ -5,8 +5,8 @@ if [ "$DEBUG" -eq 1 ]; then
set -x
fi
ROOT_DIR="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"/..; pwd -P)"
# shellcheck disable=SC1090
ROOT_DIR="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"/.. || exit 1; pwd -P)"
# shellcheck disable=SC1090,SC1091
. "$ROOT_DIR"/releases/emqx_vars
# defined in emqx_vars
@ -14,15 +14,16 @@ export RUNNER_ROOT_DIR
export RUNNER_ETC_DIR
export REL_VSN
RUNNER_SCRIPT="$RUNNER_BIN_DIR/$REL_NAME"
CODE_LOADING_MODE="${CODE_LOADING_MODE:-embedded}"
REL_DIR="$RUNNER_ROOT_DIR/releases/$REL_VSN"
SCHEMA_MOD=emqx_conf_schema
export RUNNER_SCRIPT="$RUNNER_BIN_DIR/$REL_NAME"
export CODE_LOADING_MODE="${CODE_LOADING_MODE:-embedded}"
export REL_DIR="$RUNNER_ROOT_DIR/releases/$REL_VSN"
export SCHEMA_MOD=emqx_conf_schema
WHOAMI=$(whoami)
export WHOAMI
# Make sure data/configs exists
CONFIGS_DIR="$RUNNER_DATA_DIR/configs"
export CONFIGS_DIR="$RUNNER_DATA_DIR/configs"
# hocon try to read environment variables starting with "EMQX_"
export HOCON_ENV_OVERRIDE_PREFIX='EMQX_'
@ -33,7 +34,7 @@ export BINDIR="$ERTS_DIR/bin"
export EMU="beam"
export PROGNAME="erl"
export ERTS_LIB_DIR="$ERTS_DIR/../lib"
DYNLIBS_DIR="$RUNNER_ROOT_DIR/dynlibs"
export DYNLIBS_DIR="$RUNNER_ROOT_DIR/dynlibs"
## backward compatible
if [ -d "$ERTS_DIR/lib" ]; then
@ -56,5 +57,6 @@ SED_REPLACE="sed -i "
case $(sed --help 2>&1) in
*GNU*) SED_REPLACE="sed -i ";;
*BusyBox*) SED_REPLACE="sed -i ";;
*) SED_REPLACE="sed -i '' ";;
*) SED_REPLACE=(sed -i '' );;
esac
export SED_REPLACE

View File

@ -7,6 +7,9 @@
## they require the variable `IS_BOOT_COMMAND` to be set to either
## `yes` or `no` for the name definition to be done properly.
## This should be sourced after the calling script has define the
## `$COMMAND` variable.
## make EMQX_NODE_COOKIE right
if [ -n "${EMQX_NODE_NAME:-}" ]; then
export EMQX_NODE__NAME="${EMQX_NODE_NAME}"
@ -22,7 +25,7 @@ NAME="${EMQX_NODE__NAME:-}"
if [ -z "$NAME" ]; then
if [ "$IS_BOOT_COMMAND" = 'yes' ]; then
# for boot commands, inspect emqx.conf for node name
NAME="$(call_hocon -s $SCHEMA_MOD -I "$CONFIGS_DIR/" -c "$RUNNER_ETC_DIR"/emqx.conf get node.name | tr -d \")"
NAME="$(call_hocon -s "$SCHEMA_MOD" -I "$CONFIGS_DIR/" -c "$RUNNER_ETC_DIR"/emqx.conf get node.name | tr -d \")"
else
vm_args_file="$(latest_vm_args 'EMQX_NODE__NAME')"
NAME="$(grep -E '^-s?name' "${vm_args_file}" | awk '{print $2}')"
@ -31,7 +34,7 @@ fi
# force to use 'emqx' short name
[ -z "$NAME" ] && NAME='emqx'
MNESIA_DATA_DIR="$RUNNER_DATA_DIR/mnesia/$NAME"
export MNESIA_DATA_DIR="$RUNNER_DATA_DIR/mnesia/$NAME"
case "$NAME" in
*@*)
@ -40,6 +43,7 @@ case "$NAME" in
*)
NAME_TYPE='-sname'
esac
export NAME_TYPE
SHORT_NAME="$(echo "$NAME" | awk -F'@' '{print $1}')"
export ESCRIPT_NAME="$SHORT_NAME"
@ -53,7 +57,7 @@ fi
COOKIE="${EMQX_NODE__COOKIE:-}"
if [ -z "$COOKIE" ]; then
if [ "$IS_BOOT_COMMAND" = 'yes' ]; then
COOKIE="$(call_hocon -s $SCHEMA_MOD -I "$CONFIGS_DIR/" -c "$RUNNER_ETC_DIR"/emqx.conf get node.cookie | tr -d \")"
COOKIE="$(call_hocon -s "$SCHEMA_MOD" -I "$CONFIGS_DIR/" -c "$RUNNER_ETC_DIR"/emqx.conf get node.cookie | tr -d \")"
else
vm_args_file="$(latest_vm_args 'EMQX_NODE__COOKIE')"
COOKIE="$(grep -E '^-setcookie' "${vm_args_file}" | awk '{print $2}')"

View File

@ -60,6 +60,7 @@ relx_rem_sh() {
TICKTIME="$(relx_nodetool rpcterms net_kernel get_net_ticktime)"
# shellcheck disable=SC2086 # $EPMD_ARG is supposed to be split by whitespace
# shellcheck disable=SC2153 # $NAME_TYPE is defined by `common_defs2.sh`, which runs before this is called
# Setup remote shell command to control node
exec "$BINDIR/erl" "$NAME_TYPE" "$id" -remsh "$NAME" -boot "$REL_DIR/start_clean" \
-boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
@ -90,7 +91,9 @@ relx_escript() {
"$ERTS_DIR/bin/escript" "$ROOTDIR/$scriptpath" "$@"
}
# Output a start command for the last argument of run_erl
# Output a start command for the last argument of run_erl.
# The calling script defines `$START_OPTION`, when the command is to
# start EMQX in the background.
relx_start_command() {
printf "exec \"%s\" \"%s\"" "$RUNNER_SCRIPT" \
"$START_OPTION"
@ -128,6 +131,7 @@ generate_config() {
# This is needed by the Elixir scripts.
# Do NOT append `.config`.
RELEASE_SYS_CONFIG="$CONFIGS_DIR/app.$NOW_TIME"
export RELEASE_SYS_CONFIG
CONFIG_ARGS="-config $CONF_FILE -args_file $HOCON_GEN_ARG_FILE"
@ -212,6 +216,7 @@ latest_vm_args() {
echo "$vm_args_file"
else
echoerr "node not initialized?"
# shellcheck disable=SC2153 # $COMMAND is defined by the calling script
echoerr "Generated config file vm.*.args is not found for command '$COMMAND'"
echoerr "in config dir: $CONFIGS_DIR"
echoerr "In case the file has been deleted while the node is running,"

View File

@ -5,7 +5,9 @@
set -euo pipefail
BASE="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"/..; pwd -P)"
# shellcheck disable=SC1090,SC1091
source "$BASE/bin/common_defs.sh"
# shellcheck disable=SC1090,SC1091
source "$BASE/bin/common_functions.sh"
# Make sure log directory exists
@ -182,7 +184,9 @@ case "${COMMAND}" in
IS_BOOT_COMMAND='no'
;;
esac
export IS_BOOT_COMMAND
# shellcheck disable=SC1090,SC1091
source "$BASE/bin/common_defs2.sh"
cd "$ROOTDIR"
@ -205,6 +209,7 @@ case "${COMMAND}" in
HEART_OPTION="start"
;;
esac
export START_OPTION
RUN_PARAM="$*"
# Set arguments for the heart command

View File

@ -1,10 +1,11 @@
#!/bin/sh
set -eu
# shellcheck disable=SC1090,SC1091
ROOT_DIR="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"/..; pwd -P)"
echo "Running node dump in ${ROOT_DIR}"
# shellcheck disable=SC1090
# shellcheck disable=SC1090,SC1091
. "$ROOT_DIR"/releases/emqx_vars
cd "${ROOT_DIR}"

View File

@ -1,6 +1,4 @@
#!/bin/bash
# shellcheck disable=SC1000-SC9999
set -ex
mix release --overwrite

View File

@ -5,7 +5,9 @@
set -euo pipefail
BASE="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"/..; pwd -P)"
# shellcheck disable=SC1090,SC1091
source "$BASE/bin/common_defs.sh"
# shellcheck disable=SC1090,SC1091
source "$BASE/bin/common_functions.sh"
# Make sure log directory exists
@ -30,12 +32,14 @@ case "${COMMAND}" in
IS_BOOT_COMMAND='no'
;;
esac
export IS_BOOT_COMMAND
# shellcheck disable=SC1090,SC1091
source "$BASE/bin/common_defs2.sh"
cd "$ROOTDIR"
# FIXME!!!
# FIXME!!! Create case for commands.
generate_config "$NAME_TYPE" "$NAME"
# Must be explicitly exported here in order to be picked up correctly
export RELEASE_SYS_CONFIG

View File

@ -3,7 +3,14 @@
set -euo pipefail
target_files=()
while IFS='' read -r line; do target_files+=("$line"); done < <(grep -r -l --exclude-dir=.git --exclude-dir=_build "#!/bin/" .)
while IFS='' read -r line;
do
target_files+=("$line");
done < <(grep -r -l \
--exclude-dir=.git \
--exclude-dir=_build \
--exclude-dir=deps \
"^#!/bin/" .)
return_code=0
for i in "${target_files[@]}"; do
echo checking "$i" ...