diff options
Diffstat (limited to 'priv/templates/bin.dtl')
-rwxr-xr-x | priv/templates/bin.dtl | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/priv/templates/bin.dtl b/priv/templates/bin.dtl new file mode 100755 index 0000000..8f8b048 --- /dev/null +++ b/priv/templates/bin.dtl @@ -0,0 +1,52 @@ +#!/bin/sh + +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 }} + +find_erts_dir() { + local erts_dir=$RELEASE_ROOT_DIR/erts-$ERTS_VSN + if [ -d "$erts_dir" ]; then + 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 + fi + +} + +find_sys_config() { + local possible_sys=$REL_DIR/sys.config + if [ -f "$possible_sys" ]; then + SYS_CONFIG="-config $possible_sys" + fi +} + +find_vm_args() { + local possible_vm_args=$REL_DIR/vm.args + if [ -f "$possible_vm_args" ]; then + VM_ARGS="-args_file $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 + +cd $ROOTDIR + +$BINDIR/erlexec $ERL_OPTS $SYS_CONFIG $VM_ARGS -boot $REL_DIR/$REL_NAME $@ |