When bpcdump starts, use a temporary file in /tmp to capture log output
from the info() and error() functions. Then, which the correct home for
the info file is created, move the temporary file to that name and
continue along.
Prior to this commit, all of the output from info() and error() prior to
INFO being redefined were not also captured into the info file.
VEMNT=/var/lib/vz/private/$VEID
EXTFS=/media/esata
unset WRITEPAR
VEMNT=/var/lib/vz/private/$VEID
EXTFS=/media/esata
unset WRITEPAR
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:$PATH
SCRIPT_EXT="conf start stop mount umount"
CONF_DIR=/etc/vz/conf
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:$PATH
SCRIPT_EXT="conf start stop mount umount"
CONF_DIR=/etc/vz/conf
+INFO=$(mktemp -q /tmp/bpcdump.XXXXX)
+STARTDATE=$(date)
+cat > "$INFO" <<+EOF+
+Date: $STARTDATE
+VEID: $VEID
+Volume: $VEDEV
+dd_rescue log: ddrlog
+dd_rescue bad blocks: ddrbb
+image file: image
+
++EOF+
+
trap "cleanup 1 \"termination by signal\"" SIGINT SIGTERM
if [ $(whoami) != "root" ]; then
trap "cleanup 1 \"termination by signal\"" SIGINT SIGTERM
if [ $(whoami) != "root" ]; then
else
rm -rf "$EXTVEIDFS"
fi
else
rm -rf "$EXTVEIDFS"
fi
-mkdir "$EXTVEIDFS"
-date > "$EXTVEIDFS/begin"
-if ! cd "$EXTVEIDFS"; then
- cleanup 1 "cannot change into $EXTVEIDFS directory"
-fi
+mkdir "$EXTVEIDFS" || cleanup 1 "cannot mkdir $EXTVEIDFS/"
+cd "$EXTVEIDFS" || cleanup 1 "cannot cd into $EXTVEIDFS/"
+echo "$STARTDATE" > "$EXTVEIDFS/begin"
+# Move temporary INFO file to its permanent home within $EXTVEIDFS
+mv "$INFO" "$EXTVEIDFS/info" || cleanup 1 "cannot mv file to $EXTVEIDFS/"
-cat > "$INFO" <<+EOF+
-Date: $(date)
-VEID: $VEID
-Volume: $VEDEV
-dd_rescue log: ddrlog
-dd_rescue bad blocks: ddrbb
-image file: image
info "copy $VEID device $VEDEV to $EXTVEIDFS/image"
time dd_rescue -Aqy 8192 -l "$EXTVEIDFS/ddrlog" -o "$EXTVEIDFS/ddrbb" \
$VEDEV "$EXTVEIDFS/image"
info "copy $VEID device $VEDEV to $EXTVEIDFS/image"
time dd_rescue -Aqy 8192 -l "$EXTVEIDFS/ddrlog" -o "$EXTVEIDFS/ddrbb" \
$VEDEV "$EXTVEIDFS/image"