X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02.git/blobdiff_plain/b0da06cadad861ae678fbc473e5760292791cc5a..1f2681284c87d5cde538a0eb18c49b0916b9743e:/exec/bkgpslog diff --git a/exec/bkgpslog b/exec/bkgpslog index eeed3a6..840a0c6 100755 --- a/exec/bkgpslog +++ b/exec/bkgpslog @@ -214,8 +214,8 @@ processArguments() { -r | --recipient) # Add 'age' recipient via public key string recPubKeys+=("$2"); vbm "pubkey added:""$2"; shift;; -c | --compress) OPTION_COMPRESS="true"; vbm "DEBUG:Compressed output mode enabled.";; - -z | --time-zone) try setTimeZoneEV "$2";; - -t | --temp-dir) OPTION_TMPDIR="true" && TMP_DIR_PRIORITY="$2";; + -z | --time-zone) try setTimeZoneEV "$2"; shift;; + -t | --temp-dir) OPTION_TMPDIR="true" && TMP_DIR_PRIORITY="$2"; shift;; *) echoerr "ERROR: Unrecognized argument: $1"; echoerr "STATUS:All arguments:$*"; exit 1;; # Handle unrecognized options. esac shift @@ -698,8 +698,19 @@ main() { PATHOUT_TAR="$DIR_OUT"/"$(dateShort)".."$SCRIPT_HOSTNAME""_location""$CMD_COMPRESS_SUFFIX""$CMD_ENCRYPT_SUFFIX".tar ## Write bkgpslog version to DIR_TMP/VERSION echo "$0"" Version:""$SCRIPT_VERSION" >> "$DIR_TMP/VERSION" && vbm "DEBUG:VERSION created." - ## Create empty tar archive at PATHOUT_TAR - try tar --create --directory="$DIR_TMP" --file="$PATHOUT_TAR" --files-from=/dev/null && vbm "DEBUG:""$PATHOUT_TAR"" created." + ## Check if PATHOUT_TAR already exists. + if [[ -f "$PATHOUT_TAR" ]]; then + ### Check if preexisting tar is appendable. + PATHOUT_APPENDTEST="$DIR_TMP"/"$(dateTimeShort)..append_test.txt" + echo "$(dateTimeShort)" >> "$PATHOUT_APPENDTEST"; && vbm "DEBUG:""$PATHOUT_APPENDTEST"" created." + if ! tar --append --directory="$DIR_TMP" --file="$PATHOUT_TAR" "$(basename "$PATHOUT_APPENDTEST")"; then + ### If not appendable, label tar broken, move tar, proceed. + mv "$PATHOUT_TAR" "${PATHOUT_TAR%.*}""-broken$(dateTimeShort)".tar + fi + else + ### If (no preexisting|appendable) tar found, create empty tar archive at PATHOUT_TAR + try tar --create --directory="$DIR_TMP" --file="$PATHOUT_TAR" --files-from=/dev/null && vbm "DEBUG:""$PATHOUT_TAR"" created." + fi ## Append VERSION file to PATHOUT_TAR try tar --append --directory="$DIR_TMP" --file="$PATHOUT_TAR" "VERSION" && vbm "DEBUG:VERSION added to $PATHOUT_TAR"