+ fi
+} # Form compression cmd string and filename suffix
+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
+ # Output: vars: DIR_TMP
+ # Depends: processArguments(), vbm(), yell()
+ # Parse '-t' option (user-specified temporary working dir)
+ ## Set DIR_TMP_PARENT to user-specified value if specified
+ local DIR_TMP_PARENT
+
+ if [[ "$OPTION_TMPDIR" = "true" ]]; then
+ if [[ -d "$argTempDirPriority" ]]; then
+ DIR_TMP_PARENT="$argTempDirPriority";
+ else
+ yell "WARNING:Specified temporary working directory not valid:$argTempDirPriority";
+ exit 1; # Exit since user requires a specific temp dir and it is not available.
+ fi;
+ else
+ ## Set DIR_TMP_PARENT to default or fallback otherwise
+ if [[ -d "$DIR_TMP_DEFAULT" ]]; then
+ DIR_TMP_PARENT="$DIR_TMP_DEFAULT";
+ elif [[ -d /tmp ]]; then
+ yell "WARNING:$DIR_TMP_DEFAULT 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().
+} # 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)
+ # Depends validateInput(), showUsage(), yell
+
+ # React to '-b, --buffer-ttl' option
+ if [[ "$OPTION_CUSTOM_BUFFERTTL" = "true" ]]; then
+ ## T: Check if argCustomBufferTTL is an integer
+ if validateInput "$argCustomBufferTTL" "integer"; then
+ ### T: argCustomBufferTTL is an integer
+ BUFFER_TTL="$argCustomBufferTTL";
+ else
+ ### F: argcustomBufferTTL is not an integer
+ yell "ERROR:Invalid integer argument for custom buffer time-to-live."; showUsage; exit 1;
+ fi;
+ ## F: do not change BUFFER_TTL
+ fi;
+
+ # React to '-B, --script-ttl' option
+ if [[ "$OPTION_CUSTOM_SCRIPTTTL_TE" = "true" ]]; then
+ ## 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";
+ 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
+ fi;
+} # Sets custom script or buffer TTL if specified
+