You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wo...@apache.org on 2020/04/22 20:15:28 UTC

[couchdb] 01/01: Replace VM_ARGS with ARGS_FILE which is set as it is in couchdb script /etc/vm.args; also parses name from config. (#2738)

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

wohali pushed a commit to branch remsh-improvement-3.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit e9d2ca9b470b42e5eba2d15a31553924505a1b85
Author: Simon Klassen <69...@users.noreply.github.com>
AuthorDate: Thu Apr 23 04:14:25 2020 +0800

    Replace VM_ARGS with ARGS_FILE which is set as it is in couchdb script /etc/vm.args; also parses name from config. (#2738)
    
    Co-authored-by: sklassen <none>
    Co-authored-by: Joan Touzet <wo...@users.noreply.github.com>
---
 rel/overlay/bin/remsh | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/rel/overlay/bin/remsh b/rel/overlay/bin/remsh
index c5e932a..d1fcdd9 100755
--- a/rel/overlay/bin/remsh
+++ b/rel/overlay/bin/remsh
@@ -32,17 +32,28 @@ BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
 
 PROGNAME=${0##*/}
 VERBOSE=""
-NODE="couchdb@127.0.0.1"
+DEFAULT_NODE="couchdb@127.0.0.1"
 LHOST=127.0.0.1
-VM_ARGS=$COUCHDB_BIN_DIR/../etc/vm.args
+
+ARGS_FILE="${COUCHDB_ARGS_FILE:-$ROOTDIR/etc/vm.args}"
+
+# If present, extract cookie from ERL_FLAGS
+# This is used by the CouchDB Dockerfile and Helm chart
+NODE=$(echo "$ERL_FLAGS" | sed 's/^.*name \([^ ][^ ]*\).*$/\1/g')
+if test -f "$ARGS_FILE"; then
+# else attempt to extract from vm.args
+  ARGS_FILE_COOKIE=$(awk '$1=="-name"{print $2}' "$ARGS_FILE")
+  NODE="${NODE:-$ARGS_FILE_COOKIE}"
+fi
+NODE="${NODE:-$DEFAULT_NODE}"
 
 # If present, extract cookie from ERL_FLAGS
 # This is used by the CouchDB Dockerfile and Helm chart
 COOKIE=$(echo "$ERL_FLAGS" | sed 's/^.*setcookie \([^ ][^ ]*\).*$/\1/g')
-if test -f "$VM_ARGS"; then
+if test -f "$ARGS_FILE"; then
 # else attempt to extract from vm.args
-  VM_ARGS_COOKIE=$(awk '$1=="-setcookie"{print $2}' "$VM_ARGS")
-  COOKIE="${COOKIE:-$VM_ARGS_COOKIE}"
+  ARGS_FILE_COOKIE=$(awk '$1=="-setcookie"{print $2}' "$ARGS_FILE")
+  COOKIE="${COOKIE:-$ARGS_FILE_COOKIE}"
 fi
 COOKIE="${COOKIE:-monster}"