aboutsummaryrefslogtreecommitdiffstats
path: root/priv/templates/bin.dtl
diff options
context:
space:
mode:
authorJordan Wilberding <[email protected]>2014-03-29 09:10:08 +0100
committerJordan Wilberding <[email protected]>2014-03-29 09:10:08 +0100
commit0d292ff4c1be173a775628c09d1ac9991fdd8e67 (patch)
tree604625aea65acdc6fd87addb76399317f26f98c0 /priv/templates/bin.dtl
parenta3508b03be8aff8ffafb1a48172d8dd0c8b1be24 (diff)
parent42c0d49c3e4c0fc55a498bc63d0db78308271883 (diff)
downloadrelx-0d292ff4c1be173a775628c09d1ac9991fdd8e67.tar.gz
relx-0d292ff4c1be173a775628c09d1ac9991fdd8e67.tar.bz2
relx-0d292ff4c1be173a775628c09d1ac9991fdd8e67.zip
Merge pull request #154 from nuex/quote_vars
Give release scripts ability to handle directories with spaces
Diffstat (limited to 'priv/templates/bin.dtl')
-rwxr-xr-xpriv/templates/bin.dtl60
1 files changed, 35 insertions, 25 deletions
diff --git a/priv/templates/bin.dtl b/priv/templates/bin.dtl
index 8f8b048..4434552 100755
--- a/priv/templates/bin.dtl
+++ b/priv/templates/bin.dtl
@@ -2,51 +2,61 @@
set -e
-SCRIPT_DIR=`dirname $0`
-RELEASE_ROOT_DIR=`cd $SCRIPT_DIR/.. && pwd`
-REL_NAME={{ rel_name }}
-REL_VSN={{ rel_vsn }}
-ERTS_VSN={{ erts_vsn }}
-REL_DIR=$RELEASE_ROOT_DIR/releases/$REL_VSN
-ERL_OPTS={{ erl_opts }}
+SCRIPT_DIR="$(dirname "$0")"
+RELEASE_ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
+REL_NAME="{{ rel_name }}"
+REL_VSN="{{ rel_vsn }}"
+ERTS_VSN="{{ erts_vsn }}"
+REL_DIR="$RELEASE_ROOT_DIR/releases/$REL_VSN"
+ERL_OPTS="{{ erl_opts }}"
find_erts_dir() {
- local erts_dir=$RELEASE_ROOT_DIR/erts-$ERTS_VSN
+ local erts_dir="$RELEASE_ROOT_DIR/erts-$ERTS_VSN"
if [ -d "$erts_dir" ]; then
- ERTS_DIR=$erts_dir;
- ROOTDIR=$RELEASE_ROOT_DIR
+ ERTS_DIR="$erts_dir";
+ ROOTDIR="$RELEASE_ROOT_DIR"
else
- local erl=`which erl`
- local erl_root=`$erl -noshell -eval "io:format(\\"~s\\", [code:root_dir()])." -s init stop`
- ERTS_DIR=$erl_root/erts-$ERTS_VSN
- ROOTDIR=$erl_root
+ local erl="$(which erl)"
+ local erl_root="$("$erl" -noshell -eval "io:format(\\"~s\\", [code:root_dir()])." -s init stop)"
+ ERTS_DIR="$erl_root/erts-$ERTS_VSN"
+ ROOTDIR="$erl_root"
fi
}
find_sys_config() {
- local possible_sys=$REL_DIR/sys.config
+ local possible_sys="$REL_DIR/sys.config"
if [ -f "$possible_sys" ]; then
- SYS_CONFIG="-config $possible_sys"
+ SYS_CONFIG="$possible_sys"
fi
}
find_vm_args() {
- local possible_vm_args=$REL_DIR/vm.args
+ local possible_vm_args="$REL_DIR/vm.args"
if [ -f "$possible_vm_args" ]; then
- VM_ARGS="-args_file $possible_vm_args"
+ VM_ARGS="$possible_vm_args"
fi
}
find_erts_dir
find_sys_config
find_vm_args
-export ROOTDIR=$RELEASE_ROOT_DIR
-export BINDIR=$ERTS_DIR/bin
-export EMU=beam
-export PROGNAME=erl
-export LD_LIBRARY_PATH=$ERTS_DIR/lib:$LD_LIBRARY_PATH
+export ROOTDIR="$RELEASE_ROOT_DIR"
+export BINDIR="$ERTS_DIR/bin"
+export EMU="beam"
+export PROGNAME="erl"
+export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH"
-cd $ROOTDIR
+cd "$ROOTDIR"
-$BINDIR/erlexec $ERL_OPTS $SYS_CONFIG $VM_ARGS -boot $REL_DIR/$REL_NAME $@
+# Save extra arguments
+ARGS="$@"
+
+# Build arguments for erlexec
+set -- "$ERL_OPTS"
+[ "$SYS_CONFIG" ] && set -- "$@" -config "$SYS_CONFIG"
+[ "$VM_ARGS" ] && set -- "$@" -args_file "$VM_ARGS"
+set -- "$@" -boot "$REL_DIR/$REL_NAME" "$ARGS"
+
+# Boot the release
+"$BINDIR/erlexec" "$@"