diff options
Diffstat (limited to 'priv/templates/extended_bin')
-rwxr-xr-x | priv/templates/extended_bin | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index 6c012b2..2cd6d29 100755 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -127,10 +127,12 @@ find_erts_dir() { if [ -d "$__erts_dir" ]; then ERTS_DIR="$__erts_dir"; ROOTDIR="$RELEASE_ROOT_DIR" + # run a dummy distributed erlang node just to ensure that a cookie exists + $ERTS_DIR/bin/erl -sname dummy -boot no_dot_erlang -noshell -eval "halt()" else __erl="$(which erl)" code="io:format(\"~s\", [code:root_dir()]), halt()." - __erl_root="$("$__erl" -boot no_dot_erlang -sasl errlog_type error -noshell -eval "$code")" + __erl_root="$("$__erl" -sname dummy -boot no_dot_erlang -sasl errlog_type error -noshell -eval "$code")" ERTS_DIR="$__erl_root/erts-$ERTS_VSN" ROOTDIR="$__erl_root" fi @@ -180,15 +182,15 @@ relx_gen_id() { relx_nodetool() { command="$1"; shift - escript_emulator_args $ROOTDIR/bin/nodetool + ESCRIPT_TMP=$(escript_emulator_args_tmp $ROOTDIR/bin/nodetool) - "$ERTS_DIR/bin/escript" "$ROOTDIR/bin/nodetool" "$NAME_TYPE" "$NAME" \ + "$ERTS_DIR/bin/escript" "$ESCRIPT_TMP" "$NAME_TYPE" "$NAME" \ -setcookie "$COOKIE" "$command" $@ } # Run an escript in the node's environment relx_escript() { - shift; scriptpath="$1"; shift + scriptpath="$1"; shift export RELEASE_ROOT_DIR "$ERTS_DIR/bin/escript" "$ROOTDIR/$scriptpath" $@ @@ -248,6 +250,24 @@ escript_emulator_args() { fi } +escript_emulator_args_tmp() { + # + # If the user provided $ROOTDIR/tmp directory then don't override + # original files of the package but use temporary files instead + # + local TMP_DIR="$ROOTDIR/tmp"; + + if [ -d "$TMP_DIR" ] && [ -w "$TMP_DIR" ]; then + local TMP_FILE="$TMP_DIR/$(basename $1)" + cp $1 $TMP_FILE + escript_emulator_args $TMP_FILE + echo $TMP_FILE + else + escript_emulator_args $1 + echo $1 + fi +} + add_path() { # Use $CWD/$1 if exists, otherwise releases/VSN/$1 IN_FILE_PATH=$2 @@ -353,7 +373,7 @@ relx_run_extension() { shift # all extension script locations are expected to be # relative to the start script location - [ "$SCRIPT_DIR/$EXTENSION_SCRIPT" ] && . "$SCRIPT_DIR/$EXTENSION_SCRIPT" $@ + [ "$SCRIPT_DIR/$EXTENSION_SCRIPT" ] && . "$SCRIPT_DIR/$EXTENSION_SCRIPT" "$@" } # given a list of arguments, identify the internal ones @@ -578,6 +598,7 @@ case "$1" in escript) ## Run an escript under the node's environment + shift if ! relx_escript $@; then exit 1 fi @@ -628,9 +649,9 @@ case "$1" in relx_run_hooks "$PRE_INSTALL_UPGRADE_HOOKS" - escript_emulator_args $ROOTDIR/bin/install_upgrade.escript + ESCRIPT_TMP=$(escript_emulator_args_tmp $ROOTDIR/bin/install_upgrade.escript) - exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \ + exec "$BINDIR/escript" "$ESCRIPT_TMP" \ "$COMMAND" "{'$REL_NAME', \"$NAME_TYPE\", '$NAME', '$COOKIE'}" "$@" relx_run_hooks "$POST_INSTALL_UPGRADE_HOOKS" @@ -645,9 +666,9 @@ case "$1" in COMMAND="$1"; shift - escript_emulator_args $ROOTDIR/bin/install_upgrade.escript + ESCRIPT_TMP=$(escript_emulator_args_tmp $ROOTDIR/bin/install_upgrade.escript) - exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \ + exec "$BINDIR/escript" "$ESCRIPT_TMP" \ "versions" "{'$REL_NAME', \"$NAME_TYPE\", '$NAME', '$COOKIE'}" "$@" ;; @@ -773,7 +794,7 @@ case "$1" in if [ "$IS_EXTENSION" = "1" ]; then EXTENSION_SCRIPT=$(relx_get_extension_script $1) shift - relx_run_extension $EXTENSION_SCRIPT $@ + relx_run_extension $EXTENSION_SCRIPT "$@" # all extension scripts are expected to exit else relx_usage $1 |