diff options
author | erlanger <erlanger> | 2016-01-23 12:48:55 -0500 |
---|---|---|
committer | erlanger <erlanger> | 2016-01-23 13:56:01 -0500 |
commit | 447df9204eddb92e3ce8ace581add4e7bba040e1 (patch) | |
tree | 60c391947c8ab080ac4f70ad9fe538833bb0e564 /priv/templates/extended_bin | |
parent | 1b159fed973f30e545228b99494cf5c3680b30a0 (diff) | |
download | relx-447df9204eddb92e3ce8ace581add4e7bba040e1.tar.gz relx-447df9204eddb92e3ce8ace581add4e7bba040e1.tar.bz2 relx-447df9204eddb92e3ce8ace581add4e7bba040e1.zip |
replacing OS vars: use .orig files to prevent overwriting
Diffstat (limited to 'priv/templates/extended_bin')
-rwxr-xr-x | priv/templates/extended_bin | 35 |
1 files changed, 30 insertions, 5 deletions
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 |