From d14c8c8fd64fdc945c1c021e6232ed96005ecd73 Mon Sep 17 00:00:00 2001 From: Steven Baltakatei Sandoval Date: Fri, 10 Jul 2020 02:44:45 +0000 Subject: [PATCH] chore(bkgpslog):Change allcaps varnames to lower/uppercase --- exec/bkgpslog | 82 +++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/exec/bkgpslog b/exec/bkgpslog index 58b0465..04e41ff 100755 --- a/exec/bkgpslog +++ b/exec/bkgpslog @@ -3,19 +3,19 @@ #==BEGIN Define script parameters== ## Logging Behavior parameters -BUFFER_TTL="300"; # time between file writes -SCRIPT_TTL_TE="day"; # (day|hour) +bufferTTL="300"; # time between file writes +scriptTTL_TE="day"; # (day|hour) #### TZ="UTC"; export TZ; # Default time zone; overridden by '--time-zone=[str]' option -DIR_TMP_DEFAULT="/dev/shm"; # Default parent of working directory +dirTmpDefault="/dev/shm"; # Default parent of working directory -SCRIPT_TIME_START=$(date +%Y%m%dT%H%M%S.%N); +scriptTimeStart=$(date +%Y%m%dT%H%M%S.%N); PATH="$HOME/.local/bin:$PATH"; # Add "$(systemd-path user-binaries)" path in case apps saved there -SCRIPT_HOSTNAME=$(hostname); # Save hostname of system running this script. -SCRIPT_VERSION="0.5.7"; # Define version of script. -SCRIPT_NAME="bkgpslog"; # Define basename of script file. -SCRIPT_URL="https://gitlab.com/baltakatei/ninfacyzga-01"; # Define wesite hosting this script. -AGE_VERSION="1.0.0-beta2"; # Define version of age (encryption program) -AGE_URL="https://github.com/FiloSottile/age/releases/tag/v1.0.0-beta2"; # Define website hosting age. +scriptHostname=$(hostname); # Save hostname of system running this script. +scriptVersion="0.5.7"; # Define version of script. +scriptName="bkgpslog"; # Define basename of script file. +scriptURL="https://gitlab.com/baltakatei/ninfacyzga-01"; # Define wesite hosting this script. +ageVersion="1.0.0-beta2"; # Define version of age (encryption program) +ageURL="https://github.com/FiloSottile/age/releases/tag/v1.0.0-beta2"; # Define website hosting age. declare -Ag appRollCall # Associative array for storing app status declare -Ag fileRollCall # Associative array for storing file status @@ -180,7 +180,7 @@ showUsage() { echoerr "-o ~/Sync/Location" } # Display information on how to use this script. showVersion() { - echoerr "$SCRIPT_VERSION" + echoerr "$scriptVersion" } # Display script version. vbm() { # Usage: vbm "DEBUG:verbose message here" @@ -645,7 +645,7 @@ displayMissing() { magicSetScriptTTL() { #Desc: Sets script_TTL seconds from provided time_element string argument #Usage: magicSetScriptTTL [str time_element] - #Input: arg1: string (Ex: SCRIPT_TTL_TE; "day" or "hour") + #Input: arg1: string (Ex: scriptTTL_TE; "day" or "hour") #Output: var: SCRIPT_TTL (integer seconds) #Depends: timeUntilNextHour, timeUntilNextDay local argTimeElement @@ -929,8 +929,8 @@ timeEpochNS() { echo "$TIME_EPOCH_NS"; } # Nanoseconds since 1970-01-01 magicBufferSleepPID() { - # Desc: Compensates for lag so buffer rounds start every BUFFER_TTL seconds - # Input: vars: BUFFER_TTL, errResetx10e3, K_P, T_I, T_D + # Desc: Compensates for lag so buffer rounds start every bufferTTL seconds + # Input: vars: bufferTTL, errResetx10e3, K_P, T_I, T_D # # Input: array: errorHistory # Output: vars: BUFFER_TTL_ADJ_FLOAT # Re/Attrib: https://en.wikipedia.org/wiki/PID_controller#Standard_versus_parallel_(ideal)_form @@ -1015,7 +1015,7 @@ magicWriteVersion() { # Usage: magicWriteVersion # Version: 0.1.0 # Input: CONTENT_VERSION, FILEOUT_VERSION, PATHOUT_TAR, DIR_TMP - # Input: SCRIPT_VERSION, SCRIPT_URL, AGE_VERSION, AGE_URL, SCRIPT_HOSTNAME + # Input: scriptVersion, scriptURL, ageVersion, ageURL, scriptHostname # Output: appends tar PATHOUT_TAR # Depends: dateTimeShort, appendArgTar local CONTENT_VERSION pubKeyIndex @@ -1024,14 +1024,14 @@ magicWriteVersion() { FILEOUT_VERSION="$(dateTimeShort)..VERSION"; # Gather VERSION data in CONTENT_VERSION - CONTENT_VERSION="SCRIPT_VERSION=$SCRIPT_VERSION"; + CONTENT_VERSION="scriptVersion=$scriptVersion"; #CONTENT_VERSION="$CONTENT_VERSION""\\n"; - CONTENT_VERSION="$CONTENT_VERSION""\\n""SCRIPT_NAME=$SCRIPT_NAME"; - CONTENT_VERSION="$CONTENT_VERSION""\\n""SCRIPT_URL=$SCRIPT_URL"; - CONTENT_VERSION="$CONTENT_VERSION""\\n""AGE_VERSION=$AGE_VERSION"; - CONTENT_VERSION="$CONTENT_VERSION""\\n""AGE_URL=$AGE_URL"; + CONTENT_VERSION="$CONTENT_VERSION""\\n""scriptName=$scriptName"; + CONTENT_VERSION="$CONTENT_VERSION""\\n""scriptURL=$scriptURL"; + CONTENT_VERSION="$CONTENT_VERSION""\\n""ageVersion=$ageVersion"; + CONTENT_VERSION="$CONTENT_VERSION""\\n""ageURL=$ageURL"; CONTENT_VERSION="$CONTENT_VERSION""\\n""DATE=$(date --iso-8601=seconds)"; - CONTENT_VERSION="$CONTENT_VERSION""\\n""HOSTNAME=$SCRIPT_HOSTNAME"; + CONTENT_VERSION="$CONTENT_VERSION""\\n""HOSTNAME=$scriptHostname"; ## Add list of recipient pubkeys for pubkey in "${recPubKeysValid[@]}"; do ((pubKeyIndex++)) @@ -1047,7 +1047,7 @@ magicWriteVersion() { magicGatherWriteBuffer() { # Desc: bkgpslog-specific meta function for writing data to DIR_TMP then appending each file to PATHOUT_TAR # Inputs: vars: PATHOUT_TAR FILEOUT_{NMEA,GPX,KML} CMD_CONV_{NMEA,GPX,KML} CMD_{COMPRESS,ENCRYPT} DIR_TMP, - # Inputs: vars: BUFFER_TTL bufferTTL_STR SCRIPT_HOSTNAME CMD_COMPRESS_SUFFIX CMD_ENCRYPT_SUFFIX + # Inputs: vars: BUFFER_TTL bufferTTL_STR scriptHostname CMD_COMPRESS_SUFFIX CMD_ENCRYPT_SUFFIX # Output: file: (PATHOUT_TAR) # Depends: yell(), try(), vbm(), appendArgTar(), tar 1, sleep 8, checkMakeTar() # Depends: magicWriteVersion(), appendFileTar() @@ -1064,7 +1064,7 @@ magicGatherWriteBuffer() { timeBufferStartLong="$(date --date="$BUFFER_TTL seconds ago" --iso-8601=seconds)" && vbm "timeBufferStartLong:$timeBufferStartLong" || yell "ERROR:timeBufferStartLong fail"; timeBufferStart="$(dateTimeShort "$timeBufferStartLong" )" && vbm "timeBufferStart:$timeBufferStart" || yell "ERROR:timeBufferStart fail"; # Note start time # Determine file paths (time is start of buffer period) - FILEOUT_BASENAME="$timeBufferStart""--""$bufferTTL_STR""..""$SCRIPT_HOSTNAME""_location" && vbm "STATUS:Set FILEOUT_BASENAME to:$FILEOUT_BASENAME"; + FILEOUT_BASENAME="$timeBufferStart""--""$bufferTTL_STR""..""$scriptHostname""_location" && vbm "STATUS:Set FILEOUT_BASENAME to:$FILEOUT_BASENAME"; ## Files saved to DIR_TMP FILEOUT_NMEA="$FILEOUT_BASENAME".nmea"$CMD_COMPRESS_SUFFIX""$CMD_ENCRYPT_SUFFIX" && vbm "STATUS:Set FILEOUT_NMEA to:$FILEOUT_NMEA"; FILEOUT_GPX="$FILEOUT_BASENAME".gpx"$CMD_COMPRESS_SUFFIX""$CMD_ENCRYPT_SUFFIX" && vbm "STATUS:Set FILEOUT_GPX to:$FILEOUT_GPX"; @@ -1074,7 +1074,7 @@ magicGatherWriteBuffer() { PATHOUT_KML="$DIR_TMP"/"$FILEOUT_KML" && vbm "STATUS:Set PATHOUT_KML to:$PATHOUT_KML"; ## Files saved to disk (DIR_OUT) ### one file per day (Ex: "20200731..hostname_location.[.gpx.gz].tar") - PATHOUT_TAR="$DIR_OUT"/"$(dateShort "$(date --date="$BUFFER_TTL seconds ago" --iso-8601=seconds)")".."$SCRIPT_HOSTNAME""_location""$CMD_COMPRESS_SUFFIX""$CMD_ENCRYPT_SUFFIX".tar && \ + PATHOUT_TAR="$DIR_OUT"/"$(dateShort "$(date --date="$BUFFER_TTL seconds ago" --iso-8601=seconds)")".."$scriptHostname""_location""$CMD_COMPRESS_SUFFIX""$CMD_ENCRYPT_SUFFIX".tar && \ vbm "STATUS:Set PATHOUT_TAR to:$PATHOUT_TAR"; # DEBUG: check vars vbm "STATUS:FN :$FN"; @@ -1219,8 +1219,8 @@ magicParseCompressionArg() { magicInitWorkingDir() { # Desc: Determine temporary working directory from defaults or user input # Usage: magicInitWorkignDir - # Input: vars: OPTION_TEMPDIR, argTempDirPriority, DIR_TMP_DEFAULT - # Input: vars: SCRIPT_TIME_START + # Input: vars: OPTION_TEMPDIR, argTempDirPriority, dirTmpDefault + # Input: vars: scriptTimeStart # Output: vars: DIR_TMP # Depends: processArguments(), vbm(), yell() # Parse '-t' option (user-specified temporary working dir) @@ -1236,25 +1236,25 @@ magicInitWorkingDir() { fi; else ## Set DIR_TMP_PARENT to default or fallback otherwise - if [[ -d "$DIR_TMP_DEFAULT" ]]; then - DIR_TMP_PARENT="$DIR_TMP_DEFAULT"; + if [[ -d "$dirTmpDefault" ]]; then + DIR_TMP_PARENT="$dirTmpDefault"; elif [[ -d /tmp ]]; then - yell "WARNING:$DIR_TMP_DEFAULT not available. Falling back to /tmp ."; + yell "WARNING:$dirTmpDefault not available. Falling back to /tmp ."; DIR_TMP_PARENT="/tmp"; else yell "ERROR:No valid working directory available. Exiting."; exit 1; fi fi; - ## Set DIR_TMP using DIR_TMP_PARENT and nonce (SCRIPT_TIME_START) - DIR_TMP="$DIR_TMP_PARENT"/"$SCRIPT_TIME_START""..bkgpslog" && vbm "DEBUG:Set DIR_TMP to:$DIR_TMP"; # Note: removed at end of main(). + ## 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(). } # Sets working dir magicParseCustomTTL() { # Desc: Set user-specified TTLs for buffer and script # Input: vars: argCustomBufferTTL (integer), argCustomScriptTTL_TE (string) # Input: vars: OPTION_CUSTOM_BUFFERTTL, OPTION_CUSTOM_SCRIPTTTL - # Input: vars: BUFFER_TTL (integer), SCRIPT_TTL_TE (string) - # Output: BUFFER_TTL (integer), SCRIPT_TTL_TE (string) + # Input: vars: BUFFER_TTL (integer), scriptTTL_TE (string) + # Output: BUFFER_TTL (integer), scriptTTL_TE (string) # Depends validateInput(), showUsage(), yell # React to '-b, --buffer-ttl' option @@ -1275,12 +1275,12 @@ magicParseCustomTTL() { ## T: Check if argCustomScriptTTL is a time element (ex: "day", "hour") if validateInput "$argCustomScriptTTL" "time_element"; then ### T: argCustomScriptTTL is a time element - SCRIPT_TTL_TE="$argCustomScriptTTL" && vbm "Custom SCRIPT_TTL_TE from -B:$SCRIPT_TTL_TE"; + scriptTTL_TE="$argCustomScriptTTL" && vbm "Custom scriptTTL_TE from -B:$scriptTTL_TE"; else ### F: argcustomScriptTTL is not a time element yell "ERROR:Invalid time element argument for custom script time-to-live."; showUsage; exit 1; fi; - ## F: do not change SCRIPT_TTL_TE + ## F: do not change scriptTTL_TE fi; } # Sets custom script or buffer TTL if specified @@ -1301,26 +1301,26 @@ main() { #### React to "-R" ("recipient directory") option magicParseRecipientDir; # Updates recPubKeysValid #### React to custom buffer and script TTL options ("-b", "-B") - magicParseCustomTTL; # Sets custom SCRIPT_TTL_TE and/or BUFFER_TTL if specified + magicParseCustomTTL; # Sets custom scriptTTL_TE and/or bufferTTL if specified # Check that critical apps and dirs are available, display missing ones. if ! checkapp gpspipe tar && ! checkdir "$DIR_OUT" "DIR_TMP"; then yell "ERROR:Critical components missing."; displayMissing; yell "Exiting."; exit 1; fi - # Set script lifespan (SCRIPT_TTL from SCRIPT_TTL_TE) - magicSetScriptTTL "$SCRIPT_TTL_TE"; - ## Note: SCRIPT_TTL_TE is time element string (ex: "day") while SCRIPT_TTL is integer seconds + # Set script lifespan (SCRIPT_TTL from scriptTTL_TE) + magicSetScriptTTL "$scriptTTL_TE"; + ## Note: scriptTTL_TE is time element string (ex: "day") while SCRIPT_TTL is integer seconds # File name substring (ISO-8601 duration from BUFFER_TTL) - bufferTTL_STR="$(timeDuration "$BUFFER_TTL")" && vbm "DEBUG:bufferTTL_STR:$bufferTTL_STR"; + bufferTTL_STR="$(timeDuration "$bufferTTL")" && vbm "DEBUG:bufferTTL_STR:$bufferTTL_STR"; # Init temp working dir try mkdir "$DIR_TMP" && vbm "DEBUG:Working dir created at DIR_TMP:$DIR_TMP"; # Initialize 'tar' archive ## Define output tar path (note: each day gets *one* tar file (Ex: "20200731..hostname_location.[.gpx.gz].tar")) - PATHOUT_TAR="$DIR_OUT"/"$(dateShort)".."$SCRIPT_HOSTNAME""_location""$CMD_COMPRESS_SUFFIX""$CMD_ENCRYPT_SUFFIX".tar && \ + PATHOUT_TAR="$DIR_OUT"/"$(dateShort)".."$scriptHostname""_location""$CMD_COMPRESS_SUFFIX""$CMD_ENCRYPT_SUFFIX".tar && \ vbm "STATUS:Set PATHOUT_TAR to:$PATHOUT_TAR"; ## Check that PATHOUT_TAR is a tar. Rename old and create empty one otherwise. checkMakeTar "$PATHOUT_TAR" && vbm "DEBUG:Confirmed or Created to be a tar:$PATHOUT_TAR"; -- 2.30.2