From 5b4dd4538f16cd04f0af3739fdf9ea3c7895f02e Mon Sep 17 00:00:00 2001 From: Richard Goodwin Date: Sun, 21 Oct 2018 13:37:29 -0500 Subject: [PATCH] Better testing of pushover And archive loop logging weirdness. --- windows_archive/archive-teslacam-clips | 8 ++++---- windows_archive/archiveloop | 4 ++-- windows_archive/send-pushover | 9 ++++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/windows_archive/archive-teslacam-clips b/windows_archive/archive-teslacam-clips index 28bb689..1ddd7c4 100644 --- a/windows_archive/archive-teslacam-clips +++ b/windows_archive/archive-teslacam-clips @@ -1,11 +1,11 @@ #!/bin/bash -eu -LOG_FILE=/tmp/archive-teslacam-clips.log +LOG_FILE=/tmp/archiveloop.log CAM_MOUNT=/mnt/cam ARCHIVE_MOUNT=/mnt/archive function log () { - echo "$( date ) : $1" >> "$LOGFILE" + echo "$( date ) : $1" >> "$LOG_FILE" } function retry () { @@ -70,7 +70,7 @@ function ensure_mountpoint_is_mounted_with_retry () { function move_clips_to_archive () { log "Moving clips to archive..." - local move_count=0 + move_count=0 for file_name in "$CAM_MOUNT"/TeslaCam/saved*; do [ -e "$file_name" ] || continue log "Moving $file_name ..." @@ -80,7 +80,7 @@ function move_clips_to_archive () { done log "Moved $move_count file(s)." - if [ -r "/root/.teslaCamPushoverCredentials" ] && [ $move_count > 0 ] + if [ -e "/root/.teslaCamPushoverCredentials" ] && [ ${move_count} -gt 0 ] then log "Sending Pushover message for copied files." /root/bin/send-pushover $move_count diff --git a/windows_archive/archiveloop b/windows_archive/archiveloop index 2bb7797..5336ff3 100644 --- a/windows_archive/archiveloop +++ b/windows_archive/archiveloop @@ -2,10 +2,10 @@ # Change the value on the right side of the equal sign to the name of the server hosting the archive. ARCHIVE_HOST_NAME=archiveserver -LOGFILE=/tmp/archiveloop.log +LOG_FILE=/tmp/archiveloop.log function log () { - echo "$( date ) : $1" >> "$LOGFILE" + echo "$( date ) : $1" >> "$LOG_FILE" } function archive_is_reachable () { diff --git a/windows_archive/send-pushover b/windows_archive/send-pushover index f594667..cd92f3e 100644 --- a/windows_archive/send-pushover +++ b/windows_archive/send-pushover @@ -1,18 +1,21 @@ #!/bin/bash -eu -LOGFILE=/tmp/archiveloop.log +files_copied=$1 + +LOG_FILE=/tmp/archiveloop.log function log () { - echo "$( date ) : $1" >> "$LOGFILE" + echo "$( date ) : $1" >> "$LOG_FILE" } source /root/.teslaCamPushoverCredentials if ping -c 1 api.pushover.net &> /dev/null then + if [ ${files_copied} -gt 0 ] curl -F "token=$pushover_app_key" \ -F "user=$pushover_user_key" \ -F "title=Dashcam Copy Complete" \ - -F "message=$1 file(s) were copied." \ + -F "message=${files_copied} file(s) were copied." \ https://api.pushover.net/1/messages fi