Skip to content
This repository
Browse code

Improve remsh script

Cookies now default to using ~/.erlang.cookie which is automatically
generated if it does not exist when erlang starts with a name.

There is also no longer a need to specify a name to remsh as it'll
generate a name based on the process id and set the short or long
version appropriately.
  • Loading branch information...
commit d367c4bec22ad20807901c4b9c53b4fe4cd0fa59 1 parent 44ba062
Paul J. Davis davisp authored
9 configure
@@ -44,8 +44,12 @@ do
44 44 BIGCOUCH_USER=$2
45 45 shift 2
46 46 ;;
  47 + -c)
  48 + COOKIE=$2
  49 + shift 2
  50 + ;;
47 51 *)
48   - echo "usage: $0 [-p {prefix} -t {template} -d {data_dir} -v {view_dir} -u {user}]"
  52 + echo "usage: $0 [-p {prefix} -t {template} -d {data_dir} -v {view_dir} -u {user} -c {cookie}]"
49 53 exit
50 54 ;;
51 55 esac
@@ -53,6 +57,7 @@ done
53 57
54 58 if test ! -n "$DATA"; then DATA="$PREFIX/var/lib"; fi
55 59 if test ! -n "$VIEW"; then VIEW="$PREFIX/var/lib"; fi
  60 +if test -n "$COOKIE"; then COOKIE="-setcookie $COOKIE"; fi
56 61
57 62 echo "==> configuring bigcouch in rel/bigcouch.config"
58 63 cat > rel/bigcouch.config << EOF
@@ -61,6 +66,7 @@ cat > rel/bigcouch.config << EOF
61 66 {view_dir, "$VIEW"}.
62 67 {user, "$BIGCOUCH_USER"}.
63 68 {node_name, "-name bigcouch"}.
  69 +{cookie, "$COOKIE"}.
64 70 {cluster_port, 5984}.
65 71 {cluster_ssl, 6984}.
66 72 {backend_port, 5986}.
@@ -81,6 +87,7 @@ cat > rel/dev$i.config << EOF
81 87 {data_dir, "$DIRPATH/rel/tmpdata/dev$i"}.
82 88 {view_dir, "$DIRPATH/rel/tmpdata/dev$i"}.
83 89 {node_name, "-name dev$i@127.0.0.1"}.
  90 +{cookie, "$COOKIE"}.
84 91 {cluster_port, `expr 10000 \* $i + 5984`}.
85 92 {cluster_ssl, `expr 10000 \* $i + 6984`}.
86 93 {backend_port, `expr 10000 \* $i + 5986`}.
20 rel/overlay/bin/remsh
@@ -12,15 +12,16 @@
12 12 # License for the specific language governing permissions and limitations under
13 13 # the License.
14 14
15   -if test ! $1 ; then
16   - echo "usage: $0 nodename"
17   - exit 1
18   -fi
  15 +NAME="remsh$$"
  16 +REM_NODE="{{node_name}}"
  17 +NAME_TYPE=${REM_NODE% *}
  18 +REM_NODE=${REM_NODE#* }
  19 +HOST=`echo "$REM_NODE" | grep -o "@.*" | sed 's/@//'`
19 20
20   -if test `echo $1 | sed 's/[^@]//g'`; then
21   - NAME="-name $1"
  21 +if test -n $HOST; then
  22 + NAME="$NAME_TYPE $NAME@$HOST"
22 23 else
23   - NAME="-sname $1"
  24 + NAME="$NAME_TYPE $NAME"
24 25 fi
25 26
26 27 ERTS_BIN_DIR=$(cd ${0%/*} && pwd)
@@ -33,9 +34,6 @@ START_CLEAN="${ROOTDIR}/releases/${APP_VSN}/start_clean"
33 34
34 35 BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
35 36
36   -REM_NODE="{{node_name}}"
37   -REM_NODE=${REM_NODE#* }
38   -
39   -COOKIE="-setcookie monster"
  37 +COOKIE="{{cookie}}"
40 38
41 39 exec $BINDIR/erl $NAME -remsh $REM_NODE $COOKIE -hidden -boot $START_CLEAN
13 rel/overlay/etc/vm.args
@@ -4,10 +4,15 @@
4 4 # with the -name flag.
5 5 {{node_name}}
6 6
7   -# All nodes must share the same magic cookie for distributed Erlang to work.
8   -# Comment out this line if you synchronized the cookies by other means (using
9   -# the ~/.erlang.cookie file, for example).
10   --setcookie monster
  7 +# If you passed a value for the cookie to ./configure it will be set here.
  8 +# Otherwise it will default to using ~/.erlang.cookie which will be generated
  9 +# automatically if it doesn't exist.
  10 +#
  11 +# Note that you need to make sure that the cookie value used is synchronized
  12 +# across all nodes in the cluster. This means that if you don't set the
  13 +# cookie by hand you need to manually sync ~/.erlang.cookie across all nodes
  14 +# in the cluster.
  15 +{{cookie}}
11 16
12 17 # Tell SASL not to log progress reports
13 18 -sasl errlog_type error

0 comments on commit d367c4b

Please sign in to comment.
Something went wrong with that request. Please try again.