X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02.git/blobdiff_plain/52fd74fc6af6a5c39927d7121b2845915dff9ad4..refs/heads/develop:/exec/bklog?ds=inline diff --git a/exec/bklog b/exec/bklog index a99468a..cc807a6 100644 --- a/exec/bklog +++ b/exec/bklog @@ -11,8 +11,8 @@ dirTmpDefault="/dev/shm"; # Default parent of working directory # Script Metadata scriptName="bklog"; # Define basename of script file. -scriptVersion="0.1.28-test4"; # Define version of script. -scriptURL="https://gitlab.com/baltakatei/ninfacyzga-01"; # Define wesite hosting this script. +scriptVersion="0.1.33"; # Define version of script. +scriptURL="https://gitlab.com/baltakatei/ninfacyzga-01"; # Define website hosting this script. scriptTimeStartEpoch="$(date +%s)"; # Save start time of script in epoch seconds scriptTimeStart="$(date +%Y%m%dT%H%M%S.%N)"; # YYYYmmddTHHMMSS.NNNNNNNNN scriptHostname=$(hostname); # Save hostname of system running this script. @@ -58,7 +58,7 @@ processArguments() { -p | --process-string) optionProcString="true" && argProcStrings+=("$2") && argProcFileExts+=("$3") && vbm "STATUS:file extension \"$3\" for output of processing string added:\"$2\""; shift; shift;; -l | --label) optionLabel="true" && argLabel="$2"; vbm "DEBUG :Custom label received:$argLabel"; shift;; -w | --store-raw) optionStoreRaw="true" && argRawFileExt="$2"; vbm "DEBUG :Raw stdin file extension received:$argRawFileExt"; shift;; - -W | --no-store-raw) optionNoStoreRaw="true"; vbm "DEBUG :Option selected to not store raw stdin data."; shift;; + -W | --no-store-raw) optionNoStoreRaw="true"; vbm "DEBUG :Option selected to not store raw stdin data.";; *) yell "ERROR: Unrecognized argument: $1"; yell "STATUS:All arguments:$*"; exit 1;; # Handle unrecognized options. esac shift @@ -1178,6 +1178,21 @@ magicSetScriptTTL() { fi; vbm "STATUS:$fn:Finished magicSetScriptTTL() function."; } # Set scriptTTL in seconds until next (day|hour). +magicVerboseReadout() { + vbm "$bufferTTL"; # Time-to-live (seconds) for each buffer round + vbm "$scriptTTL_TE"; # Time element at the end of which script terminates + vbm "$dirTmpDefault"; # Default parent of working directory + # Script Metadata + vbm "$scriptName"; # Basename of script file. + vbm "$scriptVersion"; # Version of script. + vbm "$scriptURL"; # Website hosting this script. + vbm "$scriptTimeStartEpoch"; # Start time of script in epoch seconds + vbm "$scriptTimeStart"; # YYYYmmddTHHMMSS.NNNNNNNNN + vbm "$scriptHostname" # Hostname of system running this script. + vbm "$PATH"; # PATH env. var. + vbm "$ageVersion"; # Version of age (encryption program) + vbm "$ageURL"; # Website hosting age. +} # Display script variables magicWriteVersion() { # Desc: Appends time-stamped VERSION to pathout_tar # Usage: magicWriteVersion @@ -1403,6 +1418,8 @@ main() { magicParseProcessStrings; # Sets arrays: procStrings, procFileExts ## React to "-l" (output file label) option magicParseLabel; # sets label (ex: "_location") + ## React to "-v" (verbose) option + magicVerboseReadout; # Display various script variables # Perform secondary setup operations ## Set script lifespan (scriptTTL from scriptTTL_TE) @@ -1436,15 +1453,21 @@ main() { while read -r -t "$bufferTTL" line && [[ $SECONDS -lt "$bufferTOD" ]]; do # Append line to buffer array buffer+=("$line"); - done; + done < /dev/stdin; + # End script if buffer array empty (ex: EOF found in stdin) + if [[ ${#buffer[@]} -eq 0 ]]; then + yell "ERROR:$fn:Empty array:buffer:${buffer[@]}"; exit 1; + fi; # Mark time for buffer ## Initial time - if [[ ! -z "$timeBufferEndEpoch" ]]; then + if [[ bufferRound -gt 0 ]]; then ### Usual case timeBufferStartEpoch="$timeBufferEndEpoch" && vbm "DEBUG :$fn:timeBufferStartEpoch:$timeBufferStartEpoch"; - else + elif [[ bufferRound -eq 0 ]]; then ### Edge case: initial startup timeBufferStartEpoch="$scriptTimeStartEpoch" && vbm "DEBUG :$fn:timeBufferStartEpoch:$timeBufferStartEpoch"; + else + yell "ERROR:$fn:Invalid bufferRound value."; exit 1; fi; ## End Time timeBufferEndEpoch="$(date +%s)" && vbm "DEBUG :$fn:timeBufferEndEpoch:$timeBufferEndEpoch";