From 84627d4893b9f8d8873baf0e069d243b40c6464b Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Fri, 6 Jul 2018 12:24:45 +0100
Subject: [PATCH] Copy usb canary image to syncthing if it is installed

---
 src/freedombone-notification | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/freedombone-notification b/src/freedombone-notification
index 8de1df916..09981542e 100755
--- a/src/freedombone-notification
+++ b/src/freedombone-notification
@@ -88,9 +88,6 @@ if [[ "$SUBJECT" == *"$canary_subject"* ]]; then
                 rm $notification_image_filename
             fi
             fswebcam -d /dev/video1 --jpeg 50 -D 1 $notification_image_filename
-            if [ -f $notification_image_filename ]; then
-                image_extra="-A $notification_image_filename"
-            fi
         else
             # Otherwise use the built-in camera
             if [ -f /dev/video0 ]; then
@@ -98,13 +95,18 @@ if [[ "$SUBJECT" == *"$canary_subject"* ]]; then
                     rm $notification_image_filename
                 fi
                 fswebcam -d /dev/video0 --jpeg 50 -D 1 $notification_image_filename
-                if [ -f $notification_image_filename ]; then
-                    image_extra="-A $notification_image_filename"
-                fi
             fi
         fi
     fi
 fi
+if [ -f $notification_image_filename ]; then
+    image_extra="-A $notification_image_filename"
+
+    # If syncthing is installed then copy the image to the admin
+    if [ -d "/home/$ADMIN_USERNAME/Sync" ]; then
+        cp $notification_image_filename "/home/$ADMIN_USERNAME/Sync/usb_canary.jpg"
+    fi
+fi
 
 # send email to administrator
 if [ "$SUBJECT" ]; then
-- 
GitLab