From de3371f00caa060780fcee8d82114b3de0fa8212 Mon Sep 17 00:00:00 2001 From: Gocnak Date: Sat, 20 Oct 2018 05:30:57 -0400 Subject: [PATCH] rsync will not be using the mnt/archive folder It'll instead bypass and just call itself on its own --- windows_archive/archive-rsync | 14 ++++++++++++-- windows_archive/archive-teslacam-clips | 23 ++++++++++------------- windows_archive/setup-teslausb | 2 +- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/windows_archive/archive-rsync b/windows_archive/archive-rsync index 8881d21..b076721 100644 --- a/windows_archive/archive-rsync +++ b/windows_archive/archive-rsync @@ -7,6 +7,16 @@ function log () { source /root/.teslaCamRsyncConfig -rsync -au /mnt/archive $user@$server:$path +nfiles=$(rsync -auh --stats /mnt/cam/TeslaCam/saved* $user@$server:$path | awk '/files transferred/{print $NF}') -log "Successfully synced files through rsync!" \ No newline at end of file +if [ $nfiles > 0 ] +then + if [ -r "/root/.teslaCamPushoverCredentials" ] && [ $nfiles > 0] + then + log "Sending Pushover message for copied files." + /root/bin/send-pushover $nfiles + fi + log "Successfully synced files through rsync!" +else + log "No files to archive through rsync!" +fi \ No newline at end of file diff --git a/windows_archive/archive-teslacam-clips b/windows_archive/archive-teslacam-clips index a9c6b4d..23bdf4d 100644 --- a/windows_archive/archive-teslacam-clips +++ b/windows_archive/archive-teslacam-clips @@ -82,19 +82,10 @@ function move_clips_to_archive () { done log "Moved $move_count file(s)." - if [ $move_count > 0] + if [ -r "/root/.teslaCamPushoverCredentials" ] && [ $move_count > 0] then - if [ -r "/root/.teslaCamRsyncConfig" ] - then - log "Archiving through rsync..." - /root/bin/archive-rsync - fi - - if [ -r "/root/.teslaCamPushoverCredentials" ] - then - log "Sending Pushover message for copied files." - /root/bin/send-pushover $move_count - fi + log "Sending Pushover message for copied files." + /root/bin/send-pushover $move_count fi log "Finished moving clips to archive." @@ -143,7 +134,13 @@ fix_errors_on_cam_drive ensure_cam_drive_is_mounted -move_clips_to_archive +if [ -r "/root/.teslaCamRsyncConfig" ] +then + log "Archiving through rsync..." + /root/bin/archive-rsync +else + move_clips_to_archive +fi unmount_cam_drive diff --git a/windows_archive/setup-teslausb b/windows_archive/setup-teslausb index 428b3cf..4fa2540 100644 --- a/windows_archive/setup-teslausb +++ b/windows_archive/setup-teslausb @@ -108,7 +108,6 @@ function create_usb_drive_backing_files () { function configure_archive () { echo "Configuring the archive..." - mkdir /mnt/archive if [ $RSYNC_ENABLE = true ] then echo "Configuring for Rsync..." @@ -117,6 +116,7 @@ function configure_archive () { echo "path=$RSYNC_PATH" > /root/.teslaCamRsyncConfig else echo "Configuring for a shared drive..." + mkdir /mnt/archive local archive_server_ip_address="$(ping -c 1 -w 1 $archiveserver 2>/dev/null | head -n 1 | grep -o -e "(\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\})" | tr -d '()')" echo "//$archive_server_ip_address/$sharename /mnt/archive cifs vers=3,credentials=/root/.teslaCamArchiveCredentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0" >> /etc/fstab