mirror of
https://github.com/cimryan/teslausb.git
synced 2026-03-01 04:30:33 +00:00
Make send-pushover safe to always invoke, and always invoke it. Split CIFS archiving to archive-cifs.sh
This commit is contained in:
@@ -1,35 +1,13 @@
|
||||
#!/bin/bash -eu
|
||||
|
||||
LOG_FILE=/tmp/archive-teslacam-clips.log
|
||||
ARCHIVE_MOUNT=/mnt/archive
|
||||
export LOG_FILE=/tmp/archive-teslacam-clips.log
|
||||
export ARCHIVE_MOUNT=/mnt/archive
|
||||
|
||||
function log () {
|
||||
echo "$( date )" >> "$LOG_FILE"
|
||||
echo "$1" >> "$LOG_FILE"
|
||||
}
|
||||
|
||||
function move_clips_to_archive () {
|
||||
log "Moving clips to archive..."
|
||||
local move_count=0
|
||||
for file_name in "$CAM_MOUNT"/TeslaCam/saved*; do
|
||||
[ -e "$file_name" ] || continue
|
||||
log "Moving $file_name ..."
|
||||
mv -- "$file_name" "$ARCHIVE_MOUNT" >> "$LOG_FILE" 2>&1 || echo ""
|
||||
log "Moved $file_name."
|
||||
move_count=$((move_count + 1))
|
||||
|
||||
done
|
||||
log "Moved $move_count file(s)."
|
||||
|
||||
if [ -r "/root/.teslaCamPushoverCredentials" ] && [ $move_count > 0]
|
||||
then
|
||||
log "Sending Pushover message for copied files."
|
||||
/root/bin/send-pushover $move_count
|
||||
fi
|
||||
|
||||
log "Finished moving clips to archive."
|
||||
}
|
||||
|
||||
function disconnect_usb_drives_from_host () {
|
||||
log "Disconnecting usb from host..."
|
||||
modprobe -r g_mass_storage
|
||||
@@ -42,6 +20,8 @@ function ensure_archive_is_mounted () {
|
||||
log "Ensured cam archive is mounted."
|
||||
}
|
||||
|
||||
export -f log
|
||||
|
||||
log "Starting..."
|
||||
|
||||
if [ ! -r "/root/.teslaCamRsyncConfig" ]
|
||||
@@ -57,10 +37,9 @@ fix_errors_in_cam_file
|
||||
|
||||
if [ -r "/root/.teslaCamRsyncConfig" ]
|
||||
then
|
||||
log "Archiving through rsync..."
|
||||
/root/bin/archive-rsync
|
||||
else
|
||||
move_clips_to_archive
|
||||
/root/bin/archive-cifs.sh
|
||||
fi
|
||||
|
||||
unmount_cam_file
|
||||
|
||||
Reference in New Issue
Block a user