aboutsummaryrefslogtreecommitdiffstats
path: root/priv/templates/extended_bin
diff options
context:
space:
mode:
Diffstat (limited to 'priv/templates/extended_bin')
-rwxr-xr-xpriv/templates/extended_bin26
1 files changed, 14 insertions, 12 deletions
diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin
index 4a29d44..b6eb297 100755
--- a/priv/templates/extended_bin
+++ b/priv/templates/extended_bin
@@ -6,7 +6,7 @@ SCRIPT=$(readlink -f $0 || true)
[ -z $SCRIPT ] && SCRIPT=$0
SCRIPT_DIR="${SCRIPT%/*}"
RELEASE_ROOT_DIR="${SCRIPT_DIR%/*}"
-REL_NAME="{{ rel_name }}"
+export REL_NAME="{{ rel_name }}"
REL_VSN="{{ rel_vsn }}"
ERTS_VSN="{{ erts_vsn }}"
CODE_LOADING_MODE="${CODE_LOADING_MODE:-embedded}"
@@ -90,7 +90,7 @@ relx_start_command() {
# Replace environment variables
relx_replace_os_vars() {
awk '{
- while(match($0,/\$\{[^{}]+?\}/)) {
+ while(match($0,/\$[{(][^{}()]+?[})]/)) {
s=RSTART; n=RLENGTH;
v0=substr($0,0,s-1); v1=substr($0,s,n); v2=substr($0,n+s,length($0)-s-n+1)
"echo "v1|getline v; $0=v0 v v2
@@ -126,15 +126,10 @@ if [ -z "$RELX_CONFIG_PATH" ]; then
fi
fi
-if [ $RELX_REPLACE_OS_VARS ]; then
- IN=$RELX_CONFIG_PATH
- OUT=${IN##*/}
- RELX_CONFIG_PATH=${IN%.*}.2.${OUT##*.}
- relx_replace_os_vars ${IN} ${RELX_CONFIG_PATH}
-fi
-
# Extract the target node name from node.args
-NAME_ARG=( $(eval echo $(egrep '^-s?name' "$VMARGS_PATH" || true)) )
+# Do this BEFORE possible variable replacement, so that $NAME is available
+# in the replacement phase if needed
+NAME_ARG=( $(egrep '^-s?name' "$VMARGS_PATH" || true) )
if [ -z "${NAME_ARG[*]}" ]; then
echo "vm.args needs to have either -name or -sname parameter."
exit 1
@@ -142,12 +137,19 @@ fi
# Extract the name type and name from the NAME_ARG for REMSH
NAME_TYPE="${NAME_ARG[0]}"
-NAME="${NAME_ARG[1]}"
+export NAME="${NAME_ARG[*]:1}"
+
+if [ $RELX_REPLACE_OS_VARS ]; then
+ IN=$RELX_CONFIG_PATH
+ OUT=${IN##*/}
+ RELX_CONFIG_PATH=${IN%.*}.2.${OUT##*.}
+ relx_replace_os_vars ${IN} ${RELX_CONFIG_PATH}
+fi
PIPE_DIR="${PIPE_DIR:-/tmp/erl_pipes/$NAME/}"
# Extract the target cookie
-COOKIE_ARG=( $(eval echo $(grep '^-setcookie' "$VMARGS_PATH" || true)) )
+COOKIE_ARG=( $(grep '^-setcookie' "$VMARGS_PATH" || true) )
if [ -z "${COOKIE_ARG[*]}" ]; then
echo "vm.args needs to have a -setcookie parameter."
exit 1