From 447df9204eddb92e3ce8ace581add4e7bba040e1 Mon Sep 17 00:00:00 2001 From: erlanger Date: Sat, 23 Jan 2016 12:48:55 -0500 Subject: replacing OS vars: use .orig files to prevent overwriting --- priv/templates/extended_bin | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'priv/templates/extended_bin') diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index b752229..3c406aa 100755 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -98,9 +98,23 @@ if [ -z "$VMARGS_PATH" ]; then fi fi +orig_vmargs_path="$VMARGS_PATH.orig" if [ $RELX_REPLACE_OS_VARS ]; then - 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 + #Make sure we don't break dev mode by keeping the symbolic link to + #the user's vm.args + if [ ! -L "$orig_vmargs_path" ]; then + #we're in copy mode, rename the vm.args file to vm.args.orig + mv "$VMARGS_PATH" "$orig_vmargs_path" + fi + + awk '{while(match($0,"[$]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH -3);gsub("[$]{"var"}",ENVIRON[var])}}1' < "$orig_vmargs_path" > "$VMARGS_PATH" + else + #We don't need to replace env. vars, just rename the + #symlink vm.args.orig to vm.args, and keep it as a + #symlink. + if [ -L "$orig_vmargs_path" ]; then + mv "$orig_vmargs_path" "$VMARGS_PATH" + fi fi # Make sure log directory exists @@ -115,12 +129,23 @@ if [ -z "$RELX_CONFIG_PATH" ]; then fi fi +orig_relx_config_path="$RELX_CONFIG_PATH.orig" if [ $RELX_REPLACE_OS_VARS ]; then - #Make sure we don't break dev mode by keeping the symbolic link - orig_relx_config_path="$RELX_CONFIG_PATH.orig" - mv "$RELX_CONFIG_PATH" "$orig_relx_config_path" + #Make sure we don't break dev mode by keeping the symbolic link to + #the user's sys.config + if [ ! -L "$orig_relx_config_path" ]; then + #We're in copy mode, rename sys.config to sys.config.orig + mv "$RELX_CONFIG_PATH" "$orig_relx_config_path" + fi awk '{while(match($0,"[$]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH -3);gsub("[$]{"var"}",ENVIRON[var])}}1' < "$orig_relx_config_path" > "$RELX_CONFIG_PATH" + else + #We don't need to replace env. vars, just rename the + #symlink sys.config.orig to sys.config. Keep it as + #a symlink. + if [ -L "$orig_relx_config_path" ]; then + mv "$orig_relx_config_path" "$RELX_CONFIG_PATH" + fi fi # Extract the target node name from node.args -- cgit v1.2.3