You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wi...@apache.org on 2019/12/11 14:58:31 UTC

[couchdb] 02/02: Remsh: attempt to auto-locate Erlang cookie

This is an automated email from the ASF dual-hosted git repository.

willholley pushed a commit to branch remsh
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 484200bf1ce9a76227c6b7622c39a97495d094d2
Author: Will Holley <wi...@gmail.com>
AuthorDate: Wed Dec 11 14:56:27 2019 +0000

    Remsh: attempt to auto-locate Erlang cookie
    
    Attempts to find the Erlang cookie from ERL_FLAGS or the
    standard vm.args location. If not present, fall back to the default
    (monster).
---
 rel/overlay/bin/remsh | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/rel/overlay/bin/remsh b/rel/overlay/bin/remsh
index a02fd5d..2444331 100755
--- a/rel/overlay/bin/remsh
+++ b/rel/overlay/bin/remsh
@@ -23,8 +23,19 @@ BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
 PROGNAME=${0##*/}
 VERBOSE=""
 NODE="couchdb@127.0.0.1"
-COOKIE=monster
 LHOST=127.0.0.1
+VM_ARGS=$COUCHDB_BIN_DIR/../etc/vm.args
+
+# If present, extract cookie from ERL_FLAGS
+# This is used by the CouchDB Dockerfile and Helm chart
+kCOOKIE_REGEX='setcookie ([^ ]+)'
+if [[ $ERL_FLAGS =~ $kCOOKIE_REGEX ]]; then
+  COOKIE="${BASH_REMATCH[1]}"
+elif test -f $VM_ARGS; then
+# else attempt to extract from vm.args
+  COOKIE=$(awk '$1=="-setcookie"{print $2}' $VM_ARGS)
+fi
+COOKIE="${COOKIE:-monster}"
 
 printHelpAndExit() {
   echo "Usage: ${PROGNAME} [OPTION]... [-- <additional Erlang cli options>]"