From: Steven Baltakatei Sandoval Date: Sat, 11 Jul 2020 04:24:41 +0000 (+0000) Subject: test(bklog):Add debug messages in magic functions X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02.git/commitdiff_plain/6fe054b434681283f32521d432f604fe8c778376 test(bklog):Add debug messages in magic functions --- diff --git a/exec/bklog b/exec/bklog index af53431..cc0efa6 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.8"; # Define version of script. +scriptVersion="0.1.9"; # 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. @@ -796,7 +796,8 @@ magicInitWorkingDir() { # Parse '-t' option (user-specified temporary working dir) ## Set dir_tmp_parent to user-specified value if specified local dir_tmp_parent - + + vbm "Starting magicInitWorkingDir() function."; if [[ "$optionTmpDir" = "true" ]]; then if [[ -d "$argTempDirPriority" ]]; then dir_tmp_parent="$argTempDirPriority"; @@ -818,6 +819,7 @@ magicInitWorkingDir() { fi; ## Set dir_tmp using dir_tmp_parent and nonce (scriptTimeStart) dir_tmp="$dir_tmp_parent"/"$scriptTimeStart""..bkgpslog" && vbm "DEBUG:Set dir_tmp to:$dir_tmp"; # Note: removed at end of main(). + vbm "Finished magicInitWorkingDir() function."; } # Sets working dir magicInitCheckTar() { # Desc: Initializes or checks output tar @@ -826,6 +828,7 @@ magicInitCheckTar() { # output: vars: pathout_tar # depends: Bash 5.0.3, vbm(), dateShort(), checkMakeTar(), magicWriteVersion() + vbm "Starting magicInitCheckTar() function."; # Form pathout_tar pathout_tar="$dirOut"/"$(dateShort "$(date --date="$bufferTTL seconds ago" --iso-8601=seconds)")".."$scriptHostname""$label""$cmd_compress_suffix""$cmd_encrypt_suffix".tar && \ vbm "STATUS:Set pathout_tar to:$pathout_tar"; @@ -833,25 +836,29 @@ magicInitCheckTar() { checkMakeTar "$pathout_tar"; ## Add VERSION file if checkMakeTar had to create a tar (exited 1) or replace one (exited 2) vbm "exit status before magicWriteVersion:$?" - if [[ $? -eq 1 ]] || [[ $? -eq 2 ]]; then magicWriteVersion; fi + if [[ $? -eq 1 ]] || [[ $? -eq 2 ]]; then magicWriteVersion; fi + vbm "Finished magicInitCheckTar() function."; } # Initialize tar, set pathout_tar magicParseCompressionArg() { # Desc: Parses compression arguments specified by '-c' option # Input: vars: optionCompress # Output: cmd_compress, cmd_compress_suffix # Depends: processArguments(), vbm(), checkapp(), gzip 1.9 + + vbm "Starting magicParseCompressionArg() function."; if [[ "$optionCompress" = "true" ]]; then # Check if compression option active if checkapp gzip; then # Check if gzip available cmd_compress="gzip " && vbm "cmd_compress:$cmd_compress"; cmd_compress_suffix=".gz" && vbm "cmd_compress_suffix:$cmd_compress_suffix"; else yell "ERROR:Compression enabled but \"gzip\" not found. Exiting."; exit 1; - fi + fi; else cmd_compress="tee /dev/null " && vbm "cmd_compress:$cmd_compress"; cmd_compress_suffix="" && vbm "cmd_compress_suffix:$cmd_compress_suffix"; vbm "DEBUG:Compression not enabled."; - fi + fi; + vbm "Starting magicParseCompressionArg() function."; } # Form compression cmd string and filename suffix magicParseCustomTTL() { # Desc: Set user-specified TTLs for buffer and script @@ -862,6 +869,7 @@ magicParseCustomTTL() { # Output: bufferTTL (integer), scriptTTL_TE (string) # Depends: Bash 5.0.3, yell(), vbm(), validateInput(), showUsage() + vbm "Starting magicParseCustomTTL() function."; # React to '-b, --buffer-ttl' option if [[ "$optionCustomBufferTTL" = "true" ]]; then ## T: Check if argCustomBufferTTL is an integer @@ -886,7 +894,8 @@ magicParseCustomTTL() { yell "ERROR:Invalid time element argument for custom script time-to-live."; showUsage; exit 1; fi; ## F: do not change scriptTTL_TE - fi; + fi; + vbm "Starting magicParseCustomTTL() function."; } # Sets custom script or buffer TTL if specified magicParseLabel() { # Desc: Parses -l option to set label @@ -983,6 +992,7 @@ magicParseRecipientArgs() { # Depends: processArguments(), yell(), vbm(), checkapp(), checkAgePubkey(), validateInput() local recipients + vbm "Starting magicParseRecipientArgs() function."; # Check if encryption option active. if [[ "$optionEncrypt" = "true" ]] && [[ "$optionRecipients" = "true" ]]; then if checkapp age; then # Check that age is available. @@ -1020,7 +1030,8 @@ magicParseRecipientArgs() { yell "ERROR:\\'-e\\' set but no \\'-r\\' or \\'-R\\' set."; exit 1; fi; # Catch case if '-r' or '-R' set but '-e' is not if [[ ! "$optionEncrypt" = "true" ]] && [[ "$optionRecipients" = "true" ]]; then - yell "ERROR:\\'-r\\' or \\'-R\\' set but \\'-e\\' is not set."; exit 1; fi; + yell "ERROR:\\'-r\\' or \\'-R\\' set but \\'-e\\' is not set."; exit 1; fi; + vbm "Finished magicParseRecipientArgs() function."; } # Populate recPubKeysValid with argRecPubKeys; form encryption cmd string and filename suffix magicParseRecipientDir() { # Desc: Updates recPubKeysValid with pubkeys in dir specified by '-R' option ("recipient directory") @@ -1031,6 +1042,7 @@ magicParseRecipientDir() { local recipientDir recFileLine updateRecipients declare -a candRecPubKeysValid + vbm "Starting magicParseRecipientDir() function."; # Check that '-e' and '-R' set if [[ "$optionEncrypt" = "true" ]] && [[ "$optionRecDir" = "true" ]]; then ### Check that argRecDir is a directory. @@ -1066,6 +1078,7 @@ magicParseRecipientDir() { # Handle case if '-R' set but '-e' not set if [[ ! "$optionEncrypt" = "true" ]] && [[ "$optionRecDir" = "true" ]]; then yell "ERROR: \\'-R\\' is set but \\'-e\\' is not set."; fi; + vbm "Finished magicParseRecipientDir() function."; } # Update recPubKeysValid with argRecDir magicSetScriptTTL() { #Desc: Sets script_TTL seconds from provided time_element string argument @@ -1074,7 +1087,8 @@ magicSetScriptTTL() { #Output: var: scriptTTL (integer seconds) #Depends: timeUntilNextHour, timeUntilNextDay local argTimeElement - + + vbm "Starting magicSetScriptTTL() function."; argTimeElement="$1"; if [[ "$argTimeElement" = "day" ]]; then # Set script lifespan to end at start of next day @@ -1097,6 +1111,7 @@ magicSetScriptTTL() { else yell "ERROR:Invalid argument for setScriptTTL function:$argTimeElement"; exit 1; fi; + vbm "Finished magicSetScriptTTL() function."; } # Set scriptTTL in seconds until next (day|hour). magicWriteVersion() { # Desc: Appends time-stamped VERSION to pathout_tar @@ -1107,7 +1122,8 @@ magicWriteVersion() { # Output: appends tar (pathout_tar) # Depends: bash 5.0.3, dateTimeShort(), appendArgTar() local fileoutVersion contentVersion pubKeyIndex pubKeyIndex - + + vbm "Starting magicWriteVersion() function."; # Set VERSION file name fileoutVersion="$(dateTimeShort)..VERSION"; @@ -1130,6 +1146,7 @@ magicWriteVersion() { # Write contentVersion as file fileoutVersion and write-append to pathout_tar appendArgTar "$contentVersion" "$fileoutVersion" "$pathout_tar" "$dir_tmp"; + vbm "Finished magicWriteVersion() function."; } # write version data to pathout_tar via appendArgTar() magicProcessWriteBuffer() { # Desc: process and write buffer