Skip to content

Commit

Permalink
Rename the meaningless REAR_LOGFILE to RUNTIME_LOGFILE to make its na…
Browse files Browse the repository at this point in the history
…me tell what it actually is (issue1119)
  • Loading branch information
jsmeix committed Dec 12, 2016
1 parent 6ac5bcc commit 3a76a17
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
26 changes: 13 additions & 13 deletions usr/sbin/rear
Expand Up @@ -323,7 +323,7 @@ for simultaneous_runnable_workflow in "${SIMULTANEOUS_RUNNABLE_WORKFLOWS[@]}" ;
if test "$WORKFLOW" = "$simultaneous_runnable_workflow" ; then
# Simultaneously runnable workflows require unique logfile names
# so that the PID is interposed in the LOGFILE value from default.conf
# which is used below as REAR_LOGFILE while the workflow is running
# which is used below as RUNTIME_LOGFILE while the workflow is running
# and at the end it gets copied to a possibly used-defined LOGFILE.
# The logfile_suffix also works for logfile names without '.*' suffix
# (in this case ${LOGFILE##*.} returns the whole $LOGFILE value):
Expand Down Expand Up @@ -358,12 +358,12 @@ fi
mkdir -p $LOG_DIR

exec 2>"$LOGFILE" || echo "ERROR: Could not create $LOGFILE" >&2
# Keep our currently used LOGFILE in a seperate variable REAR_LOGFILE
# Keep our currently used LOGFILE in a seperate variable RUNTIME_LOGFILE
# in case end-user overruled it in the local.conf file:
readonly REAR_LOGFILE="$LOGFILE"
readonly RUNTIME_LOGFILE="$LOGFILE"

# Include functions after LOGFILE and REAR_LOGFILE are set
# because some functions use LOGFILE or REAR_LOGFILE:
# Include functions after LOGFILE and RUNTIME_LOGFILE are set
# because some functions use LOGFILE or RUNTIME_LOGFILE:
for script in $SHARE_DIR/lib/*.sh ; do
source $script
done
Expand All @@ -372,7 +372,7 @@ done
if test "$WORKFLOW" != "help" ; then
LogPrint "$PRODUCT $VERSION / $RELEASE_DATE"
Log "Command line options: $0 ${CMD_OPTS[@]}"
LogPrint "Using log file: $REAR_LOGFILE"
LogPrint "Using log file: $RUNTIME_LOGFILE"
fi

# In DEBUG mode keep by default the build area but that can be overridden in user config files
Expand Down Expand Up @@ -502,13 +502,13 @@ else
EXIT_CODE=1
fi

# Usually REAR_LOGFILE=/var/log/rear/rear-$HOSTNAME.log
# The REAR_LOGFILE name set by main script from LOGFILE in default.conf
# but later user config files are sourced in main script where LOGFILE can be set different
# so that the user config LOGFILE setting is used as final logfile name:
if test "$REAR_LOGFILE" != "$LOGFILE" ; then
LogPrint "Saving $REAR_LOGFILE as $LOGFILE"
cat "$REAR_LOGFILE" > "$LOGFILE"
# Usually RUNTIME_LOGFILE=/var/log/rear/rear-$HOSTNAME.log
# The RUNTIME_LOGFILE name is set by the main script from LOGFILE in default.conf
# but later user config files are sourced in the main script where LOGFILE can be set different
# so that the user config LOGFILE is used as final logfile name:
if test "$RUNTIME_LOGFILE" != "$LOGFILE" ; then
LogPrint "Saving $RUNTIME_LOGFILE as $LOGFILE"
cat "$RUNTIME_LOGFILE" > "$LOGFILE"
fi

if test $EXIT_CODE -eq 0 ; then
Expand Down
4 changes: 2 additions & 2 deletions usr/share/rear/lib/_input-output-functions.sh
Expand Up @@ -74,7 +74,7 @@ readonly MASTER_PID=$$
exec 7>&1
QuietAddExitTask "exec 7>&-"
# USR1 is used to abort on errors, not using Print to always print to the original STDOUT, even if quiet
builtin trap "echo '${MESSAGE_PREFIX}Aborting due to an error, check $REAR_LOGFILE for details' >&7 ; kill $MASTER_PID" USR1
builtin trap "echo '${MESSAGE_PREFIX}Aborting due to an error, check $RUNTIME_LOGFILE for details' >&7 ; kill $MASTER_PID" USR1

# make sure nobody else can use trap
function trap () {
Expand Down Expand Up @@ -155,7 +155,7 @@ BUG in $caller_source:
'$@'
--------------------
Please report this issue at https://github.com/rear/rear/issues
and include the relevant parts from $REAR_LOGFILE
and include the relevant parts from $RUNTIME_LOGFILE
preferably with full debug information via 'rear -d -D $WORKFLOW'
===================="
}
Expand Down
10 changes: 5 additions & 5 deletions usr/share/rear/output/default/950_copy_result_files.sh
Expand Up @@ -19,13 +19,13 @@ if test -s $(get_template "RESULT_usage_$OUTPUT.txt") ; then
StopIfError "Could not copy '$(get_template RESULT_usage_$OUTPUT.txt)'"
fi

# Usually REAR_LOGFILE=/var/log/rear/rear-$HOSTNAME.log
# The REAR_LOGFILE name set by main script from LOGFILE in default.conf
# but later user config files are sourced in main script where LOGFILE can be set different
# Usually RUNTIME_LOGFILE=/var/log/rear/rear-$HOSTNAME.log
# The RUNTIME_LOGFILE name is set by the main script from LOGFILE in default.conf
# but later user config files are sourced in the main script where LOGFILE can be set different
# so that the user config LOGFILE basename is used as final logfile name:
final_logfile_name=$( basename $LOGFILE )
cat "$REAR_LOGFILE" > "$TMP_DIR/$final_logfile_name" || Error "Could not copy $REAR_LOGFILE to $TMP_DIR/$final_logfile_name"
LogPrint "Saving $REAR_LOGFILE as $final_logfile_name to $scheme location"
cat "$RUNTIME_LOGFILE" > "$TMP_DIR/$final_logfile_name" || Error "Could not copy $RUNTIME_LOGFILE to $TMP_DIR/$final_logfile_name"
LogPrint "Saving $RUNTIME_LOGFILE as $final_logfile_name to $scheme location"

# Add the README, VERSION and the final logfile to the RESULT_FILES array
RESULT_FILES=( "${RESULT_FILES[@]}" "$TMP_DIR/VERSION" "$TMP_DIR/README" "$TMP_DIR/$final_logfile_name" )
Expand Down
10 changes: 5 additions & 5 deletions usr/share/rear/rescue/default/910_copy_logfile.sh
@@ -1,10 +1,10 @@
# Copy current unfinished logfile to initramfs for debug purpose.
# Usually REAR_LOGFILE=/var/log/rear/rear-$HOSTNAME.log
# The REAR_LOGFILE name set by main script from LOGFILE in default.conf
# but later user config files are sourced in main script where LOGFILE can be set different
# Usually RUNTIME_LOGFILE=/var/log/rear/rear-$HOSTNAME.log
# The RUNTIME_LOGFILE name is set by the main script from LOGFILE in default.conf
# but later user config files are sourced in the main script where LOGFILE can be set different
# so that the user config LOGFILE basename (except a trailing '.log') is used as target logfile name:
logfile_basename=$( basename $LOGFILE )
LogPrint "Copying logfile $REAR_LOGFILE into initramfs as '/tmp/${logfile_basename%.*}-partial-$(date -Iseconds).log'"
LogPrint "Copying logfile $RUNTIME_LOGFILE into initramfs as '/tmp/${logfile_basename%.*}-partial-$(date -Iseconds).log'"
mkdir -p $v $ROOTFS_DIR/tmp >&2
cp -a $v $REAR_LOGFILE $ROOTFS_DIR/tmp/${logfile_basename%.*}-partial-$(date -Iseconds).log >&2
cp -a $v $RUNTIME_LOGFILE $ROOTFS_DIR/tmp/${logfile_basename%.*}-partial-$(date -Iseconds).log >&2

0 comments on commit 3a76a17

Please sign in to comment.