Skip to content

Commit

Permalink
Some additional fixes to partial config handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwalker committed Jan 18, 2019
1 parent 5add0c9 commit 59e4835
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
17 changes: 10 additions & 7 deletions priv/libexec/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@ get_vmargs_path() {
if [ -z "$VMARGS_PATH" ]; then
if [ -f "$RELEASE_MUTABLE_DIR/vm.args" ]; then
echo "$RELEASE_MUTABLE_DIR/vm.args"
return 0
fi
if [ -f "$RELEASE_CONFIG_DIR/vm.args" ]; then
echo "$RELEASE_CONFIG_DIR/vm.args"
return 0
fi
else
echo "$VMARGS_PATH"
return 0
fi

return 1
echo ""
}

# We're expecting that the real configs have been generated at
Expand All @@ -42,6 +39,9 @@ partial_configure_release() {
export SYS_CONFIG_PATH="$RELEASE_CONFIG_DIR/sys.config"
fi
fi

# Set up the node based on the new configuration
_configure_node
}

# Sets config paths for sys.config and vm.args, and ensures that env var replacements are performed
Expand Down Expand Up @@ -236,7 +236,7 @@ _configure_node() {

# We need to detect configuration from vm.args
vmargs="$(get_vmargs_path)"
if !$?; then
if [ -z "$vmargs" ]; then
fail "Unable to load vm.args and NAME is not exported, unable to configure node!"
fi

Expand All @@ -256,6 +256,9 @@ _configure_node() {
# NAME will be either `somename` or `somename@somehost`
export NAME
NAME="$(echo "$NAME_ARG" | awk '{print $2}' | tail -n 1)"
if [ -z "$NAME" ]; then
fail "Invalid $NAME_TYPE value in vm.args, value is empty!"
fi

# User can specify an sname without @hostname
# This will fail when creating remote shell
Expand Down Expand Up @@ -298,8 +301,8 @@ _load_cookie() {
if [ ! -z "$COOKIE" ]; then
return 0
fi
vmargs=""
if ! vmargs="$(get_vmargs_path)"; then
vmargs="$(get_vmargs_path)"
if [ -z "$vmargs" ]; then
return 1
fi
COOKIE_ARG="$(_replace_os_vars_str "${vmargs}" | grep '^-setcookie' || true)"
Expand Down
5 changes: 0 additions & 5 deletions priv/libexec/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ RUN_ERL_DISABLE_FLOWCNTRL="${RUN_ERL_DISABLE_FLOWCNTRL:-true}"
# VM code loading mode, embedded by default, can also be interactive
# See http://erlang.org/doc/man/code.html
CODE_LOADING_MODE="${CODE_LOADING_MODE:-embedded}"
# Path to start_erl.data
START_ERL_DATA="${START_ERL_DATA:-$RELEASE_ROOT_DIR/releases/start_erl.data}"
# Directory containing the current version of this release
export REL_DIR
REL_DIR="${REL_DIR:-$RELEASE_ROOT_DIR/releases/$REL_VSN}"
# The lib directory for this release
REL_LIB_DIR="${REL_LIB_DIR:-$RELEASE_ROOT_DIR/lib}"
# The location of generated files and other mutable state
Expand Down
5 changes: 5 additions & 0 deletions priv/templates/release_rc_main.eex
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@ SCRIPT_DIR="$(dirname "${SCRIPT}")"
RELEASE_ROOT_DIR="${RELEASE_ROOT_DIR:-$(dirname "$(dirname "${SCRIPT_DIR}")")}"
# Directory containing the current version of this release
REL_DIR="${REL_DIR:-$RELEASE_ROOT_DIR/releases/$REL_VSN}"
export REL_DIR
# The location of builtin command scripts
RELEASE_LIBEXEC_DIR="$SCRIPT_DIR/libexec"
# The location of consolidated protocol .beams
CONSOLIDATED_DIR="${RELEASE_ROOT_DIR}/lib/${REL_NAME}-${REL_VSN}/consolidated"
export CONSOLIDATED_DIR
# Path to start_erl.data
START_ERL_DATA="${START_ERL_DATA:-$RELEASE_ROOT_DIR/releases/start_erl.data}"
export START_ERL_DATA

# shellcheck source=../libexec/readlink.sh
. "$RELEASE_LIBEXEC_DIR/readlink.sh"
Expand Down Expand Up @@ -133,6 +137,7 @@ case $COMMAND_NAME in
# If the command exists in libexec, execute
# Otherwise check to see if it's the name of a custom command
if [ -f "$COMMAND_PATH" ]; then
partial_configure_release
. "$COMMAND_PATH" "$@"
else
COMMAND_PATH="$REL_DIR/commands/$COMMAND_NAME.sh"
Expand Down

0 comments on commit 59e4835

Please sign in to comment.