Skip to content

Commit

Permalink
Fix -sname support
Browse files Browse the repository at this point in the history
-sname support was not working in all cases (e.g. bitwalker#699).
This fixes at least the things mentioned in the above issue.
  • Loading branch information
nifoc committed Aug 26, 2019
1 parent b7805d2 commit f4ee4bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions priv/libexec/commands/remote_console.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require_live_node

# Generate a unique id used to allow multiple remsh to the same node
# transparently
id="remsh$(gen_id)-${NAME}"
id="remsh$(gen_id)-${OLD_NAME}"

# Get the node's ticktime so that we use the same thing.
TICKTIME="$(release_remote_ctl rpc ':net_kernel.get_net_ticktime()')"
Expand All @@ -19,13 +19,13 @@ if [ ! -z "$USE_ERL_SHELL" ]; then
erl -hidden \
-kernel logger_level warning \
-kernel net_ticktime "$TICKTIME" \
"$NAME_TYPE" "$id" \
"$OLD_NAME_TYPE" "$id" \
-remsh "$NAME" \
-setcookie "$COOKIE"
else
iex --erl "-hidden -kernel net_ticktime $TICKTIME" \
--logger-sasl-reports false \
-"$NAME_TYPE" "$id" \
-"$OLD_NAME_TYPE" "$id" \
--cookie "$COOKIE" \
--remsh "$NAME"
fi
9 changes: 7 additions & 2 deletions priv/libexec/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ _configure_node() {
fail "Invalid $NAME_TYPE value in vm.args, value is empty!"
fi

# Save some of the old configuration values, so that they can be reused (e.g. in remote_console)
export OLD_NAME
OLD_NAME="$NAME"
export OLD_NAME_TYPE
OLD_NAME_TYPE="$NAME_TYPE"

# User can specify an sname without @hostname
# This will fail when creating remote shell
# So here we check for @ and add @hostname if missing
Expand All @@ -277,9 +283,8 @@ _configure_node() {
fi
;;
*)
if [ "$NAME_TYPE" != "-sname" ]; then
if [ "$NAME_TYPE" = "-sname" ]; then
HOSTNAME="$(get_hostname)"
OLD_NAME="$NAME"
NAME="$NAME@$HOSTNAME"
NAME_TYPE="-name"
notice "Automatically converted short name ($OLD_NAME) to long name ($NAME)!"
Expand Down

0 comments on commit f4ee4bd

Please sign in to comment.