X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02.git/blobdiff_plain/236c8b97f828fa0d58474ef028592ff0ff435790..195dd3c3d00d0621ae84af52eca3e2040f80d738:/exec/bklog?ds=sidebyside diff --git a/exec/bklog b/exec/bklog index 5ab7fb6..ecc31d8 100644 --- a/exec/bklog +++ b/exec/bklog @@ -11,7 +11,7 @@ dirTmpDefault="/dev/shm"; # Default parent of working directory # Script Metadata scriptName="bklog"; # Define basename of script file. -scriptVersion="0.1.15"; # Define version of script. +scriptVersion="0.1.19"; # Define version of script. scriptURL="https://gitlab.com/baltakatei/ninfacyzga-01"; # Define wesite hosting this script. scriptTimeStart="$(date +%Y%m%dT%H%M%S.%N)"; # YYYYmmddTHHMMSS.NNNNNNNNN scriptHostname=$(hostname); # Save hostname of system running this script. @@ -787,7 +787,7 @@ magicInitCheckTar() { # input: vars: scriptHostname # output: vars: pathout_tar # depends: Bash 5.0.3, vbm(), dateShort(), checkMakeTar(), magicWriteVersion() - local fn + local fn checkMakeTarES # Save function name fn="${FUNCNAME[0]}"; @@ -797,10 +797,10 @@ magicInitCheckTar() { pathout_tar="$dirOut"/"$(dateShort "$(date --date="$bufferTTL seconds ago" --iso-8601=seconds)")".."$scriptHostname""$label""$cmd_compress_suffix""$cmd_encrypt_suffix".tar && \ vbm "STATUS:$fn:Set pathout_tar to:$pathout_tar"; # Validate pathout_tar as tar. - checkMakeTar "$pathout_tar"; + checkMakeTar "$pathout_tar"; checkMakeTarES="$?"; ## Add VERSION file if checkMakeTar had to create a tar (exited 1) or replace one (exited 2) - vbm "STATUS:$fn:exit status before magicWriteVersion:$?" - if [[ $? -eq 1 ]] || [[ $? -eq 2 ]]; then magicWriteVersion; fi + vbm "STATUS:$fn:exit status before magicWriteVersion:$checkMakeTarES" + if [[ "$checkMakeTarES" -eq 1 ]] || [[ "$checkMakeTarES" -eq 2 ]]; then magicWriteVersion; fi vbm "STATUS:$fn:Finished magicInitCheckTar() function."; } # Initialize tar, set pathout_tar magicParseCompressionArg() { @@ -914,28 +914,40 @@ magicParseProcessStrings() { # Validate input ## Validate argRawFileExt if [[ "$argRawFileExt" =~ ^[.][[:alnum:]]*$ ]]; then - rawFileExt="$argRawFileExt"; + rawFileExt="$argRawFileExt" && \ + vbm "DEBUG :$fn:Set rawFileExt to \"$argRawFileExt\""; + else + vbm "DEBUG :$fn:Validation failure for $argRawFileExt . Not set to rawFileExt."; fi; # Add default stdin output file entries for procStrings, procFileExts ## Check if user specified that no raw stdin be saved. if [[ ! "$optionNoStoreRaw" = "true" ]]; then ### T: --no-store-raw not set. Store raw. Append procStrings with cat. + vbm "DEBUG :$fn:--no-store-raw not set. Storing raw."; #### Append procStrings array - procStrings+=("cat "); + procStrings+=("cat ") && \ + vbm "DEBUG :$fn:Appended \"cat \" to procStrings"; + vbm "DEBUG :$fn:procStrings array:${procStrings[*]}"; #### Check if --store-raw set. if [[ "$optionStoreRaw" = "true" ]]; then ##### T: --store-raw set. Append procFileExts with user-specified file ext - procFileExts+=("$rawFileExt"); + vbm "DEBUG :$fn:--store-raw set."; + procFileExts+=("$rawFileExt") && \ + vbm "DEBUG :$fn:Appended $rawFileExt to procFileExts"; + vbm "STATUS:$fn:procFileExts array:${procFileExts[*]}"; else ##### F: --store-raw not set. Append procFileExts with default ".stdin" file ext ###### Append procFileExts array - procFileExts+=(".stdin"); + procFileExts+=(".stdin") && \ + vbm "DEBUG :$fn:Appended \".stdin\" to procFileExts"; + vbm "STATUS:$fn:procFileExts array:${procFileExts[*]}"; fi; else ### F: --no-store-raw set. Do not store raw. #### Do not append procStrings or procFileExts arrays. - : + vbm "STATUS:$fn:--no-store-raw set. Not storing raw."; + vbm "STATUS:$fn:procFileExts array:${procFileExts[*]}"; fi; # Do nothing more if optionProcString not set to true. @@ -958,8 +970,10 @@ magicParseProcessStrings() { yell "ERROR:$fn:Illegal character '-' at start of process string element:\"$element\""; exit 1; fi; done; vbm "STATUS:$fn:Quick check shows argProcStrings and argProcFileExts appear to have valid contents."; - procStrings=("${argProcStrings[@]}"); # Export process command strings - procFileExts=("${argProcFileExts[@]}"); # Export process command strings + vbm "STATUS:$fn:argProcStrings:${argProcStrings[*]}" + vbm "STATUS:$fn:argProcStrings:${argProcFileExts[*]}" + procStrings+=("${argProcStrings[@]}"); # Export process command strings + procFileExts+=("${argProcFileExts[@]}"); # Export process command strings vbm "STATUS:$fn:Finished magicParseProcessStrings() function."; } # Validate and save process strings and file extensions to arrays procStrings, procFileExts magicParseRecipients() { @@ -1152,6 +1166,10 @@ magicProcessWriteBuffer() { fn="${FUNCNAME[0]}"; vbm "STATUS:$fn:Started magicProcessWriteBuffer()."; + vbm "DEBUG :$fn:buffer array element count:${#buffer[@]}"; + vbm "DEBUG :$fn:buffer array first element:${buffer[0]}"; + vbm "DEBUG :$fn:buffer array last element :${buffer[-1]}"; + # Determine file paths (time is start of buffer period) ## Calculate start time timeBufferStartLong="$(date --date="$bufferTTL seconds ago" --iso-8601=seconds)" && \ @@ -1185,7 +1203,7 @@ magicProcessWriteBuffer() { for index in "${!pathouts[@]}"; do writeCmd2="${procStrings[$index]}"; writeCmdAll="$writeCmd1 | $writeCmd2 | $writeCmd3 | $writeCmd4" && vbm "STATUS:$fn:Assembled command:\"$writeCmdAll\""; - eval "$writeCmdAll" >> "${pathouts[$index]}" && vbm "STATUS:$fn:Wrote command output to ${pathouts[$index]}"; + eval "$writeCmd1 | $writeCmd2 | $writeCmd3 | $writeCmd4" > "${pathouts[$index]}" && vbm "STATUS:$fn:Wrote command output to ${pathouts[$index]}"; done; # Append dir_tmp files to pathout_tar @@ -1313,7 +1331,9 @@ main() { ## Init temp working dir try mkdir "$dir_tmp" && vbm "DEBUG :$fn:Working dir created at dir_tmp:$dir_tmp"; ## Initialize output tar (set pathout_tar) - magicInitCheckTar; + magicInitCheckTar; + ## Append VERSION file to tar + magicWriteVersion; # Check vital apps, files, dirs if ! checkapp tar && ! checkdir "$dirOut" "dir_tmp"; then