diff options
Diffstat (limited to 'priv/templates/extended_bin.dtl')
-rw-r--r-- | priv/templates/extended_bin.dtl | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/priv/templates/extended_bin.dtl b/priv/templates/extended_bin.dtl index 39701c0..16b8708 100644 --- a/priv/templates/extended_bin.dtl +++ b/priv/templates/extended_bin.dtl @@ -13,12 +13,12 @@ PIPE_DIR=/tmp/erl_pipes/{{ rel_name }}/ find_erts_dir() { local erts_dir=$RELEASE_ROOT_DIR/erts-$ERTS_VSN - if [ -d \"$erts_dir\" ]; then + 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` + 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 @@ -27,21 +27,21 @@ find_erts_dir() { find_sys_config() { local possible_sys=$REL_DIR/sys.config - if [ -f \"$possible_sys\" ]; then - SYS_CONFIG=\"-config $possible_sys\" + if [ -f "$possible_sys" ]; then + SYS_CONFIG="-config $possible_sys" fi } # Use $CWD/vm.args if exists, otherwise releases/APP_VSN/vm.args, or else etc/vm.args -if [ -e \"$RELEASE_ROOT_DIR/vm.args\" ]; then +if [ -e "$RELEASE_ROOT_DIR/vm.args" ]; then VMARGS_PATH=$RELEASE_ROOT_DIR/vm.args USE_DIR=$RELEASE_ROOT_DIR else USE_DIR=$REL_DIR - if [ -e \"$REL_DIR/vm.args\" ]; then - VMARGS_PATH=\"$REL_DIR/vm.args\" + if [ -e "$REL_DIR/vm.args" ]; then + VMARGS_PATH="$REL_DIR/vm.args" else - VMARGS_PATH=\"$REL_DIR/vm.args\" + VMARGS_PATH="$REL_DIR/vm.args" fi fi @@ -50,20 +50,20 @@ RUNNER_LOG_DIR=$RELEASE_ROOT_DIR/log mkdir -p $RUNNER_LOG_DIR # Use releases/VSN/sys.config if it exists otherwise use etc/app.config -if [ -e \"$USE_DIR/sys.config\" ]; then - CONFIG_PATH=\"$USE_DIR/sys.config\" +if [ -e "$USE_DIR/sys.config" ]; then + CONFIG_PATH="$USE_DIR/sys.config" else - if [ -e \"$REL_DIR/sys.config\" ]; then - CONFIG_PATH=\"$REL_DIR/sys.config\" + if [ -e "$REL_DIR/sys.config" ]; then + CONFIG_PATH="$REL_DIR/sys.config" else - CONFIG_PATH=\"$REL_DIR/app.config\" + CONFIG_PATH="$REL_DIR/app.config" fi fi # Extract the target node name from node.args NAME_ARG=`egrep '^-s?name' $VMARGS_PATH` -if [ -z \"$NAME_ARG\" ]; then - echo \"vm.args needs to have either -name or -sname parameter.\" +if [ -z "$NAME_ARG" ]; then + echo "vm.args needs to have either -name or -sname parameter." exit 1 fi @@ -72,13 +72,13 @@ REMSH_TYPE=`echo $NAME_ARG | awk '{print $1}'` REMSH_NAME=`echo $NAME_ARG | awk '{print $2}'` # Note the `date +%s`, used to allow multiple remsh to the same node transparently -REMSH_NAME_ARG=\"$REMSH_TYPE remsh`date +%s`@`echo $REMSH_NAME | awk -F@ '{print $2}'`\" -REMSH_REMSH_ARG=\"-remsh $REMSH_NAME -boot start_clean\" +REMSH_NAME_ARG="$REMSH_TYPE remsh`date +%s`@`echo $REMSH_NAME | awk -F@ '{print $2}'`" +REMSH_REMSH_ARG="-remsh $REMSH_NAME -boot start_clean" # Extract the target cookie COOKIE_ARG=`grep '^-setcookie' $VMARGS_PATH` -if [ -z \"$COOKIE_ARG\" ]; then - echo \"vm.args needs to have a -setcookie parameter.\" +if [ -z "$COOKIE_ARG" ]; then + echo "vm.args needs to have a -setcookie parameter." exit 1 fi @@ -93,38 +93,38 @@ export LD_LIBRARY_PATH=$ERTS_DIR/lib cd $ROOTDIR # Setup remote shell command to control node -REMSH=\"$BINDIR/erl $REMSH_NAME_ARG $REMSH_REMSH_ARG $COOKIE_ARG\" +REMSH="$BINDIR/erl $REMSH_NAME_ARG $REMSH_REMSH_ARG $COOKIE_ARG" # Setup command to control the node -NODETOOL=\"$BINDIR/escript $ROOTDIR/bin/nodetool $NAME_ARG $COOKIE_ARG\" +NODETOOL="$BINDIR/escript $ROOTDIR/bin/nodetool $NAME_ARG $COOKIE_ARG" # Check the first argument for instructions -case \"$1\" in +case "$1" in start|start_boot) # Make sure there is not already a node running #RES=`$NODETOOL ping` - #if [ \"$RES\" = \"pong\" ]; then - # echo \"Node is already running!\" + #if [ "$RES" = "pong" ]; then + # echo "Node is already running!" # exit 1 #fi - case \"$1\" in + case "$1" in start) shift - START_OPTION=\"console\" - HEART_OPTION=\"start\" + START_OPTION="console" + HEART_OPTION="start" ;; start_boot) shift - START_OPTION=\"console_boot\" - HEART_OPTION=\"start_boot\" + START_OPTION="console_boot" + HEART_OPTION="start_boot" ;; esac - RUN_PARAM=$(printf \"'%s' \" \"$@\") - HEART_COMMAND=\"$SCRIPT_DIR/bin/$REL_NAME $HEART_OPTION $RUN_PARAM\" + RUN_PARAM=$(printf "'%s' " "$@") + HEART_COMMAND="$SCRIPT_DIR/bin/$REL_NAME $HEART_OPTION $RUN_PARAM" export HEART_COMMAND mkdir -p $PIPE_DIR - $BINDIR/run_erl -daemon $PIPE_DIR $RUNNER_LOG_DIR \"exec $RELEASE_ROOT_DIR/bin/$REL_NAME $START_OPTION $RUN_PARAM\" 2>&1 + $BINDIR/run_erl -daemon $PIPE_DIR $RUNNER_LOG_DIR "exec $RELEASE_ROOT_DIR/bin/$REL_NAME $START_OPTION $RUN_PARAM" 2>&1 ;; stop) @@ -133,21 +133,21 @@ case \"$1\" in Linux|Darwin|FreeBSD|DragonFly|NetBSD|OpenBSD) # PID COMMAND PID=`ps ax -o pid= -o command=| - grep \"$SCRIPT_DIR/.*/[b]eam\"|awk '{print $1}'` + grep "$SCRIPT_DIR/.*/[b]eam"|awk '{print $1}'` ;; SunOS) # PID COMMAND PID=`ps -ef -o pid= -o args=| - grep \"$SCRIPT_DIR/.*/[b]eam\"|awk '{print $1}'` + grep "$SCRIPT_DIR/.*/[b]eam"|awk '{print $1}'` ;; CYGWIN*) # UID PID PPID TTY STIME COMMAND - PID=`ps -efW|grep \"$SCRIPT_DIR/.*/[b]eam\"|awk '{print $2}'` + PID=`ps -efW|grep "$SCRIPT_DIR/.*/[b]eam"|awk '{print $2}'` ;; esac $NODETOOL stop ES=$? - if [ \"$ES\" -ne 0 ]; then + if [ "$ES" -ne 0 ]; then exit $ES fi while `kill -0 $PID 2>/dev/null`; @@ -160,7 +160,7 @@ case \"$1\" in ## Restart the VM without exiting the process $NODETOOL restart ES=$? - if [ \"$ES\" -ne 0 ]; then + if [ "$ES" -ne 0 ]; then exit $ES fi ;; @@ -169,7 +169,7 @@ case \"$1\" in ## Restart the VM completely (uses heart to restart it) $NODETOOL reboot ES=$? - if [ \"$ES\" -ne 0 ]; then + if [ "$ES" -ne 0 ]; then exit $ES fi ;; @@ -178,7 +178,7 @@ case \"$1\" in ## See if the VM is alive $NODETOOL ping ES=$? - if [ \"$ES\" -ne 0 ]; then + if [ "$ES" -ne 0 ]; then exit $ES fi ;; @@ -187,8 +187,8 @@ case \"$1\" in # Make sure a node IS running RES=`$NODETOOL ping` ES=$? - if [ \"$ES\" -ne 0 ]; then - echo \"Node is not running!\" + if [ "$ES" -ne 0 ]; then + echo "Node is not running!" exit $ES fi @@ -200,8 +200,8 @@ case \"$1\" in # Make sure a node IS running RES=`$NODETOOL ping` ES=$? - if [ \"$ES\" -ne 0 ]; then - echo \"Node is not running!\" + if [ "$ES" -ne 0 ]; then + echo "Node is not running!" exit $ES fi @@ -210,18 +210,18 @@ case \"$1\" in ;; upgrade|downgrade|install) - if [ -z \"$2\" ]; then - echo \"Missing package argument\" - echo \"Usage: $REL_NAME $1 {package base name}\" - echo \"NOTE {package base name} MUST NOT include the .tar.gz suffix\" + if [ -z "$2" ]; then + echo "Missing package argument" + echo "Usage: $REL_NAME $1 {package base name}" + echo "NOTE {package base name} MUST NOT include the .tar.gz suffix" exit 1 fi # Make sure a node IS running RES=`$NODETOOL ping` ES=$? - if [ \"$ES\" -ne 0 ]; then - echo \"Node is not running!\" + if [ "$ES" -ne 0 ]; then + echo "Node is not running!" exit $ES fi @@ -235,31 +235,31 @@ case \"$1\" in # .boot file typically just $REL_NAME (ie, the app name) # however, for debugging, sometimes start_clean.boot is useful. # For e.g. 'setup', one may even want to name another boot script. - case \"$1\" in + case "$1" in console) [ -f $REL_DIR/$REL_NAME.boot ] && BOOTFILE=$REL_DIR/$REL_NAME || BOOTFILE=$REL_DIR/start ;; console_clean) BOOTFILE=$ROOTDIR/bin/start_clean ;; console_boot) shift - BOOTFILE=\"$1\" + BOOTFILE="$1" shift ;; esac # Setup beam-required vars EMU=beam PROGNAME=`echo $0 | sed 's/.*\\///'` - CMD=\"$BINDIR/erlexec -boot $BOOTFILE -env ERL_LIBS $REL_DIR/lib -config $CONFIG_PATH -args_file $VMARGS_PATH\" + CMD="$BINDIR/erlexec -boot $BOOTFILE -env ERL_LIBS $REL_DIR/lib -config $CONFIG_PATH -args_file $VMARGS_PATH" export EMU export PROGNAME # Dump environment info for logging purposes - echo \"Exec: $CMD\" -- ${1+\"$@\"} - echo \"Root: $ROOTDIR\" + echo "Exec: $CMD" -- ${1+"$@"} + echo "Root: $ROOTDIR" # Log the startup - logger -t \"$REL_NAME[$$]\" \"Starting up\" + logger -t "$REL_NAME[$$]" "Starting up" # Start the VM - exec $CMD -- ${1+\"$@\"} + exec $CMD -- ${1+"$@"} ;; foreground) @@ -267,24 +267,24 @@ case \"$1\" in # or other supervision services [ -f $REL_DIR/$REL_NAME.boot ] && BOOTFILE=$REL_NAME || BOOTFILE=start - FOREGROUNDOPTIONS=\"-noinput +Bd\" + FOREGROUNDOPTIONS="-noinput +Bd" # Setup beam-required vars EMU=beam PROGNAME=`echo $0 | sed 's/.*\\///'` - CMD=\"$BINDIR/erlexec $FOREGROUNDOPTIONS -boot $REL_DIR/$BOOTFILE -mode embedded -config $CONFIG_PATH -args_file $VMARGS_PATH\" + CMD="$BINDIR/erlexec $FOREGROUNDOPTIONS -boot $REL_DIR/$BOOTFILE -mode embedded -config $CONFIG_PATH -args_file $VMARGS_PATH" export EMU export PROGNAME # Dump environment info for logging purposes - echo \"Exec: $CMD\" -- ${1+\"$@\"} - echo \"Root: $ROOTDIR\" + echo "Exec: $CMD" -- ${1+"$@"} + echo "Root: $ROOTDIR" # Start the VM - exec $CMD -- ${1+\"$@\"} + exec $CMD -- ${1+"$@"} ;; *) - echo \"Usage: $REL_NAME {start|start_boot <file>|foreground|stop|restart|reboot|ping|console|console_clean|console_boot <file>|attach|remote_console|upgrade}\" + echo "Usage: $REL_NAME {start|start_boot <file>|foreground|stop|restart|reboot|ping|console|console_clean|console_boot <file>|attach|remote_console|upgrade}" exit 1 ;; esac |