aboutsummaryrefslogtreecommitdiffstats
path: root/priv
diff options
context:
space:
mode:
Diffstat (limited to 'priv')
-rwxr-xr-xpriv/templates/extended_bin70
1 files changed, 61 insertions, 9 deletions
diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin
index 854cf6a..e5de981 100755
--- a/priv/templates/extended_bin
+++ b/priv/templates/extended_bin
@@ -182,9 +182,9 @@ relx_gen_id() {
relx_nodetool() {
command="$1"; shift
- escript_emulator_args $ROOTDIR/bin/nodetool
+ ESCRIPT_TMP=$(escript_emulator_args_tmp $ROOTDIR/bin/nodetool)
- "$ERTS_DIR/bin/escript" "$ROOTDIR/bin/nodetool" "$NAME_TYPE" "$NAME" \
+ "$ERTS_DIR/bin/escript" "$ESCRIPT_TMP" "$NAME_TYPE" "$NAME" \
-setcookie "$COOKIE" "$command" $@
}
@@ -250,6 +250,24 @@ escript_emulator_args() {
fi
}
+escript_emulator_args_tmp() {
+ #
+ # If the user provided $ROOTDIR/tmp directory then don't override
+ # original files of the package but use temporary files instead
+ #
+ local TMP_DIR="$ROOTDIR/tmp";
+
+ if [ -d "$TMP_DIR" ] && [ -w "$TMP_DIR" ]; then
+ local TMP_FILE="$TMP_DIR/$(basename $1)"
+ cp $1 $TMP_FILE
+ escript_emulator_args $TMP_FILE
+ echo $TMP_FILE
+ else
+ escript_emulator_args $1
+ echo $1
+ fi
+}
+
add_path() {
# Use $CWD/$1 if exists, otherwise releases/VSN/$1
IN_FILE_PATH=$2
@@ -314,6 +332,16 @@ relx_run_hooks() {
done
}
+relx_disable_hooks() {
+ PRE_START_HOOKS=""
+ POST_START_HOOKS=""
+ PRE_STOP_HOOKS=""
+ POST_STOP_HOOKS=""
+ PRE_INSTALL_UPGRADE_HOOKS=""
+ POST_INSTALL_UPGRADE_HOOKS=""
+ STATUS_HOOK=""
+}
+
relx_is_extension() {
EXTENSION=$1
case "$EXTENSION" in
@@ -345,9 +373,29 @@ relx_run_extension() {
shift
# all extension script locations are expected to be
# relative to the start script location
- [ "$SCRIPT_DIR/$EXTENSION_SCRIPT" ] && . "$SCRIPT_DIR/$EXTENSION_SCRIPT" $@
+ [ "$SCRIPT_DIR/$EXTENSION_SCRIPT" ] && . "$SCRIPT_DIR/$EXTENSION_SCRIPT" "$@"
+}
+
+# given a list of arguments, identify the internal ones
+# --relx-disable-hooks
+# and process them accordingly
+process_internal_args() {
+ for arg in $@
+ do
+ shift
+ case "$arg" in
+ --relx-disable-hooks)
+ relx_disable_hooks
+ ;;
+ *)
+ ;;
+ esac
+ done
}
+# process internal arguments
+process_internal_args $@
+
find_erts_dir
export ROOTDIR="$RELEASE_ROOT_DIR"
export BINDIR="$ERTS_DIR/bin"
@@ -502,7 +550,7 @@ case "$1" in
relx_run_hooks "$PRE_START_HOOKS"
"$BINDIR/run_erl" -daemon "$PIPE_DIR" "$RUNNER_LOG_DIR" \
- "exec \"$RELEASE_ROOT_DIR/bin/$REL_NAME\" \"$START_OPTION\" $ARGS"
+ "exec \"$RELEASE_ROOT_DIR/bin/$REL_NAME\" \"$START_OPTION\" --relx-disable-hooks $ARGS"
relx_run_hooks "$POST_START_HOOKS"
;;
@@ -600,9 +648,9 @@ case "$1" in
relx_run_hooks "$PRE_INSTALL_UPGRADE_HOOKS"
- escript_emulator_args $ROOTDIR/bin/install_upgrade.escript
+ ESCRIPT_TMP=$(escript_emulator_args_tmp $ROOTDIR/bin/install_upgrade.escript)
- exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \
+ exec "$BINDIR/escript" "$ESCRIPT_TMP" \
"$COMMAND" "{'$REL_NAME', \"$NAME_TYPE\", '$NAME', '$COOKIE'}" "$@"
relx_run_hooks "$POST_INSTALL_UPGRADE_HOOKS"
@@ -617,9 +665,9 @@ case "$1" in
COMMAND="$1"; shift
- escript_emulator_args $ROOTDIR/bin/install_upgrade.escript
+ ESCRIPT_TMP=$(escript_emulator_args_tmp $ROOTDIR/bin/install_upgrade.escript)
- exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \
+ exec "$BINDIR/escript" "$ESCRIPT_TMP" \
"versions" "{'$REL_NAME', \"$NAME_TYPE\", '$NAME', '$COOKIE'}" "$@"
;;
@@ -677,6 +725,7 @@ case "$1" in
echo "$RELEASE_ROOT_DIR"
logger -t "$REL_NAME[$$]" "Starting up"
+ relx_run_hooks "$PRE_START_HOOKS"
# Start the VM
exec "$BINDIR/erlexec" $FOREGROUNDOPTIONS \
-boot "$BOOTFILE" -mode "$CODE_LOADING_MODE" \
@@ -684,6 +733,9 @@ case "$1" in
-config "$RELX_CONFIG_PATH" \
-args_file "$VMARGS_PATH" \
-pa ${__code_paths} -- "$@"
+ # exec will replace the current image and nothing else gets
+ # executed from this point on, this explains the absence
+ # of the pre start hook
;;
rpc)
# Make sure a node IS running
@@ -741,7 +793,7 @@ case "$1" in
if [ "$IS_EXTENSION" = "1" ]; then
EXTENSION_SCRIPT=$(relx_get_extension_script $1)
shift
- relx_run_extension $EXTENSION_SCRIPT $@
+ relx_run_extension $EXTENSION_SCRIPT "$@"
# all extension scripts are expected to exit
else
relx_usage $1