X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02.git/blobdiff_plain/032f4b050a0ebb190fdef3497e2dee52cd04031b..39a3d6f780360b8ee0e2d044c33c63cdbb36a105:/exec/bkgpslog?ds=sidebyside diff --git a/exec/bkgpslog b/exec/bkgpslog deleted file mode 100755 index df20b54..0000000 --- a/exec/bkgpslog +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash - -# Date: 2020-03-30T02:13Z -# Author: Steven Baltakatei Sandoval - -#== Variable Initialization == - -#== Global constants == -PATH="/usr/local/bin/:$PATH" # Add default OpenTimestamps path to PATH (necessary if cron used to call this script) -PATH="/opt/bktei:$PATH" # Add default baltakatei script install directory to PATH (necessary for other bk scripts) -SCRIPT_HOSTNAME=$(hostname) # Save hostname of system running this script. -SCRIPT_VERSION="bkgpslog 0.0.1" # Define version of script. -SCRIPT_TIME_SHORT="$(date +%Y%m%dT%H%M%S%z)" # Save current date & time in ISO-8601 format. -SCRIPT_DATE_SHORT="$(date +%Y%m%d)" # Save current date in ISO-8601 format. -#DIROUT1="/home/pi/Sync/Evanescent_Location" # Define output directory. - -#== Function Definitions == -echoerr() { - echo "$@" 1>&2; # Define stderr echo function. -} # Define stderr message function. -showUsage() { - echoerr "USAGE:" - echoerr " bkgpslog.sh [ options ]" - echoerr - echoerr "OPTIONS:" - echoerr " -h, --help" - echoerr " Display help information." - echoerr - echoerr " --version" - echoerr " Display script version." - echoerr - echoerr " -v, --verbose" - echoerr " Display debugging info." - echoerr - echoerr " -o, --output [ directory ]" - echoerr " Specify output directory to save logs." -} # Display information on how to use this script. -showVersion() { - echoerr "$SCRIPT_VERSION" -} # Display script version. -vbm() { - if [ $OPTION_VERBOSE -eq "true" ]; then - echoerr "$@" - fi -} # Verbose message display function. -processArguments() { - while [ ! $# -eq 0 ]; do # While number of arguments ($#) is not (!) equal to (-eq) zero (0). - echoerr "DEBUG:Starting processArguments while loop." - echoerr "DEBUG:Provided arguments are:""$@" - case "$1" in - --h | --help) showUsage; exit 1;; # Display usage. - --version) showVersion; exit 1;; # Show version - --v | --verbose) OPTION_VERBOSE="true"; vbm "DEBUG:Verbose mode enabled.";; # Enable verbose mode. - --o | --output) if [ -d "$2" ]; then DIROUT1="$2"; fi ;; # Define output directory. - *) echoerr "ERROR: Unrecognized argument."; exit 1;; # Handle unrecognized options. - esac - shift - done -} # Argument Processing -checkExecutables() { - -} # Check that certain executables exist. - -main() { - processArguments # Process arguments. - checkExecutables "gpspipe" # Confirm that executables necessary to run are available. -} # Main function. - - - - - - -if [[ -d "$DIROUT1" ]] && command -v "gpspipe" 1>/dev/null 2>/dev/null ; then - while true; do - #echoerr "DEBUG:Starting while loop." - # Update time constants - TIME_CURRENT="$(date --iso-8601=seconds)" ; - #echoerr "DEBUG:TIME_CURRENT is:""$TIME_CURRENT" ; - TIME_CURRENT_SHORT="$(date -d "$TIME_CURRENT" +%Y%m%dT%H%M%S%z)" - #echoerr "DEBUG:TIME_CURRENT_SHORT is""$TIME_CURRENT_SHORT" - DATE_CURRENT="$(date -d "$TIME_CURRENT" --iso-8601=date)" ; - #echoerr "DEBUG:DATE_CURRENT is:""$DATE_CURRENT" ; - DATE_CURRENT_SHORT="$(date -d "$TIME_CURRENT" +%Y%m%d)" ; - #echoerr "DEBUG:DATE_CURRENT is:""$DATE_CURRENT_SHORT" ; - DATE_TOMORROW="$(date -d "$TIME_CURRENT next day" --iso-8601=date)" ; - #echoerr "DEBUG:DATE_TOMORROW is:""$DATE_TOMORROW" ; - TIME_NEXT_MIDNIGHT="$(date -d "$DATE_TOMORROW" --iso-8601=seconds)" ; - #echoerr "DEBUG:TIME_NEXT_MIDNIGHT is:""$TIME_NEXT_MIDNIGHT" ; - SECONDS_UNTIL_NEXT_MIDNIGHT="$(( $(date +%s -d "$TIME_NEXT_MIDNIGHT") - $(date +%s -d "$TIME_CURRENT") ))" ; - #echoerr "DEBUG:SECONDS_UNTIL_NEXT_MIDNIGHT is:""$SECONDS_UNTIL_NEXT_MIDNIGHT" ; - if [ "$SECONDS_UNTIL_NEXT_MIDNIGHT" -eq 0 ]; then echoerr "WARNING:Is it exactly midnight?" ; continue; fi ; # Exit loop early if equal to 0 because "timeout 0s" never ends. - if [ "$SECONDS_UNTIL_NEXT_MIDNIGHT" -lt 0 ]; then echoerr "ERROR:Time until midnight error." ; exit 1; fi ; # Exit script if equal to 0 because "timeout 0s" never ends. - - # Update output file names. - DIROUTN="$DIROUT1" ; - FILEOUTN="$DATE_CURRENT_SHORT""..""$(hostname)""_location.nmea" ; - - # Append location log until midnight. - timeout "$SECONDS_UNTIL_NEXT_MIDNIGHT""s" gpspipe -r 1>> "$DIROUTN"/"$FILEOUTN" 2>>/dev/null ; # log raw nmea data - done - - #gpspipe -r -d -l -o "$DIROUT1"/"$FILEOUT1" ; - -else - echo "$SCRIPT_TIME_SHORT"">gpspipe or $DIROUT1 not found." >> ~/"$SCRIPT_DATE_SHORT"..error.log ; -fi