aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsoranoba <[email protected]>2016-06-15 20:23:17 +0900
committersoranoba <[email protected]>2016-06-16 01:18:02 +0900
commit12e030ac8a2f30fc8dc1a1c04f90568778edd914 (patch)
tree09ad2899348781e2f813253acd9544730d3a3093
parent38bf6186db7518e5b2eae9b51cc1096362697128 (diff)
downloadrelx-12e030ac8a2f30fc8dc1a1c04f90568778edd914.tar.gz
relx-12e030ac8a2f30fc8dc1a1c04f90568778edd914.tar.bz2
relx-12e030ac8a2f30fc8dc1a1c04f90568778edd914.zip
If cookie is not exist in vm.args, it use the cookie in ~/.erlang.cookie
-rwxr-xr-xpriv/templates/extended_bin18
1 files changed, 13 insertions, 5 deletions
diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin
index c2515ba..811a8bb 100755
--- a/priv/templates/extended_bin
+++ b/priv/templates/extended_bin
@@ -163,14 +163,22 @@ PIPE_DIR="${PIPE_DIR:-/tmp/erl_pipes/$NAME/}"
# Extract the target cookie
COOKIE_ARG="$(grep '^-setcookie' "$VMARGS_PATH" || true)"
+DEFAULT_COOKIE_FILE="$HOME/.erlang.cookie"
if [ -z "$COOKIE_ARG" ]; then
- echo "vm.args needs to have a -setcookie parameter."
- exit 1
+ if [ ! -f "$DEFAULT_COOKIE_FILE" ]; then
+ echo "vm.args needs to have a -setcookie, or $DEFAULT_COOKIE_FILE is required."
+ exit 1
+ elif [ -O "$DEFAULT_COOKIE_FILE" ] && [ $(stat --format=%a $DEFAULT_COOKIE_FILE) -eq 400 ]; then
+ COOKIE="$(cat $DEFAULT_COOKIE_FILE)"
+ else
+ echo "$DEFAULT_COOKIE_FILE must be set to octal 400. (read-only by user)"
+ exit 1
+ fi
+else
+ # Extract cookie name from COOKIE_ARG
+ COOKIE="$(echo "$COOKIE_ARG" | awk '{print $2}')"
fi
-# Extract cookie name from COOKIE_ARG
-COOKIE="$(echo "$COOKIE_ARG" | awk '{print $2}')"
-
find_erts_dir
export ROOTDIR="$RELEASE_ROOT_DIR"
export BINDIR="$ERTS_DIR/bin"