aboutsummaryrefslogtreecommitdiffstats
path: root/priv
diff options
context:
space:
mode:
authorTristan Sloughter <[email protected]>2015-12-31 12:51:03 -0600
committerTristan Sloughter <[email protected]>2015-12-31 12:51:03 -0600
commitdfebf6dbbab497b61190b8ea153af1ef2b4b7ee4 (patch)
tree4cce6d56564b40834be16d743259751bf9f3f591 /priv
parent72016ccf71ff41582161e7ace81dc7a0095c7bb3 (diff)
parentb34795fdc2440bb190503fb9b84676b73ed2bbd3 (diff)
downloadrelx-dfebf6dbbab497b61190b8ea153af1ef2b4b7ee4.tar.gz
relx-dfebf6dbbab497b61190b8ea153af1ef2b4b7ee4.tar.bz2
relx-dfebf6dbbab497b61190b8ea153af1ef2b4b7ee4.zip
Merge pull request #431 from erlware/revert-426-varsv3.10.0
Revert "Enhance evaluation of environment variables"
Diffstat (limited to 'priv')
-rwxr-xr-xpriv/templates/extended_bin59
1 files changed, 22 insertions, 37 deletions
diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin
index 7945567..346a88c 100755
--- a/priv/templates/extended_bin
+++ b/priv/templates/extended_bin
@@ -2,11 +2,13 @@
set -e
-SCRIPT=$(readlink -f $0 || true)
-[ -z $SCRIPT ] && SCRIPT=$0
-SCRIPT_DIR="${SCRIPT%/*}"
-RELEASE_ROOT_DIR="${SCRIPT_DIR%/*}"
-export REL_NAME="{{ rel_name }}"
+SCRIPT=$(readlink $0 || true)
+if [ -z $SCRIPT ]; then
+ SCRIPT=$0
+fi;
+SCRIPT_DIR="$(cd `dirname "$SCRIPT"` && pwd -P)"
+RELEASE_ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd -P)"
+REL_NAME="{{ rel_name }}"
REL_VSN="{{ rel_vsn }}"
ERTS_VSN="{{ erts_vsn }}"
CODE_LOADING_MODE="${CODE_LOADING_MODE:-embedded}"
@@ -87,17 +89,6 @@ relx_start_command() {
"$START_OPTION"
}
-# Replace environment variables
-relx_replace_os_vars() {
- awk '{
- 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
- }
- }1' < "$1" > "$2"
-}
-
# Use $CWD/vm.args if exists, otherwise releases/VSN/vm.args
if [ -z "$VMARGS_PATH" ]; then
if [ -f "$RELEASE_ROOT_DIR/vm.args" ]; then
@@ -108,10 +99,8 @@ if [ -z "$VMARGS_PATH" ]; then
fi
if [ $RELX_REPLACE_OS_VARS ]; then
- IN=$VMARGS_PATH
- OUT=${IN##*/}
- VMARGS_PATH=${IN%.*}.2.${OUT##*.}
- relx_replace_os_vars ${IN} ${VMARGS_PATH}
+ awk '{while(match($0,"[$]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH -3);gsub("[$]{"var"}",ENVIRON[var])}}1' < $VMARGS_PATH > $VMARGS_PATH.2.config
+ VMARGS_PATH=$VMARGS_PATH.2.config
fi
# Make sure log directory exists
@@ -126,37 +115,33 @@ if [ -z "$RELX_CONFIG_PATH" ]; then
fi
fi
+if [ $RELX_REPLACE_OS_VARS ]; then
+ awk '{while(match($0,"[$]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH -3);gsub("[$]{"var"}",ENVIRON[var])}}1' < $RELX_CONFIG_PATH > $RELX_CONFIG_PATH.2.config
+ RELX_CONFIG_PATH=$RELX_CONFIG_PATH.2.config
+fi
+
# Extract the target node name from node.args
-# 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
+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
fi
# Extract the name type and name from the NAME_ARG for REMSH
-NAME_TYPE="${NAME_ARG[0]}"
-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
+NAME_TYPE="$(echo "$NAME_ARG" | awk '{print $1}')"
+NAME="$(echo "$NAME_ARG" | awk '{print $2}')"
PIPE_DIR="${PIPE_DIR:-/tmp/erl_pipes/$NAME/}"
# Extract the target cookie
-COOKIE_ARG=( $(grep '^-setcookie' "$VMARGS_PATH" || true) )
-if [ -z "${COOKIE_ARG[*]}" ]; then
+COOKIE_ARG="$(grep '^-setcookie' "$VMARGS_PATH" || true)"
+if [ -z "$COOKIE_ARG" ]; then
echo "vm.args needs to have a -setcookie parameter."
exit 1
fi
# Extract cookie name from COOKIE_ARG
-COOKIE="${COOKIE_ARG[1]}"
+COOKIE="$(echo "$COOKIE_ARG" | awk '{print $2}')"
find_erts_dir
export ROOTDIR="$RELEASE_ROOT_DIR"
@@ -164,7 +149,7 @@ export BINDIR="$ERTS_DIR/bin"
export EMU="beam"
export PROGNAME="erl"
export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH"
-ERTS_LIB_DIR="${ERTS_DIR%/*}/lib"
+ERTS_LIB_DIR="$ERTS_DIR/../lib"
cd "$ROOTDIR"