#!/bin/bash
-
-# Desc: Records gps data until midnight
-# Author: Steven Baltakatei Sandoval; License: GPLv3+
-# Usage: bkgpslog -o [output dir]
+# Desc: Records gps data
#==BEGIN Define script parameters==
## Logging Behavior parameters
SCRIPT_TIME_START=$(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.5"; # Define version of 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)
TIME_INPUT="$argTime";
else
### F: Time argument not valid; exit
- yell "ERROR:Invalid time argument supplied. Exiting."; exit 1;
+ yell "ERROR:Invalid time argument supplied: \"$argTime\""; yell "Exiting."; exit 1;
fi
fi
# Construct and deliver separator-les date string
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")")".."$SCRIPT_HOSTNAME""_location""$CMD_COMPRESS_SUFFIX""$CMD_ENCRYPT_SUFFIX".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 && \
vbm "STATUS:Set PATHOUT_TAR to:$PATHOUT_TAR";
# DEBUG: check vars
vbm "STATUS:FN :$FN";
## Note: SCRIPT_TTL_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")";
+ bufferTTL_STR="$(timeDuration "$BUFFER_TTL")" && vbm "DEBUG:bufferTTL_STR:$bufferTTL_STR";
# Init temp working dir
- try mkdir "$DIR_TMP" && vbm "DEBUG:Working dir creatd at:$DIR_TMP";
+ 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"))
# MAIN LOOP:Record gps data until script lifespan ends
timeBufferFirstNS="$(timeEpochNS)"; bufferRound=0; BUFFER_TTL_ADJ_FLOAT="$BUFFER_TTL";
while [[ "$SECONDS" -lt "$SCRIPT_TTL" ]]; do
+ if ! [[ -d "$DIR_TMP" ]]; then yell "ERROR:DIR_TMP existence failure:$DIR_TMP"; try mkdir "$DIR_TMP" && vbm "DEBUG:Working dir recreated DIR_TMP:$DIR_TMP"; fi
magicParseRecipientDir;
magicGatherWriteBuffer &
sleep "$BUFFER_TTL_ADJ_FLOAT"; # adjusted by magicBufferSleepPID
# Cleanup
## Remove DIR_TMP
- try rm -r "$DIR_TMP";
+ try rm -r "$DIR_TMP" && vbm "Removed DIR_TMP:$DIR_TMP";
vbm "STATUS:Main function finished.";
} # Main function.
main "$@" # Run main function.
exit 0;
#==END Perform work and exit==
+
+# Author: Steven Baltakatei Sandoval;
+# License: GPLv3+