mirror of
https://github.com/cimryan/teslausb.git
synced 2026-03-01 04:30:33 +00:00
Better testing of pushover
And archive loop logging weirdness.
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
#!/bin/bash -eu
|
#!/bin/bash -eu
|
||||||
|
|
||||||
LOG_FILE=/tmp/archive-teslacam-clips.log
|
LOG_FILE=/tmp/archiveloop.log
|
||||||
CAM_MOUNT=/mnt/cam
|
CAM_MOUNT=/mnt/cam
|
||||||
ARCHIVE_MOUNT=/mnt/archive
|
ARCHIVE_MOUNT=/mnt/archive
|
||||||
|
|
||||||
function log () {
|
function log () {
|
||||||
echo "$( date ) : $1" >> "$LOGFILE"
|
echo "$( date ) : $1" >> "$LOG_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function retry () {
|
function retry () {
|
||||||
@@ -70,7 +70,7 @@ function ensure_mountpoint_is_mounted_with_retry () {
|
|||||||
|
|
||||||
function move_clips_to_archive () {
|
function move_clips_to_archive () {
|
||||||
log "Moving clips to archive..."
|
log "Moving clips to archive..."
|
||||||
local move_count=0
|
move_count=0
|
||||||
for file_name in "$CAM_MOUNT"/TeslaCam/saved*; do
|
for file_name in "$CAM_MOUNT"/TeslaCam/saved*; do
|
||||||
[ -e "$file_name" ] || continue
|
[ -e "$file_name" ] || continue
|
||||||
log "Moving $file_name ..."
|
log "Moving $file_name ..."
|
||||||
@@ -80,7 +80,7 @@ function move_clips_to_archive () {
|
|||||||
|
|
||||||
done
|
done
|
||||||
log "Moved $move_count file(s)."
|
log "Moved $move_count file(s)."
|
||||||
if [ -r "/root/.teslaCamPushoverCredentials" ] && [ $move_count > 0 ]
|
if [ -e "/root/.teslaCamPushoverCredentials" ] && [ ${move_count} -gt 0 ]
|
||||||
then
|
then
|
||||||
log "Sending Pushover message for copied files."
|
log "Sending Pushover message for copied files."
|
||||||
/root/bin/send-pushover $move_count
|
/root/bin/send-pushover $move_count
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
# Change the value on the right side of the equal sign to the name of the server hosting the archive.
|
# Change the value on the right side of the equal sign to the name of the server hosting the archive.
|
||||||
ARCHIVE_HOST_NAME=archiveserver
|
ARCHIVE_HOST_NAME=archiveserver
|
||||||
LOGFILE=/tmp/archiveloop.log
|
LOG_FILE=/tmp/archiveloop.log
|
||||||
|
|
||||||
function log () {
|
function log () {
|
||||||
echo "$( date ) : $1" >> "$LOGFILE"
|
echo "$( date ) : $1" >> "$LOG_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function archive_is_reachable () {
|
function archive_is_reachable () {
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
#!/bin/bash -eu
|
#!/bin/bash -eu
|
||||||
|
|
||||||
LOGFILE=/tmp/archiveloop.log
|
files_copied=$1
|
||||||
|
|
||||||
|
LOG_FILE=/tmp/archiveloop.log
|
||||||
|
|
||||||
function log () {
|
function log () {
|
||||||
echo "$( date ) : $1" >> "$LOGFILE"
|
echo "$( date ) : $1" >> "$LOG_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
source /root/.teslaCamPushoverCredentials
|
source /root/.teslaCamPushoverCredentials
|
||||||
|
|
||||||
if ping -c 1 api.pushover.net &> /dev/null
|
if ping -c 1 api.pushover.net &> /dev/null
|
||||||
then
|
then
|
||||||
|
if [ ${files_copied} -gt 0 ]
|
||||||
curl -F "token=$pushover_app_key" \
|
curl -F "token=$pushover_app_key" \
|
||||||
-F "user=$pushover_user_key" \
|
-F "user=$pushover_user_key" \
|
||||||
-F "title=Dashcam Copy Complete" \
|
-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
|
https://api.pushover.net/1/messages
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user